From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C5C6345834; Wed, 21 Aug 2024 18:28:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DEDC42D76; Wed, 21 Aug 2024 18:28:13 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 226C742D26 for ; Wed, 21 Aug 2024 18:28:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724257690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=am6pJyf6ks3TFAJJqEOutZkU22MkT7AqYbiqQftdNho=; b=SonKzbhIjhOaHr73RilkFC9+i1jUcldHDJGD7gBiQHD0SkabBzi0Yx64DHWc58ekZn5TvZ kQOBXvy2wZOCynHF2W8yDuPGj7CgCUtzldq0I77ancamBjnKUPl2QUCykajzTt6rjei+Tt oWe3zmcxuagMEaumxV3A/zmJzrViDfY= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-33-ePjv-MUHN3WCrc3tYWvzkQ-1; Wed, 21 Aug 2024 12:28:07 -0400 X-MC-Unique: ePjv-MUHN3WCrc3tYWvzkQ-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A6ED418BEFB2; Wed, 21 Aug 2024 16:27:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.208.21]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2F9A318FE366; Wed, 21 Aug 2024 16:27:00 +0000 (UTC) From: Robin Jarry To: dev@dpdk.org, Cristian Dumitrescu Subject: [PATCH dpdk v1 09/15] pipeline: use ipv6 addr struct Date: Wed, 21 Aug 2024 18:25:26 +0200 Message-ID: <20240821162516.610624-26-rjarry@redhat.com> In-Reply-To: <20240821162516.610624-17-rjarry@redhat.com> References: <20240821162516.610624-17-rjarry@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Update rte_table_action_ipv6_header and rte_table_action_nat_params to use the recently added IPv6 address structure instead of uint8_t[16] arrays. Signed-off-by: Robin Jarry --- examples/ip_pipeline/cli.c | 12 +++++------ lib/pipeline/rte_table_action.c | 36 +++++++++++++-------------------- lib/pipeline/rte_table_action.h | 7 ++++--- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c index e8269ea90c11..66fdeac8f501 100644 --- a/examples/ip_pipeline/cli.c +++ b/examples/ip_pipeline/cli.c @@ -3540,8 +3540,8 @@ parse_table_action_encap(char **tokens, parser_read_uint8(&hop_limit, tokens[5])) return 0; - memcpy(a->encap.vxlan.ipv6.sa, sa.s6_addr, 16); - memcpy(a->encap.vxlan.ipv6.da, da.s6_addr, 16); + memcpy(&a->encap.vxlan.ipv6.sa, sa.s6_addr, 16); + memcpy(&a->encap.vxlan.ipv6.da, da.s6_addr, 16); a->encap.vxlan.ipv6.flow_label = flow_label; a->encap.vxlan.ipv6.dscp = dscp; a->encap.vxlan.ipv6.hop_limit = hop_limit; @@ -3615,7 +3615,7 @@ parse_table_action_nat(char **tokens, return 0; a->nat.ip_version = 0; - memcpy(a->nat.addr.ipv6, addr.s6_addr, 16); + memcpy(&a->nat.addr.ipv6, addr.s6_addr, 16); a->nat.port = port; a->action_mask |= 1 << RTE_TABLE_ACTION_NAT; return 4; @@ -4956,9 +4956,9 @@ table_rule_show(const char *pipeline_name, (uint32_t)a->encap.vxlan.ipv4.ttl); } else { fprintf(f, " ipv6 "); - ipv6_addr_show(f, a->encap.vxlan.ipv6.sa); + ipv6_addr_show(f, a->encap.vxlan.ipv6.sa.a); fprintf(f, " "); - ipv6_addr_show(f, a->encap.vxlan.ipv6.da); + ipv6_addr_show(f, a->encap.vxlan.ipv6.da.a); fprintf(f, " %u %u %u ", a->encap.vxlan.ipv6.flow_label, (uint32_t)a->encap.vxlan.ipv6.dscp, @@ -4980,7 +4980,7 @@ table_rule_show(const char *pipeline_name, if (a->nat.ip_version) ipv4_addr_show(f, a->nat.addr.ipv4); else - ipv6_addr_show(f, a->nat.addr.ipv6); + ipv6_addr_show(f, a->nat.addr.ipv6.a); fprintf(f, " %u ", (uint32_t)(a->nat.port)); } diff --git a/lib/pipeline/rte_table_action.c b/lib/pipeline/rte_table_action.c index a04d5121e1f0..8479f984e4ea 100644 --- a/lib/pipeline/rte_table_action.c +++ b/lib/pipeline/rte_table_action.c @@ -872,12 +872,8 @@ encap_vxlan_apply(void *data, d->ipv6.payload_len = 0; /* not pre-computed */ d->ipv6.proto = IP_PROTO_UDP; d->ipv6.hop_limits = p->vxlan.ipv6.hop_limit; - memcpy(&d->ipv6.src_addr, - p->vxlan.ipv6.sa, - sizeof(p->vxlan.ipv6.sa)); - memcpy(&d->ipv6.dst_addr, - p->vxlan.ipv6.da, - sizeof(p->vxlan.ipv6.da)); + rte_ipv6_addr_cpy(&d->ipv6.src_addr, &p->vxlan.ipv6.sa); + rte_ipv6_addr_cpy(&d->ipv6.dst_addr, &p->vxlan.ipv6.da); /* UDP */ d->udp.src_port = rte_htons(p->vxlan.udp.sp); @@ -907,12 +903,8 @@ encap_vxlan_apply(void *data, d->ipv6.payload_len = 0; /* not pre-computed */ d->ipv6.proto = IP_PROTO_UDP; d->ipv6.hop_limits = p->vxlan.ipv6.hop_limit; - memcpy(&d->ipv6.src_addr, - p->vxlan.ipv6.sa, - sizeof(p->vxlan.ipv6.sa)); - memcpy(&d->ipv6.dst_addr, - p->vxlan.ipv6.da, - sizeof(p->vxlan.ipv6.da)); + rte_ipv6_addr_cpy(&d->ipv6.src_addr, &p->vxlan.ipv6.sa); + rte_ipv6_addr_cpy(&d->ipv6.dst_addr, &p->vxlan.ipv6.da); /* UDP */ d->udp.src_port = rte_htons(p->vxlan.udp.sp); @@ -1211,7 +1203,7 @@ struct nat_ipv4_data { } __rte_packed; struct nat_ipv6_data { - uint8_t addr[16]; + struct rte_ipv6_addr addr; uint16_t port; } __rte_packed; @@ -1258,7 +1250,7 @@ nat_apply(void *data, } else { struct nat_ipv6_data *d = data; - memcpy(d->addr, p->addr.ipv6, sizeof(d->addr)); + rte_ipv6_addr_cpy(&d->addr, &p->addr.ipv6); d->port = rte_htons(p->port); } @@ -1438,11 +1430,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip, tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum, (uint16_t *)&ip->src_addr, - (uint16_t *)data->addr, + (uint16_t *)&data->addr, tcp->src_port, data->port); - rte_memcpy(&ip->src_addr, data->addr, 16); + rte_ipv6_addr_cpy(&ip->src_addr, &data->addr); tcp->src_port = data->port; tcp->cksum = tcp_cksum; } else { @@ -1451,11 +1443,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip, udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum, (uint16_t *)&ip->src_addr, - (uint16_t *)data->addr, + (uint16_t *)&data->addr, udp->src_port, data->port); - rte_memcpy(&ip->src_addr, data->addr, 16); + rte_ipv6_addr_cpy(&ip->src_addr, &data->addr); udp->src_port = data->port; udp->dgram_cksum = udp_cksum; } @@ -1466,11 +1458,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip, tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum, (uint16_t *)&ip->dst_addr, - (uint16_t *)data->addr, + (uint16_t *)&data->addr, tcp->dst_port, data->port); - rte_memcpy(&ip->dst_addr, data->addr, 16); + rte_ipv6_addr_cpy(&ip->dst_addr, &data->addr); tcp->dst_port = data->port; tcp->cksum = tcp_cksum; } else { @@ -1479,11 +1471,11 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip, udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum, (uint16_t *)&ip->dst_addr.a, - (uint16_t *)data->addr, + (uint16_t *)&data->addr, udp->dst_port, data->port); - rte_memcpy(&ip->dst_addr, data->addr, 16); + rte_ipv6_addr_cpy(&ip->dst_addr, &data->addr); udp->dst_port = data->port; udp->dgram_cksum = udp_cksum; } diff --git a/lib/pipeline/rte_table_action.h b/lib/pipeline/rte_table_action.h index 5dffbeb70031..b119ac03dc6e 100644 --- a/lib/pipeline/rte_table_action.h +++ b/lib/pipeline/rte_table_action.h @@ -60,6 +60,7 @@ extern "C" { #include #include +#include #include #include @@ -419,8 +420,8 @@ struct rte_table_action_ipv4_header { /** Pre-computed IPv6 header fields for encapsulation action. */ struct rte_table_action_ipv6_header { - uint8_t sa[16]; /**< Source address. */ - uint8_t da[16]; /**< Destination address. */ + struct rte_ipv6_addr sa; /**< Source address. */ + struct rte_ipv6_addr da; /**< Destination address. */ uint32_t flow_label; /**< Flow label. */ uint8_t dscp; /**< DiffServ Code Point (DSCP). */ uint8_t hop_limit; /**< Hop Limit (HL). */ @@ -597,7 +598,7 @@ struct rte_table_action_nat_params { uint32_t ipv4; /** IPv6 address; only valid when *ip_version* is set to 0. */ - uint8_t ipv6[16]; + struct rte_ipv6_addr ipv6; } addr; /** Port. */ -- 2.46.0