Skip to contentSkip to conversation

IPv6 APIs overhaul

PATCH Superseded Robin Jarry 7 participants 127 messages Aug 21, 2024 – Jul 24 Page 2 of 3

Subsystems (4)
lore
Share & tools
lore
#72 lore raw

PATCH v3 5/17 net: use struct rte_ipv6_addr for header addresses

In reply to Robin Jarry

The rte_ipv6_hdr uses ad-hoc uint8_t[16] arrays to represent addresses. Replace these arrays with the newly added rte_ipv6_addr structure. Adapt all code accordingly.

---

Notes:
v3:

- replace *memcpy(ipv6) with direct struct assignments
- replace RTE_IPV6_ADDR() invocations with RTE_IPV6()
- replace string initializers with RTE_IPV6_FULL_MASK or RTE_IPV6()
- use RTE_IPV6_ADDR_FMT and RTE_IPV6_ADDR_SPLIT where possible
- replace stray in6_addr with rte_ipv6_addr in drivers/net/mvpp2/mrvl_flow.c

 app/test-flow-perf/items_gen.c           |  4 +--
 app/test-pipeline/pipeline_hash.c        |  4 +--
 app/test/packet_burst_generator.c        |  4 +--
 app/test/test_ipfrag.c                   |  4 +--
 app/test/test_reassembly_perf.c          | 23 +++++++-------
 app/test/test_thash.c                    |  8 ++---
 doc/guides/rel_notes/deprecation.rst     |  2 --
 doc/guides/rel_notes/release_24_11.rst   |  1 +
 drivers/net/bnxt/bnxt_flow.c             | 12 ++++----
 drivers/net/bonding/rte_eth_bond_pmd.c   |  6 ++--
 drivers/net/cxgbe/cxgbe_flow.c           | 16 ++++------
 drivers/net/dpaa2/dpaa2_flow.c           | 24 +++++++--------
 drivers/net/hinic/hinic_pmd_flow.c       |  6 ++--
 drivers/net/hinic/hinic_pmd_tx.c         |  2 +-
 drivers/net/hns3/hns3_flow.c             |  8 ++---
 drivers/net/i40e/i40e_flow.c             | 12 ++++----
 drivers/net/iavf/iavf_fdir.c             |  8 ++---
 drivers/net/iavf/iavf_fsub.c             |  8 ++---
 drivers/net/iavf/iavf_ipsec_crypto.c     |  6 ++--
 drivers/net/ice/ice_fdir_filter.c        | 12 ++++----
 drivers/net/ice/ice_switch_filter.c      | 16 +++++-----
 drivers/net/igc/igc_flow.c               |  4 +--
 drivers/net/ixgbe/ixgbe_flow.c           | 12 ++++----
 drivers/net/ixgbe/ixgbe_ipsec.c          |  4 +--
 drivers/net/mlx5/hws/mlx5dr_definer.c    | 36 +++++++++++-----------
 drivers/net/mlx5/mlx5_flow.c             |  8 ++---
 drivers/net/mlx5/mlx5_flow_dv.c          | 20 ++++---------
 drivers/net/mlx5/mlx5_flow_hw.c          | 12 +++-----
 drivers/net/mlx5/mlx5_flow_verbs.c       |  8 ++---
 drivers/net/mvpp2/mrvl_flow.c            | 16 ++++------
 drivers/net/nfp/flower/nfp_flower_flow.c | 32 ++++++++++----------
 drivers/net/nfp/nfp_net_flow.c           | 38 +++++++++++-------------
 drivers/net/qede/qede_filter.c           |  4 +--
 drivers/net/sfc/sfc_flow.c               | 22 +++++---------
 drivers/net/tap/tap_flow.c               | 14 +++------
 drivers/net/txgbe/txgbe_flow.c           | 12 ++++----
 drivers/net/txgbe/txgbe_ipsec.c          |  4 +--
 examples/ip_fragmentation/main.c         |  2 +-
 examples/ip_pipeline/pipeline.c          | 16 +++++-----
 examples/ip_reassembly/main.c            |  2 +-
 examples/ipsec-secgw/flow.c              | 33 ++++----------------
 examples/ipsec-secgw/ipsec.c             |  8 ++---
 examples/ipsec-secgw/sa.c                |  4 +--
 examples/ipsec-secgw/sad.h               | 10 ++++---
 examples/l3fwd/l3fwd_fib.c               |  2 +-
 examples/l3fwd/l3fwd_lpm.c               |  4 +--
 lib/ethdev/rte_flow.h                    |  8 ++---
 lib/hash/rte_thash.h                     | 12 ++++----
 lib/ip_frag/rte_ipv6_reassembly.c        |  4 +--
 lib/net/rte_ip6.h                        |  6 ++--
 lib/node/ip6_lookup.c                    | 10 +++----
 lib/pipeline/rte_swx_ipsec.c             |  6 ++--
 lib/pipeline/rte_table_action.c          | 24 +++++++--------
 53 files changed, 255 insertions(+), 328 deletions(-)
app/test-flow-perf/items_gen.c +2 -2
index 4ae72509d445..c740e1838ffb 100644
@@ -78,8 +78,8 @@ add_ipv6(struct rte_flow_item *items,
 	for (i = 0; i < 16; i++) {
 		/* Currently src_ip is limited to 32 bit */
 		if (i < 4)
-			ipv6_specs[ti].hdr.src_addr[15 - i] = para.src_ip >> (i * 8);
-		ipv6_masks[ti].hdr.src_addr[15 - i] = 0xff;
+			ipv6_specs[ti].hdr.src_addr.a[15 - i] = para.src_ip >> (i * 8);
+		ipv6_masks[ti].hdr.src_addr.a[15 - i] = 0xff;
 	}
 
 	items[items_counter].type = RTE_FLOW_ITEM_TYPE_IPV6;
app/test-pipeline/pipeline_hash.c +1 -3
index cab9c2098014..194e5c5dcc53 100644
@@ -432,7 +432,6 @@ app_main_loop_rx_metadata(void) {
 				struct rte_ipv4_hdr *ip_hdr;
 				struct rte_ipv6_hdr *ipv6_hdr;
 				uint32_t ip_dst;
-				uint8_t *ipv6_dst;
 				uint32_t *signature, *k32;
 
 				m = app.mbuf_rx.array[j];
@@ -452,9 +451,8 @@ app_main_loop_rx_metadata(void) {
 				} else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
 					ipv6_hdr = (struct rte_ipv6_hdr *)
 						&m_data[sizeof(struct rte_ether_hdr)];
-					ipv6_dst = ipv6_hdr->dst_addr;
 
-					memcpy(key, ipv6_dst, 16);
+					memcpy(key, &ipv6_hdr->dst_addr, 16);
 				} else
 					continue;
 
app/test/packet_burst_generator.c +2 -2
index 2cd34abc1a65..76a409a56452 100644
@@ -149,8 +149,8 @@ initialize_ipv6_header(struct rte_ipv6_hdr *ip_hdr, uint8_t *src_addr,
 	ip_hdr->proto = IPPROTO_UDP;
 	ip_hdr->hop_limits = IP_DEFTTL;
 
-	rte_memcpy(ip_hdr->src_addr, src_addr, sizeof(ip_hdr->src_addr));
-	rte_memcpy(ip_hdr->dst_addr, dst_addr, sizeof(ip_hdr->dst_addr));
+	rte_memcpy(&ip_hdr->src_addr, src_addr, sizeof(ip_hdr->src_addr));
+	rte_memcpy(&ip_hdr->dst_addr, dst_addr, sizeof(ip_hdr->dst_addr));
 
 	return (uint16_t) (pkt_data_len + sizeof(struct rte_ipv6_hdr));
 }
app/test/test_ipfrag.c +2 -2
index 8e4df220a214..18d672715729 100644
@@ -238,8 +238,8 @@ v6_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s, uint8_t ttl,
 	hdr->proto = proto;
 	hdr->hop_limits = ttl;
 
-	memset(hdr->src_addr, 0x08, sizeof(hdr->src_addr));
-	memset(hdr->dst_addr, 0x04, sizeof(hdr->src_addr));
+	memset(&hdr->src_addr, 0x08, sizeof(hdr->src_addr));
+	memset(&hdr->dst_addr, 0x04, sizeof(hdr->src_addr));
 }
 
 static inline void
app/test/test_reassembly_perf.c +12 -11
index 3912179022fc..15db19add917 100644
@@ -8,6 +8,7 @@
 #include <rte_ether.h>
 #include <rte_hexdump.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_ip_frag.h>
 #include <rte_mbuf.h>
 #include <rte_mbuf_pool_ops.h>
@@ -36,7 +37,7 @@
 #define IP_DST_ADDR(x) ((198U << 24) | (18 << 16) | (1 << 15) | (x))
 
 /* 2001:0200::/48 is IANA reserved range for IPv6 benchmarking (RFC5180) */
-static uint8_t ip6_addr[16] = {32, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+static struct rte_ipv6_addr ip6_addr = RTE_IPV6(0x2001, 0x0200, 0, 0, 0, 0, 0, 0);
 #define IP6_VERSION 6
 
 #define IP_DEFTTL 64 /* from RFC 1340. */
@@ -340,17 +341,17 @@ ipv6_frag_fill_data(struct rte_mbuf **mbuf, uint8_t nb_frags, uint32_t flow_id,
 			rte_cpu_to_be_16(pkt_len - sizeof(struct rte_ipv6_hdr));
 		ip_hdr->proto = IPPROTO_FRAGMENT;
 		ip_hdr->hop_limits = IP_DEFTTL;
-		memcpy(ip_hdr->src_addr, ip6_addr, sizeof(ip_hdr->src_addr));
-		memcpy(ip_hdr->dst_addr, ip6_addr, sizeof(ip_hdr->dst_addr));
-		ip_hdr->src_addr[7] = (flow_id >> 16) & 0xf;
-		ip_hdr->src_addr[7] |= 0x10;
-		ip_hdr->src_addr[8] = (flow_id >> 8) & 0xff;
-		ip_hdr->src_addr[9] = flow_id & 0xff;
+		ip_hdr->src_addr = ip6_addr;
+		ip_hdr->dst_addr = ip6_addr;
+		ip_hdr->src_addr.a[7] = (flow_id >> 16) & 0xf;
+		ip_hdr->src_addr.a[7] |= 0x10;
+		ip_hdr->src_addr.a[8] = (flow_id >> 8) & 0xff;
+		ip_hdr->src_addr.a[9] = flow_id & 0xff;
 
-		ip_hdr->dst_addr[7] = (flow_id >> 16) & 0xf;
-		ip_hdr->dst_addr[7] |= 0x20;
-		ip_hdr->dst_addr[8] = (flow_id >> 8) & 0xff;
-		ip_hdr->dst_addr[9] = flow_id & 0xff;
+		ip_hdr->dst_addr.a[7] = (flow_id >> 16) & 0xf;
+		ip_hdr->dst_addr.a[7] |= 0x20;
+		ip_hdr->dst_addr.a[8] = (flow_id >> 8) & 0xff;
+		ip_hdr->dst_addr.a[9] = flow_id & 0xff;
 
 		frag_hdr->next_header = IPPROTO_UDP;
 		frag_hdr->reserved = 0;
app/test/test_thash.c +4 -4
index 65d42fd90085..952da6a52954 100644
@@ -145,10 +145,10 @@ test_toeplitz_hash_calc(void)
 	}
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
 		/*Fill ipv6 hdr*/
-		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr); j++)
-			ipv6_hdr.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr); j++)
-			ipv6_hdr.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr.a); j++)
+			ipv6_hdr.src_addr.a[j] = v6_tbl[i].src_ip[j];
+		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr.a); j++)
+			ipv6_hdr.dst_addr.a[j] = v6_tbl[i].dst_ip[j];
 		/*Load and convert ipv6 address into tuple*/
 		rte_thash_load_v6_addrs(&ipv6_hdr, &tuple);
 		tuple.v6.sport = v6_tbl[i].src_port;
doc/guides/rel_notes/deprecation.rst +0 -2
index 211f59fdc9a2..439867289cf3 100644
@@ -87,8 +87,6 @@ Deprecation Notices
     - ``rte_lpm6_delete_bulk_func()``
     - ``rte_lpm6_lookup()``
     - ``rte_lpm6_lookup_bulk_func()``
-  net
-    - ``struct rte_ipv6_hdr``
   node
     - ``rte_node_ip6_route_add()``
   pipeline
doc/guides/rel_notes/release_24_11.rst +1 -0
index 182e890aa8f2..e769d275f784 100644
@@ -143,6 +143,7 @@ API Changes
    =======================================================
 
 * net: IPv6 related symbols were moved from ``<rte_ip.h>`` to the new ``<rte_ip6.h>`` header.
+* net: The ``rte_ipv6_hdr`` structure was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
 
 ABI Changes
 -----------
drivers/net/bnxt/bnxt_flow.c +6 -6
index 03413e912149..c41403c753cf 100644
@@ -424,22 +424,22 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,
 					EM_FLOW_ALLOC_INPUT_EN_DST_IPADDR;
 
 			rte_memcpy(filter->src_ipaddr,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(filter->dst_ipaddr,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 
-			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.src_addr,
+			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.src_addr.a,
 						   16)) {
 				rte_memcpy(filter->src_ipaddr_mask,
-					   ipv6_mask->hdr.src_addr, 16);
+					   &ipv6_mask->hdr.src_addr, 16);
 				en |= !use_ntuple ? 0 :
 				    NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_IPADDR_MASK;
 			}
 
-			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.dst_addr,
+			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.dst_addr.a,
 						   16)) {
 				rte_memcpy(filter->dst_ipaddr_mask,
-					   ipv6_mask->hdr.dst_addr, 16);
+					   &ipv6_mask->hdr.dst_addr, 16);
 				en |= !use_ntuple ? 0 :
 				     NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK;
 			}
drivers/net/bonding/rte_eth_bond_pmd.c +2 -4
index 34131f0e35f6..cda1c37124f4 100644
@@ -689,10 +689,8 @@ ipv4_hash(struct rte_ipv4_hdr *ipv4_hdr)
 static inline uint32_t
 ipv6_hash(struct rte_ipv6_hdr *ipv6_hdr)
 {
-	unaligned_uint32_t *word_src_addr =
-		(unaligned_uint32_t *)&(ipv6_hdr->src_addr[0]);
-	unaligned_uint32_t *word_dst_addr =
-		(unaligned_uint32_t *)&(ipv6_hdr->dst_addr[0]);
+	unaligned_uint32_t *word_src_addr = (unaligned_uint32_t *)&ipv6_hdr->src_addr;
+	unaligned_uint32_t *word_dst_addr = (unaligned_uint32_t *)&ipv6_hdr->dst_addr;
 
 	return (word_src_addr[0] ^ word_dst_addr[0]) ^
 			(word_src_addr[1] ^ word_dst_addr[1]) ^
drivers/net/cxgbe/cxgbe_flow.c +6 -10
index f5787c247f1f..9c7fa19bef00 100644
@@ -411,15 +411,15 @@ ch_rte_parsetype_ipv6(const void *dmask, const struct rte_flow_item *item,
 			      RTE_IPV6_HDR_TC_SHIFT,
 			      tos);
 
-	if (memcmp(val->hdr.dst_addr, z, sizeof(val->hdr.dst_addr)) ||
+	if (memcmp(&val->hdr.dst_addr, z, sizeof(val->hdr.dst_addr)) ||
 	    (umask &&
-	     memcmp(umask->hdr.dst_addr, z, sizeof(umask->hdr.dst_addr))))
+	     memcmp(&umask->hdr.dst_addr, z, sizeof(umask->hdr.dst_addr))))
 		CXGBE_FILL_FS_MEMCPY(val->hdr.dst_addr, mask->hdr.dst_addr,
 				     lip);
 
-	if (memcmp(val->hdr.src_addr, z, sizeof(val->hdr.src_addr)) ||
+	if (memcmp(&val->hdr.src_addr, z, sizeof(val->hdr.src_addr)) ||
 	    (umask &&
-	     memcmp(umask->hdr.src_addr, z, sizeof(umask->hdr.src_addr))))
+	     memcmp(&umask->hdr.src_addr, z, sizeof(umask->hdr.src_addr))))
 		CXGBE_FILL_FS_MEMCPY(val->hdr.src_addr, mask->hdr.src_addr,
 				     fip);
 
@@ -918,12 +918,8 @@ static struct chrte_fparse parseitem[] = {
 		.fptr  = ch_rte_parsetype_ipv6,
 		.dmask = &(const struct rte_flow_item_ipv6) {
 			.hdr = {
-				.src_addr =
-					"\xff\xff\xff\xff\xff\xff\xff\xff"
-					"\xff\xff\xff\xff\xff\xff\xff\xff",
-				.dst_addr =
-					"\xff\xff\xff\xff\xff\xff\xff\xff"
-					"\xff\xff\xff\xff\xff\xff\xff\xff",
+				.src_addr = RTE_IPV6_MASK_FULL,
+				.dst_addr = RTE_IPV6_MASK_FULL,
 				.vtc_flow = RTE_BE32(0xff000000),
 			},
 		},
drivers/net/dpaa2/dpaa2_flow.c +10 -14
index 62e350d7361b..b167a975990b 100644
@@ -117,12 +117,8 @@ static const struct rte_flow_item_ipv4 dpaa2_flow_item_ipv4_mask = {
 
 static const struct rte_flow_item_ipv6 dpaa2_flow_item_ipv6_mask = {
 	.hdr = {
-		.src_addr =
-			"\xff\xff\xff\xff\xff\xff\xff\xff"
-			"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
-			"\xff\xff\xff\xff\xff\xff\xff\xff"
-			"\xff\xff\xff\xff\xff\xff\xff\xff",
+		.src_addr = RTE_IPV6_MASK_FULL,
+		.dst_addr = RTE_IPV6_MASK_FULL,
 		.proto = 0xff
 	},
 };
@@ -1480,16 +1476,16 @@ dpaa2_configure_flow_generic_ip(
 		mask_ipv4->hdr.dst_addr)) {
 		flow->ipaddr_rule.ipaddr_type = FLOW_IPV4_ADDR;
 	} else if (mask_ipv6 &&
-		(memcmp((const char *)mask_ipv6->hdr.src_addr,
+		(memcmp(&mask_ipv6->hdr.src_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE) ||
-		memcmp((const char *)mask_ipv6->hdr.dst_addr,
+		memcmp(&mask_ipv6->hdr.dst_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		flow->ipaddr_rule.ipaddr_type = FLOW_IPV6_ADDR;
 	}
 
 	if ((mask_ipv4 && mask_ipv4->hdr.src_addr) ||
 		(mask_ipv6 &&
-			memcmp((const char *)mask_ipv6->hdr.src_addr,
+			memcmp(&mask_ipv6->hdr.src_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		index = dpaa2_flow_extract_search(
 				&priv->extract.qos_key_extract.dpkg,
@@ -1528,13 +1524,13 @@ dpaa2_configure_flow_generic_ip(
 		if (spec_ipv4)
 			key = &spec_ipv4->hdr.src_addr;
 		else
-			key = &spec_ipv6->hdr.src_addr[0];
+			key = &spec_ipv6->hdr.src_addr;
 		if (mask_ipv4) {
 			mask = &mask_ipv4->hdr.src_addr;
 			size = NH_FLD_IPV4_ADDR_SIZE;
 			prot = NET_PROT_IPV4;
 		} else {
-			mask = &mask_ipv6->hdr.src_addr[0];
+			mask = &mask_ipv6->hdr.src_addr;
 			size = NH_FLD_IPV6_ADDR_SIZE;
 			prot = NET_PROT_IPV6;
 		}
@@ -1571,7 +1567,7 @@ dpaa2_configure_flow_generic_ip(
 
 	if ((mask_ipv4 && mask_ipv4->hdr.dst_addr) ||
 		(mask_ipv6 &&
-			memcmp((const char *)mask_ipv6->hdr.dst_addr,
+			memcmp(&mask_ipv6->hdr.dst_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		index = dpaa2_flow_extract_search(
 				&priv->extract.qos_key_extract.dpkg,
@@ -1618,13 +1614,13 @@ dpaa2_configure_flow_generic_ip(
 		if (spec_ipv4)
 			key = &spec_ipv4->hdr.dst_addr;
 		else
-			key = spec_ipv6->hdr.dst_addr;
+			key = &spec_ipv6->hdr.dst_addr;
 		if (mask_ipv4) {
 			mask = &mask_ipv4->hdr.dst_addr;
 			size = NH_FLD_IPV4_ADDR_SIZE;
 			prot = NET_PROT_IPV4;
 		} else {
-			mask = &mask_ipv6->hdr.dst_addr[0];
+			mask = &mask_ipv6->hdr.dst_addr;
 			size = NH_FLD_IPV6_ADDR_SIZE;
 			prot = NET_PROT_IPV6;
 		}
drivers/net/hinic/hinic_pmd_flow.c +3 -3
index d1a564a16303..8fdd5a35be9f 100644
@@ -962,7 +962,7 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item,
 
 		/* check ipv6 src addr mask, ipv6 src addr is 16 bytes */
 		for (i = 0; i < 16; i++) {
-			if (ipv6_mask->hdr.src_addr[i] == UINT8_MAX) {
+			if (ipv6_mask->hdr.src_addr.a[i] == UINT8_MAX) {
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM, item,
 					"Not supported by fdir filter, do not support src ipv6");
@@ -978,13 +978,13 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item,
 		}
 
 		for (i = 0; i < 16; i++) {
-			if (ipv6_mask->hdr.dst_addr[i] == UINT8_MAX)
+			if (ipv6_mask->hdr.dst_addr.a[i] == UINT8_MAX)
 				rule->mask.dst_ipv6_mask |= 1 << i;
 		}
 
 		ipv6_spec = (const struct rte_flow_item_ipv6 *)item->spec;
 		rte_memcpy(rule->hinic_fdir.dst_ipv6,
-			   ipv6_spec->hdr.dst_addr, 16);
+			   &ipv6_spec->hdr.dst_addr, 16);
 
 		/*
 		 * Check if the next not void item is TCP or UDP or ICMP.
drivers/net/hinic/hinic_pmd_tx.c +1 -1
index f09b1a6e1ea6..22fb0bffafcc 100644
@@ -743,7 +743,7 @@ hinic_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 	else
 		psd_hdr.len = ipv6_hdr->payload_len;
 
-	sum = __rte_raw_cksum(ipv6_hdr->src_addr,
+	sum = __rte_raw_cksum(&ipv6_hdr->src_addr,
 		sizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr), 0);
 	sum = __rte_raw_cksum(&psd_hdr, sizeof(psd_hdr), sum);
 	return __rte_raw_cksum_reduce(sum);
drivers/net/hns3/hns3_flow.c +4 -4
index 37eb2b4c3807..bf1eee506dde 100644
@@ -822,10 +822,10 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 						  "Only support src & dst ip,proto in IPV6");
 		}
 		net_addr_to_host(rule->key_conf.mask.src_ip,
-				 (const rte_be32_t *)ipv6_mask->hdr.src_addr,
+				 (const rte_be32_t *)&ipv6_mask->hdr.src_addr,
 				 IP_ADDR_LEN);
 		net_addr_to_host(rule->key_conf.mask.dst_ip,
-				 (const rte_be32_t *)ipv6_mask->hdr.dst_addr,
+				 (const rte_be32_t *)&ipv6_mask->hdr.dst_addr,
 				 IP_ADDR_LEN);
 		rule->key_conf.mask.ip_proto = ipv6_mask->hdr.proto;
 		if (rule->key_conf.mask.src_ip[IP_ADDR_KEY_ID])
@@ -838,10 +838,10 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 
 	ipv6_spec = item->spec;
 	net_addr_to_host(rule->key_conf.spec.src_ip,
-			 (const rte_be32_t *)ipv6_spec->hdr.src_addr,
+			 (const rte_be32_t *)&ipv6_spec->hdr.src_addr,
 			 IP_ADDR_LEN);
 	net_addr_to_host(rule->key_conf.spec.dst_ip,
-			 (const rte_be32_t *)ipv6_spec->hdr.dst_addr,
+			 (const rte_be32_t *)&ipv6_spec->hdr.dst_addr,
 			 IP_ADDR_LEN);
 	rule->key_conf.spec.ip_proto = ipv6_spec->hdr.proto;
 
drivers/net/i40e/i40e_flow.c +6 -6
index 92165c8422d5..c6857727e8be 100644
@@ -1953,13 +1953,13 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 
-				if (!memcmp(ipv6_mask->hdr.src_addr,
+				if (!memcmp(&ipv6_mask->hdr.src_addr,
 					    ipv6_addr_mask,
-					    RTE_DIM(ipv6_mask->hdr.src_addr)))
+					    sizeof(ipv6_mask->hdr.src_addr)))
 					input_set |= I40E_INSET_IPV6_SRC;
-				if (!memcmp(ipv6_mask->hdr.dst_addr,
+				if (!memcmp(&ipv6_mask->hdr.dst_addr,
 					    ipv6_addr_mask,
-					    RTE_DIM(ipv6_mask->hdr.dst_addr)))
+					    sizeof(ipv6_mask->hdr.dst_addr)))
 					input_set |= I40E_INSET_IPV6_DST;
 
 				if ((ipv6_mask->hdr.vtc_flow &
@@ -1987,9 +1987,9 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 					I40E_FDIR_IPTYPE_IPV6;
 
 				rte_memcpy(filter->input.flow.ipv6_flow.src_ip,
-					   ipv6_spec->hdr.src_addr, 16);
+					   &ipv6_spec->hdr.src_addr, 16);
 				rte_memcpy(filter->input.flow.ipv6_flow.dst_ip,
-					   ipv6_spec->hdr.dst_addr, 16);
+					   &ipv6_spec->hdr.dst_addr, 16);
 
 				/* Check if it is fragment. */
 				if (ipv6_spec->hdr.proto ==
drivers/net/iavf/iavf_fdir.c +4 -4
index 811a10287b70..321346425465 100644
@@ -1048,14 +1048,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 								 HOP_LIMIT);
 			}
 
-			if (!memcmp(ipv6_mask->hdr.src_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.src_addr))) {
+			if (!memcmp(&ipv6_mask->hdr.src_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.src_addr))) {
 				input_set |= IAVF_INSET_IPV6_SRC;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6,
 								 SRC);
 			}
-			if (!memcmp(ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.dst_addr))) {
+			if (!memcmp(&ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.dst_addr))) {
 				input_set |= IAVF_INSET_IPV6_DST;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6,
 								 DST);
drivers/net/iavf/iavf_fsub.c +4 -4
index 74e1e7099b8c..eb5a3feab189 100644
@@ -354,23 +354,23 @@ iavf_fsub_parse_pattern(const struct rte_flow_item pattern[],
 				}
 
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						*input |= IAVF_INSET_IPV6_SRC;
 						break;
 					}
 				}
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						*input |= IAVF_INSET_IPV6_DST;
 						break;
 					}
 				}
 
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j])
+					if (ipv6_mask->hdr.src_addr.a[j])
 						input_set_byte++;
 
-					if (ipv6_mask->hdr.dst_addr[j])
+					if (ipv6_mask->hdr.dst_addr.a[j])
 						input_set_byte++;
 				}
 
drivers/net/iavf/iavf_ipsec_crypto.c +3 -3
index 6fd45ff45f3d..89dd5af5500f 100644
@@ -1738,8 +1738,8 @@ static void
 parse_ipv6_item(const struct rte_flow_item_ipv6 *item,
 		struct rte_ipv6_hdr *ipv6)
 {
-	memcpy(ipv6->src_addr, item->hdr.src_addr, 16);
-	memcpy(ipv6->dst_addr, item->hdr.dst_addr, 16);
+	ipv6->src_addr = item->hdr.src_addr;
+	ipv6->dst_addr = item->hdr.dst_addr;
 }
 
 static void
@@ -1904,7 +1904,7 @@ iavf_ipsec_flow_create(struct iavf_adapter *ad,
 			ipsec_flow->spi,
 			0,
 			0,
-			ipsec_flow->ipv6_hdr.dst_addr,
+			ipsec_flow->ipv6_hdr.dst_addr.a,
 			0,
 			ipsec_flow->is_udp,
 			ipsec_flow->udp_hdr.dst_port);
drivers/net/ice/ice_fdir_filter.c +6 -6
index 741107f93939..406918fed547 100644
@@ -2097,11 +2097,11 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
-			if (!memcmp(ipv6_mask->hdr.src_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.src_addr)))
+			if (!memcmp(&ipv6_mask->hdr.src_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.src_addr)))
 				*input_set |= ICE_INSET_IPV6_SRC;
-			if (!memcmp(ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.dst_addr)))
+			if (!memcmp(&ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.dst_addr)))
 				*input_set |= ICE_INSET_IPV6_DST;
 
 			if ((ipv6_mask->hdr.vtc_flow &
@@ -2113,8 +2113,8 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
 				*input_set |= ICE_INSET_IPV6_HOP_LIMIT;
 
-			rte_memcpy(&p_v6->dst_ip, ipv6_spec->hdr.dst_addr, 16);
-			rte_memcpy(&p_v6->src_ip, ipv6_spec->hdr.src_addr, 16);
+			rte_memcpy(&p_v6->dst_ip, &ipv6_spec->hdr.dst_addr, 16);
+			rte_memcpy(&p_v6->src_ip, &ipv6_spec->hdr.src_addr, 16);
 			vtc_flow_cpu = rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow);
 			p_v6->tc = (uint8_t)(vtc_flow_cpu >> ICE_FDIR_IPV6_TC_OFFSET);
 			p_v6->proto = ipv6_spec->hdr.proto;
drivers/net/ice/ice_switch_filter.c +8 -8
index 122b87f625a7..28bc775a2c34 100644
@@ -665,13 +665,13 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 				}
 
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						*input |= ICE_INSET_IPV6_SRC;
 						break;
 					}
 				}
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						*input |= ICE_INSET_IPV6_DST;
 						break;
 					}
@@ -691,18 +691,18 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 				f = &list[t].h_u.ipv6_hdr;
 				s = &list[t].m_u.ipv6_hdr;
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						f->src_addr[j] =
-						ipv6_spec->hdr.src_addr[j];
+						ipv6_spec->hdr.src_addr.a[j];
 						s->src_addr[j] =
-						ipv6_mask->hdr.src_addr[j];
+						ipv6_mask->hdr.src_addr.a[j];
 						input_set_byte++;
 					}
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						f->dst_addr[j] =
-						ipv6_spec->hdr.dst_addr[j];
+						ipv6_spec->hdr.dst_addr.a[j];
 						s->dst_addr[j] =
-						ipv6_mask->hdr.dst_addr[j];
+						ipv6_mask->hdr.dst_addr.a[j];
 						input_set_byte++;
 					}
 				}
drivers/net/igc/igc_flow.c +2 -2
index b677a0d61340..b778ac26135a 100644
@@ -435,8 +435,8 @@ igc_parse_pattern_ipv6(const struct rte_flow_item *item,
 	if (mask->hdr.vtc_flow ||
 		mask->hdr.payload_len ||
 		mask->hdr.hop_limits ||
-		!igc_is_zero_ipv6_addr(mask->hdr.src_addr) ||
-		!igc_is_zero_ipv6_addr(mask->hdr.dst_addr))
+		!igc_is_zero_ipv6_addr(&mask->hdr.src_addr) ||
+		!igc_is_zero_ipv6_addr(&mask->hdr.dst_addr))
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ITEM, item,
 				"IPv6 only support protocol");
drivers/net/ixgbe/ixgbe_flow.c +6 -6
index 687341c6b8d3..1b35ed5faabe 100644
@@ -1917,9 +1917,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 
 		/* check src addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.src_addr[j] == 0) {
+			if (ipv6_mask->hdr.src_addr.a[j] == 0) {
 				rule->mask.src_ipv6_mask &= ~(1 << j);
-			} else if (ipv6_mask->hdr.src_addr[j] != UINT8_MAX) {
+			} else if (ipv6_mask->hdr.src_addr.a[j] != UINT8_MAX) {
 				memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1930,9 +1930,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 
 		/* check dst addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.dst_addr[j] == 0) {
+			if (ipv6_mask->hdr.dst_addr.a[j] == 0) {
 				rule->mask.dst_ipv6_mask &= ~(1 << j);
-			} else if (ipv6_mask->hdr.dst_addr[j] != UINT8_MAX) {
+			} else if (ipv6_mask->hdr.dst_addr.a[j] != UINT8_MAX) {
 				memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1945,9 +1945,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 			rule->b_spec = TRUE;
 			ipv6_spec = item->spec;
 			rte_memcpy(rule->ixgbe_fdir.formatted.src_ip,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(rule->ixgbe_fdir.formatted.dst_ip,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 		}
 
 		/**
drivers/net/ixgbe/ixgbe_ipsec.c +2 -2
index 3a666ba15f59..778004cbe4d2 100644
@@ -681,9 +681,9 @@ ixgbe_crypto_add_ingress_sa_from_flow(const void *sess,
 			ic_session->src_ip.type = IPv6;
 			ic_session->dst_ip.type = IPv6;
 			rte_memcpy(ic_session->src_ip.ipv6,
-				   ipv6->hdr.src_addr, 16);
+				   &ipv6->hdr.src_addr, 16);
 			rte_memcpy(ic_session->dst_ip.ipv6,
-				   ipv6->hdr.dst_addr, 16);
+				   &ipv6->hdr.dst_addr, 16);
 		} else {
 			const struct rte_flow_item_ipv4 *ipv4 = ip_spec;
 			ic_session->src_ip.type = IPv4;
drivers/net/mlx5/hws/mlx5dr_definer.c +18 -18
index 51a3f7be4b75..7326d2cf42a5 100644
@@ -176,14 +176,14 @@ struct mlx5dr_definer_conv_data {
 	X(SET,		ipv6_proto,		v->hdr.proto,		rte_flow_item_ipv6) \
 	X(SET,		ipv6_routing_hdr,	IPPROTO_ROUTING,	rte_flow_item_ipv6) \
 	X(SET,		ipv6_hop_limits,	v->hdr.hop_limits,	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_127_96,	&v->hdr.src_addr[0],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_95_64,	&v->hdr.src_addr[4],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_63_32,	&v->hdr.src_addr[8],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_31_0,	&v->hdr.src_addr[12],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_127_96,	&v->hdr.dst_addr[0],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_95_64,	&v->hdr.dst_addr[4],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_63_32,	&v->hdr.dst_addr[8],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_31_0,	&v->hdr.dst_addr[12],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_127_96,	&v->hdr.src_addr.a[0],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_95_64,	&v->hdr.src_addr.a[4],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_63_32,	&v->hdr.src_addr.a[8],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_31_0,	&v->hdr.src_addr.a[12],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_127_96,	&v->hdr.dst_addr.a[0],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_95_64,	&v->hdr.dst_addr.a[4],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_63_32,	&v->hdr.dst_addr.a[8],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_31_0,	&v->hdr.dst_addr.a[12],	rte_flow_item_ipv6) \
 	X(SET,		ipv6_version,		STE_IPV6,		rte_flow_item_ipv6) \
 	X(SET,		ipv6_frag,		v->has_frag_ext,	rte_flow_item_ipv6) \
 	X(SET,		icmp_protocol,		STE_ICMP,		rte_flow_item_icmp) \
@@ -1161,8 +1161,8 @@ mlx5dr_definer_conv_item_ipv6(struct mlx5dr_definer_conv_data *cd,
 	    m->has_esp_ext || m->has_dest_ext || m->has_mobil_ext ||
 	    m->has_hip_ext || m->has_shim6_ext ||
 	    (l && (l->has_frag_ext || l->hdr.vtc_flow || l->hdr.proto ||
-		   !is_mem_zero(l->hdr.src_addr, 16) ||
-		   !is_mem_zero(l->hdr.dst_addr, 16)))) {
+		   !is_mem_zero(l->hdr.src_addr.a, 16) ||
+		   !is_mem_zero(l->hdr.dst_addr.a, 16)))) {
 		rte_errno = ENOTSUP;
 		return rte_errno;
 	}
@@ -1219,56 +1219,56 @@ mlx5dr_definer_conv_item_ipv6(struct mlx5dr_definer_conv_data *cd,
 		DR_CALC_SET(fc, eth_l3, time_to_live_hop_limit, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_127_96, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_127_96_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_127_96, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 4, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 4, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_95_64, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_95_64_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_95_64, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 8, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 8, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_63_32, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_63_32_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_63_32, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 12, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 12, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_31_0, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_31_0_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_31_0, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_127_96, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_127_96_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_127_96, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 4, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 4, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_95_64, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_95_64_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_95_64, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 8, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 8, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_63_32, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_63_32_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_63_32, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 12, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 12, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_31_0, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_31_0_set;
drivers/net/mlx5/mlx5_flow.c +2 -6
index 72fb3a55baf4..e41b96dfb7cb 100644
@@ -2933,12 +2933,8 @@ mlx5_flow_validate_item_ipv6(const struct rte_eth_dev *dev,
 	const struct rte_flow_item_ipv6 *spec = item->spec;
 	const struct rte_flow_item_ipv6 nic_mask = {
 		.hdr = {
-			.src_addr =
-				"\xff\xff\xff\xff\xff\xff\xff\xff"
-				"\xff\xff\xff\xff\xff\xff\xff\xff",
-			.dst_addr =
-				"\xff\xff\xff\xff\xff\xff\xff\xff"
-				"\xff\xff\xff\xff\xff\xff\xff\xff",
+			.src_addr = RTE_IPV6_MASK_FULL,
+			.dst_addr = RTE_IPV6_MASK_FULL,
 			.vtc_flow = RTE_BE32(0xffffffff),
 			.proto = 0xff,
 		},
drivers/net/mlx5/mlx5_flow_dv.c +6 -14
index 89057edbcfc2..424103721fb0 100644
@@ -7697,12 +7697,8 @@ const struct rte_flow_item_ipv4 nic_ipv4_mask = {
 
 const struct rte_flow_item_ipv6 nic_ipv6_mask = {
 	.hdr = {
-		.src_addr =
-		"\xff\xff\xff\xff\xff\xff\xff\xff"
-		"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
-		"\xff\xff\xff\xff\xff\xff\xff\xff"
-		"\xff\xff\xff\xff\xff\xff\xff\xff",
+		.src_addr = RTE_IPV6_MASK_FULL,
+		.dst_addr = RTE_IPV6_MASK_FULL,
 		.vtc_flow = RTE_BE32(0xffffffff),
 		.proto = 0xff,
 		.hop_limits = 0xff,
@@ -9549,12 +9545,8 @@ flow_dv_translate_item_ipv6(void *key, const struct rte_flow_item *item,
 	const struct rte_flow_item_ipv6 *ipv6_v;
 	const struct rte_flow_item_ipv6 nic_mask = {
 		.hdr = {
-			.src_addr =
-				"\xff\xff\xff\xff\xff\xff\xff\xff"
-				"\xff\xff\xff\xff\xff\xff\xff\xff",
-			.dst_addr =
-				"\xff\xff\xff\xff\xff\xff\xff\xff"
-				"\xff\xff\xff\xff\xff\xff\xff\xff",
+			.src_addr = RTE_IPV6_MASK_FULL,
+			.dst_addr = RTE_IPV6_MASK_FULL,
 			.vtc_flow = RTE_BE32(0xffffffff),
 			.proto = 0xff,
 			.hop_limits = 0xff,
@@ -9577,11 +9569,11 @@ flow_dv_translate_item_ipv6(void *key, const struct rte_flow_item *item,
 	l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
 			     dst_ipv4_dst_ipv6.ipv6_layout.ipv6);
 	for (i = 0; i < size; ++i)
-		l24_v[i] = ipv6_m->hdr.dst_addr[i] & ipv6_v->hdr.dst_addr[i];
+		l24_v[i] = ipv6_m->hdr.dst_addr.a[i] & ipv6_v->hdr.dst_addr.a[i];
 	l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
 			     src_ipv4_src_ipv6.ipv6_layout.ipv6);
 	for (i = 0; i < size; ++i)
-		l24_v[i] = ipv6_m->hdr.src_addr[i] & ipv6_v->hdr.src_addr[i];
+		l24_v[i] = ipv6_m->hdr.src_addr.a[i] & ipv6_v->hdr.src_addr.a[i];
 	/* TOS. */
 	vtc_v = rte_be_to_cpu_32(ipv6_m->hdr.vtc_flow & ipv6_v->hdr.vtc_flow);
 	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn, vtc_v >> 20);
drivers/net/mlx5/mlx5_flow_hw.c +4 -8
index d243b59b71cd..c88f19d55445 100644
@@ -8250,12 +8250,8 @@ const struct rte_flow_item_ipv6 hws_nic_ipv6_mask = {
 		.payload_len = RTE_BE16(0xffff),
 		.proto = 0xff,
 		.hop_limits = 0xff,
-		.src_addr =
-		"\xff\xff\xff\xff\xff\xff\xff\xff"
-		"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
-		"\xff\xff\xff\xff\xff\xff\xff\xff"
-		"\xff\xff\xff\xff\xff\xff\xff\xff",
+		.src_addr = RTE_IPV6_MASK_FULL,
+		.dst_addr = RTE_IPV6_MASK_FULL,
 	},
 	.has_frag_ext = 1,
 };
@@ -14645,10 +14641,10 @@ flow_hw_calc_encap_hash(struct rte_eth_dev *dev,
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			memcpy(data.dst.ipv6_addr,
-			       ((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.dst_addr,
+			       &((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.dst_addr,
 			       sizeof(data.dst.ipv6_addr));
 			memcpy(data.src.ipv6_addr,
-			       ((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.src_addr,
+			       &((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.src_addr,
 			       sizeof(data.src.ipv6_addr));
 			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
drivers/net/mlx5/mlx5_flow_verbs.c +4 -4
index 3a4356c0f650..5b4a4eda3bbc 100644
@@ -600,13 +600,13 @@ flow_verbs_translate_item_ipv6(struct mlx5_flow *dev_flow,
 		uint32_t vtc_flow_val;
 		uint32_t vtc_flow_mask;
 
-		memcpy(&ipv6.val.src_ip, spec->hdr.src_addr,
+		memcpy(&ipv6.val.src_ip, &spec->hdr.src_addr,
 		       RTE_DIM(ipv6.val.src_ip));
-		memcpy(&ipv6.val.dst_ip, spec->hdr.dst_addr,
+		memcpy(&ipv6.val.dst_ip, &spec->hdr.dst_addr,
 		       RTE_DIM(ipv6.val.dst_ip));
-		memcpy(&ipv6.mask.src_ip, mask->hdr.src_addr,
+		memcpy(&ipv6.mask.src_ip, &mask->hdr.src_addr,
 		       RTE_DIM(ipv6.mask.src_ip));
-		memcpy(&ipv6.mask.dst_ip, mask->hdr.dst_addr,
+		memcpy(&ipv6.mask.dst_ip, &mask->hdr.dst_addr,
 		       RTE_DIM(ipv6.mask.dst_ip));
 		vtc_flow_val = rte_be_to_cpu_32(spec->hdr.vtc_flow);
 		vtc_flow_mask = rte_be_to_cpu_32(mask->hdr.vtc_flow);
drivers/net/mvpp2/mrvl_flow.c +6 -10
index e74a5f83f55b..098523ada653 100644
@@ -536,27 +536,23 @@ mrvl_parse_ip6_addr(const struct rte_flow_item_ipv6 *spec,
 	       int parse_dst, struct rte_flow *flow)
 {
 	struct pp2_cls_rule_key_field *key_field;
-	int size = sizeof(spec->hdr.dst_addr);
-	struct in6_addr k, m;
+	struct rte_ipv6_addr k, m;
 
-	memset(&k, 0, sizeof(k));
 	if (parse_dst) {
-		memcpy(k.s6_addr, spec->hdr.dst_addr, size);
-		memcpy(m.s6_addr, mask->hdr.dst_addr, size);
-
+		k = spec->hdr.dst_addr;
+		m = mask->hdr.dst_addr;
 		flow->table_key.proto_field[flow->rule.num_fields].field.ipv6 =
 			MV_NET_IP6_F_DA;
 	} else {
-		memcpy(k.s6_addr, spec->hdr.src_addr, size);
-		memcpy(m.s6_addr, mask->hdr.src_addr, size);
-
+		k = spec->hdr.src_addr;
+		m = mask->hdr.src_addr;
 		flow->table_key.proto_field[flow->rule.num_fields].field.ipv6 =
 			MV_NET_IP6_F_SA;
 	}
 
 	key_field = &flow->rule.fields[flow->rule.num_fields];
 	mrvl_alloc_key_mask(key_field);
-	key_field->size = 16;
+	key_field->size = RTE_IPV6_ADDR_SIZE;
 
 	inet_ntop(AF_INET6, &k, (char *)key_field->key, MRVL_CLS_STR_SIZE_MAX);
 	inet_ntop(AF_INET6, &m, (char *)key_field->mask, MRVL_CLS_STR_SIZE_MAX);
drivers/net/nfp/flower/nfp_flower_flow.c +15 -17
index 0078455658ac..56352893d832 100644
@@ -2027,18 +2027,18 @@ nfp_flow_merge_ipv6(struct nfp_flow_merge_param *param)
 
 			ipv6_gre_tun->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 			ipv6_gre_tun->ip_ext.ttl = hdr->hop_limits;
-			memcpy(ipv6_gre_tun->ipv6.ipv6_src, hdr->src_addr,
+			memcpy(ipv6_gre_tun->ipv6.ipv6_src, &hdr->src_addr,
 					sizeof(ipv6_gre_tun->ipv6.ipv6_src));
-			memcpy(ipv6_gre_tun->ipv6.ipv6_dst, hdr->dst_addr,
+			memcpy(ipv6_gre_tun->ipv6.ipv6_dst, &hdr->dst_addr,
 					sizeof(ipv6_gre_tun->ipv6.ipv6_dst));
 		} else {
 			ipv6_udp_tun = (struct nfp_flower_ipv6_udp_tun *)(*param->mbuf_off);
 
 			ipv6_udp_tun->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 			ipv6_udp_tun->ip_ext.ttl = hdr->hop_limits;
-			memcpy(ipv6_udp_tun->ipv6.ipv6_src, hdr->src_addr,
+			memcpy(ipv6_udp_tun->ipv6.ipv6_src, &hdr->src_addr,
 					sizeof(ipv6_udp_tun->ipv6.ipv6_src));
-			memcpy(ipv6_udp_tun->ipv6.ipv6_dst, hdr->dst_addr,
+			memcpy(ipv6_udp_tun->ipv6.ipv6_dst, &hdr->dst_addr,
 					sizeof(ipv6_udp_tun->ipv6.ipv6_dst));
 		}
 	} else {
@@ -2061,8 +2061,8 @@ nfp_flow_merge_ipv6(struct nfp_flow_merge_param *param)
 		ipv6->ip_ext.tos   = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 		ipv6->ip_ext.proto = hdr->proto;
 		ipv6->ip_ext.ttl   = hdr->hop_limits;
-		memcpy(ipv6->ipv6_src, hdr->src_addr, sizeof(ipv6->ipv6_src));
-		memcpy(ipv6->ipv6_dst, hdr->dst_addr, sizeof(ipv6->ipv6_dst));
+		memcpy(ipv6->ipv6_src, &hdr->src_addr, sizeof(ipv6->ipv6_src));
+		memcpy(ipv6->ipv6_dst, &hdr->dst_addr, sizeof(ipv6->ipv6_dst));
 
 ipv6_end:
 		*param->mbuf_off += sizeof(struct nfp_flower_ipv6);
@@ -2518,10 +2518,8 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
 				.vtc_flow   = RTE_BE32(0x0ff00000),
 				.proto      = 0xff,
 				.hop_limits = 0xff,
-				.src_addr   = "\xff\xff\xff\xff\xff\xff\xff\xff"
-					"\xff\xff\xff\xff\xff\xff\xff\xff",
-				.dst_addr   = "\xff\xff\xff\xff\xff\xff\xff\xff"
-					"\xff\xff\xff\xff\xff\xff\xff\xff",
+				.src_addr   = RTE_IPV6_MASK_FULL,
+				.dst_addr   = RTE_IPV6_MASK_FULL,
 			},
 			.has_frag_ext = 1,
 		},
@@ -3324,8 +3322,8 @@ nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower,
 	struct nfp_flower_cmsg_tun_neigh_v6 payload;
 
 	tun->payload.v6_flag = 1;
-	memcpy(tun->payload.dst.dst_ipv6, ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6));
-	memcpy(tun->payload.src.src_ipv6, ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6));
+	memcpy(tun->payload.dst.dst_ipv6, &ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6));
+	memcpy(tun->payload.src.src_ipv6, &ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6));
 	memcpy(tun->payload.dst_addr, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	memcpy(tun->payload.src_addr, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 
@@ -3345,8 +3343,8 @@ nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower,
 			sizeof(struct nfp_flower_meta_tci));
 
 	memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6));
-	memcpy(payload.dst_ipv6, ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6));
-	memcpy(payload.src_ipv6, ipv6->hdr.src_addr, sizeof(payload.src_ipv6));
+	memcpy(payload.dst_ipv6, &ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6));
+	memcpy(payload.src_ipv6, &ipv6->hdr.src_addr, sizeof(payload.src_ipv6));
 	memcpy(payload.common.dst_mac, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	memcpy(payload.common.src_mac, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	payload.common.port_id = port->in_port;
@@ -3573,7 +3571,7 @@ nfp_flow_action_vxlan_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
@@ -3944,7 +3942,7 @@ nfp_flow_action_geneve_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
@@ -4021,7 +4019,7 @@ nfp_flow_action_nvgre_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
drivers/net/nfp/nfp_net_flow.c +18 -20
index 2c7801ed41f4..4d370e3097b2 100644
@@ -294,28 +294,28 @@ nfp_net_flow_merge_ipv6(struct rte_flow *nfp_flow,
 
 	ipv6->l4_protocol_mask = mask->hdr.proto;
 	for (i = 0; i < sizeof(ipv6->src_ipv6); i += 4) {
-		ipv6->src_ipv6_mask[i] = mask->hdr.src_addr[i + 3];
-		ipv6->src_ipv6_mask[i + 1] = mask->hdr.src_addr[i + 2];
-		ipv6->src_ipv6_mask[i + 2] = mask->hdr.src_addr[i + 1];
-		ipv6->src_ipv6_mask[i + 3] = mask->hdr.src_addr[i];
+		ipv6->src_ipv6_mask[i] = mask->hdr.src_addr.a[i + 3];
+		ipv6->src_ipv6_mask[i + 1] = mask->hdr.src_addr.a[i + 2];
+		ipv6->src_ipv6_mask[i + 2] = mask->hdr.src_addr.a[i + 1];
+		ipv6->src_ipv6_mask[i + 3] = mask->hdr.src_addr.a[i];
 
-		ipv6->dst_ipv6_mask[i] = mask->hdr.dst_addr[i + 3];
-		ipv6->dst_ipv6_mask[i + 1] = mask->hdr.dst_addr[i + 2];
-		ipv6->dst_ipv6_mask[i + 2] = mask->hdr.dst_addr[i + 1];
-		ipv6->dst_ipv6_mask[i + 3] = mask->hdr.dst_addr[i];
+		ipv6->dst_ipv6_mask[i] = mask->hdr.dst_addr.a[i + 3];
+		ipv6->dst_ipv6_mask[i + 1] = mask->hdr.dst_addr.a[i + 2];
+		ipv6->dst_ipv6_mask[i + 2] = mask->hdr.dst_addr.a[i + 1];
+		ipv6->dst_ipv6_mask[i + 3] = mask->hdr.dst_addr.a[i];
 	}
 
 	ipv6->l4_protocol = spec->hdr.proto;
 	for (i = 0; i < sizeof(ipv6->src_ipv6); i += 4) {
-		ipv6->src_ipv6[i] = spec->hdr.src_addr[i + 3];
-		ipv6->src_ipv6[i + 1] = spec->hdr.src_addr[i + 2];
-		ipv6->src_ipv6[i + 2] = spec->hdr.src_addr[i + 1];
-		ipv6->src_ipv6[i + 3] = spec->hdr.src_addr[i];
+		ipv6->src_ipv6[i] = spec->hdr.src_addr.a[i + 3];
+		ipv6->src_ipv6[i + 1] = spec->hdr.src_addr.a[i + 2];
+		ipv6->src_ipv6[i + 2] = spec->hdr.src_addr.a[i + 1];
+		ipv6->src_ipv6[i + 3] = spec->hdr.src_addr.a[i];
 
-		ipv6->dst_ipv6[i] = spec->hdr.dst_addr[i + 3];
-		ipv6->dst_ipv6[i + 1] = spec->hdr.dst_addr[i + 2];
-		ipv6->dst_ipv6[i + 2] = spec->hdr.dst_addr[i + 1];
-		ipv6->dst_ipv6[i + 3] = spec->hdr.dst_addr[i];
+		ipv6->dst_ipv6[i] = spec->hdr.dst_addr.a[i + 3];
+		ipv6->dst_ipv6[i + 1] = spec->hdr.dst_addr.a[i + 2];
+		ipv6->dst_ipv6[i + 2] = spec->hdr.dst_addr.a[i + 1];
+		ipv6->dst_ipv6[i + 3] = spec->hdr.dst_addr.a[i];
 	}
 
 	return 0;
@@ -403,10 +403,8 @@ static const struct nfp_net_flow_item_proc nfp_net_flow_item_proc_list[] = {
 		.mask_support = &(const struct rte_flow_item_ipv6){
 			.hdr = {
 				.proto    = 0xff,
-				.src_addr = "\xff\xff\xff\xff\xff\xff\xff\xff"
-						"\xff\xff\xff\xff\xff\xff\xff\xff",
-				.dst_addr = "\xff\xff\xff\xff\xff\xff\xff\xff"
-						"\xff\xff\xff\xff\xff\xff\xff\xff",
+				.src_addr = RTE_IPV6_MASK_FULL,
+				.dst_addr = RTE_IPV6_MASK_FULL,
 			},
 		},
 		.mask_default = &rte_flow_item_ipv6_mask,
drivers/net/qede/qede_filter.c +2 -2
index d98266eac55c..14fb4338e9c7 100644
@@ -794,9 +794,9 @@ qede_flow_parse_pattern(__rte_unused struct rte_eth_dev *dev,
 
 				spec = pattern->spec;
 				memcpy(flow->entry.tuple.src_ipv6,
-				       spec->hdr.src_addr, IPV6_ADDR_LEN);
+				       &spec->hdr.src_addr, IPV6_ADDR_LEN);
 				memcpy(flow->entry.tuple.dst_ipv6,
-				       spec->hdr.dst_addr, IPV6_ADDR_LEN);
+				       &spec->hdr.dst_addr, IPV6_ADDR_LEN);
 				flow->entry.tuple.eth_proto =
 					RTE_ETHER_TYPE_IPV6;
 			}
drivers/net/sfc/sfc_flow.c +8 -14
index 1b50aefe5c48..1006243539b5 100644
@@ -575,14 +575,8 @@ sfc_flow_parse_ipv6(const struct rte_flow_item *item,
 	const uint16_t ether_type_ipv6 = rte_cpu_to_le_16(EFX_ETHER_TYPE_IPV6);
 	const struct rte_flow_item_ipv6 supp_mask = {
 		.hdr = {
-			.src_addr = { 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff },
-			.dst_addr = { 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff },
+			.src_addr = RTE_IPV6_MASK_FULL,
+			.dst_addr = RTE_IPV6_MASK_FULL,
 			.proto = 0xff,
 		}
 	};
@@ -618,28 +612,28 @@ sfc_flow_parse_ipv6(const struct rte_flow_item *item,
 	 * IPv6 addresses are in big-endian byte order in item and in
 	 * efx_spec
 	 */
-	if (memcmp(mask->hdr.src_addr, supp_mask.hdr.src_addr,
+	if (memcmp(&mask->hdr.src_addr, &supp_mask.hdr.src_addr,
 		   sizeof(mask->hdr.src_addr)) == 0) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_HOST;
 
 		RTE_BUILD_BUG_ON(sizeof(efx_spec->efs_rem_host) !=
 				 sizeof(spec->hdr.src_addr));
-		rte_memcpy(&efx_spec->efs_rem_host, spec->hdr.src_addr,
+		rte_memcpy(&efx_spec->efs_rem_host, &spec->hdr.src_addr,
 			   sizeof(efx_spec->efs_rem_host));
-	} else if (!sfc_flow_is_zero(mask->hdr.src_addr,
+	} else if (!sfc_flow_is_zero(mask->hdr.src_addr.a,
 				     sizeof(mask->hdr.src_addr))) {
 		goto fail_bad_mask;
 	}
 
-	if (memcmp(mask->hdr.dst_addr, supp_mask.hdr.dst_addr,
+	if (memcmp(&mask->hdr.dst_addr, &supp_mask.hdr.dst_addr,
 		   sizeof(mask->hdr.dst_addr)) == 0) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_HOST;
 
 		RTE_BUILD_BUG_ON(sizeof(efx_spec->efs_loc_host) !=
 				 sizeof(spec->hdr.dst_addr));
-		rte_memcpy(&efx_spec->efs_loc_host, spec->hdr.dst_addr,
+		rte_memcpy(&efx_spec->efs_loc_host, &spec->hdr.dst_addr,
 			   sizeof(efx_spec->efs_loc_host));
-	} else if (!sfc_flow_is_zero(mask->hdr.dst_addr,
+	} else if (!sfc_flow_is_zero(mask->hdr.dst_addr.a,
 				     sizeof(mask->hdr.dst_addr))) {
 		goto fail_bad_mask;
 	}
drivers/net/tap/tap_flow.c +4 -10
index 0a90c0487b46..e89f0da0d0d7 100644
@@ -209,14 +209,8 @@ static const struct tap_flow_items tap_flow_items[] = {
 			       RTE_FLOW_ITEM_TYPE_TCP),
 		.mask = &(const struct rte_flow_item_ipv6){
 			.hdr = {
-				.src_addr = {
-					"\xff\xff\xff\xff\xff\xff\xff\xff"
-					"\xff\xff\xff\xff\xff\xff\xff\xff",
-				},
-				.dst_addr = {
-					"\xff\xff\xff\xff\xff\xff\xff\xff"
-					"\xff\xff\xff\xff\xff\xff\xff\xff",
-				},
+				.src_addr = RTE_IPV6_MASK_FULL,
+				.dst_addr = RTE_IPV6_MASK_FULL,
 				.proto = -1,
 			},
 		},
@@ -617,13 +611,13 @@ tap_flow_create_ipv6(const struct rte_flow_item *item, void *data)
 		info->eth_type = htons(ETH_P_IPV6);
 	if (!spec)
 		return 0;
-	if (memcmp(mask->hdr.dst_addr, empty_addr, 16)) {
+	if (memcmp(&mask->hdr.dst_addr, empty_addr, 16)) {
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST,
 			   sizeof(spec->hdr.dst_addr), &spec->hdr.dst_addr);
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST_MASK,
 			   sizeof(mask->hdr.dst_addr), &mask->hdr.dst_addr);
 	}
-	if (memcmp(mask->hdr.src_addr, empty_addr, 16)) {
+	if (memcmp(&mask->hdr.src_addr, empty_addr, 16)) {
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC,
 			   sizeof(spec->hdr.src_addr), &spec->hdr.src_addr);
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC_MASK,
drivers/net/txgbe/txgbe_flow.c +6 -6
index 7ef52d0b0fcd..5d2dd453687c 100644
@@ -1807,9 +1807,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 
 		/* check src addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.src_addr[j] == UINT8_MAX) {
+			if (ipv6_mask->hdr.src_addr.a[j] == UINT8_MAX) {
 				rule->mask.src_ipv6_mask |= 1 << j;
-			} else if (ipv6_mask->hdr.src_addr[j] != 0) {
+			} else if (ipv6_mask->hdr.src_addr.a[j] != 0) {
 				memset(rule, 0, sizeof(struct txgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1820,9 +1820,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 
 		/* check dst addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.dst_addr[j] == UINT8_MAX) {
+			if (ipv6_mask->hdr.dst_addr.a[j] == UINT8_MAX) {
 				rule->mask.dst_ipv6_mask |= 1 << j;
-			} else if (ipv6_mask->hdr.dst_addr[j] != 0) {
+			} else if (ipv6_mask->hdr.dst_addr.a[j] != 0) {
 				memset(rule, 0, sizeof(struct txgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1835,9 +1835,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 			rule->b_spec = TRUE;
 			ipv6_spec = item->spec;
 			rte_memcpy(rule->input.src_ip,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(rule->input.dst_ip,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 		}
 
 		/**
drivers/net/txgbe/txgbe_ipsec.c +2 -2
index 4af49dd802d0..65b6c251c684 100644
@@ -659,9 +659,9 @@ txgbe_crypto_add_ingress_sa_from_flow(const void *sess,
 			ic_session->src_ip.type = IPv6;
 			ic_session->dst_ip.type = IPv6;
 			rte_memcpy(ic_session->src_ip.ipv6,
-				   ipv6->hdr.src_addr, 16);
+				   &ipv6->hdr.src_addr, 16);
 			rte_memcpy(ic_session->dst_ip.ipv6,
-				   ipv6->hdr.dst_addr, 16);
+				   &ipv6->hdr.dst_addr, 16);
 		} else {
 			const struct rte_flow_item_ipv4 *ipv4 = ip_spec;
 			ic_session->src_ip.type = IPv4;
examples/ip_fragmentation/main.c +1 -1
index 736eae6f05ee..4c0fa5054a2e 100644
@@ -311,7 +311,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,
 		ip_hdr = rte_pktmbuf_mtod(m, struct rte_ipv6_hdr *);
 
 		/* Find destination port */
-		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr,
+		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr.a,
 						&next_hop) == 0 &&
 				(enabled_port_mask & 1 << next_hop) != 0) {
 			port_out = next_hop;
examples/ip_pipeline/pipeline.c +8 -8
index 301c52d061be..d08f8c24c80f 100644
@@ -638,7 +638,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 1,
 		.input_index = 1,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[0]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[0]),
 	},
 
 	[2] = {
@@ -646,7 +646,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 2,
 		.input_index = 2,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[4]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[4]),
 	},
 
 	[3] = {
@@ -654,7 +654,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 3,
 		.input_index = 3,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[8]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[8]),
 	},
 
 	[4] = {
@@ -662,7 +662,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 4,
 		.input_index = 4,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[12]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[12]),
 	},
 
 	/* Destination IP address (IPv6) */
@@ -671,7 +671,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 5,
 		.input_index = 5,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[0]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[0]),
 	},
 
 	[6] = {
@@ -679,7 +679,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 6,
 		.input_index = 6,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[4]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[4]),
 	},
 
 	[7] = {
@@ -687,7 +687,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 7,
 		.input_index = 7,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[8]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[8]),
 	},
 
 	[8] = {
@@ -695,7 +695,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 8,
 		.input_index = 8,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[12]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[12]),
 	},
 
 	/* Source Port */
examples/ip_reassembly/main.c +1 -1
index c7019078f7b4..4da692eb23e6 100644
@@ -400,7 +400,7 @@ reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queue,
 		}
 
 		/* Find destination port */
-		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr,
+		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr.a,
 						&next_hop) == 0 &&
 				(enabled_port_mask & 1 << next_hop) != 0) {
 			dst_port = next_hop;
examples/ipsec-secgw/flow.c +6 -27
index 05a62c3020fa..3f7630f5fd53 100644
@@ -83,29 +83,8 @@ ipv4_addr_cpy(rte_be32_t *spec, rte_be32_t *mask, char *token,
 static void
 ipv6_hdr_print(struct rte_ipv6_hdr *hdr)
 {
-	uint8_t *addr;
-
-	addr = hdr->src_addr;
-	printf("src: %4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx \t",
-	       (uint16_t)((addr[0] << 8) | addr[1]),
-	       (uint16_t)((addr[2] << 8) | addr[3]),
-	       (uint16_t)((addr[4] << 8) | addr[5]),
-	       (uint16_t)((addr[6] << 8) | addr[7]),
-	       (uint16_t)((addr[8] << 8) | addr[9]),
-	       (uint16_t)((addr[10] << 8) | addr[11]),
-	       (uint16_t)((addr[12] << 8) | addr[13]),
-	       (uint16_t)((addr[14] << 8) | addr[15]));
-
-	addr = hdr->dst_addr;
-	printf("dst: %4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx",
-	       (uint16_t)((addr[0] << 8) | addr[1]),
-	       (uint16_t)((addr[2] << 8) | addr[3]),
-	       (uint16_t)((addr[4] << 8) | addr[5]),
-	       (uint16_t)((addr[6] << 8) | addr[7]),
-	       (uint16_t)((addr[8] << 8) | addr[9]),
-	       (uint16_t)((addr[10] << 8) | addr[11]),
-	       (uint16_t)((addr[12] << 8) | addr[13]),
-	       (uint16_t)((addr[14] << 8) | addr[15]));
+	printf("src: " RTE_IPV6_ADDR_FMT " \t", RTE_IPV6_ADDR_SPLIT(&hdr->src_addr));
+	printf("dst: " RTE_IPV6_ADDR_FMT, RTE_IPV6_ADDR_SPLIT(&hdr->dst_addr));
 }
 
 static int
@@ -196,8 +175,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.src_addr,
-						  rule->ipv6.mask.hdr.src_addr,
+				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.src_addr.a,
+						  rule->ipv6.mask.hdr.src_addr.a,
 						  tokens[ti], status))
 					return;
 			}
@@ -205,8 +184,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.dst_addr,
-						  rule->ipv6.mask.hdr.dst_addr,
+				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.dst_addr.a,
+						  rule->ipv6.mask.hdr.dst_addr.a,
 						  tokens[ti], status))
 					return;
 			}
examples/ipsec-secgw/ipsec.c +4 -4
index b52b0ffc3d22..ebde28639c12 100644
@@ -529,9 +529,9 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 			sa->pattern[1].spec = &sa->ipv6_spec;
 
-			memcpy(sa->ipv6_spec.hdr.dst_addr,
+			memcpy(&sa->ipv6_spec.hdr.dst_addr,
 				sa->dst.ip.ip6.ip6_b, 16);
-			memcpy(sa->ipv6_spec.hdr.src_addr,
+			memcpy(&sa->ipv6_spec.hdr.src_addr,
 			       sa->src.ip.ip6.ip6_b, 16);
 		} else if (IS_IP4(sa->flags)) {
 			sa->pattern[1].mask = &rte_flow_item_ipv4_mask;
@@ -735,9 +735,9 @@ create_ipsec_esp_flow(struct ipsec_sa *sa)
 		sa->pattern[1].mask = &rte_flow_item_ipv6_mask;
 		sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 		sa->pattern[1].spec = &sa->ipv6_spec;
-		memcpy(sa->ipv6_spec.hdr.dst_addr,
+		memcpy(&sa->ipv6_spec.hdr.dst_addr,
 			sa->dst.ip.ip6.ip6_b, sizeof(sa->dst.ip.ip6.ip6_b));
-		memcpy(sa->ipv6_spec.hdr.src_addr,
+		memcpy(&sa->ipv6_spec.hdr.src_addr,
 			sa->src.ip.ip6.ip6_b, sizeof(sa->src.ip.ip6.ip6_b));
 		sa->pattern[2].type = RTE_FLOW_ITEM_TYPE_ESP;
 		sa->pattern[2].spec = &sa->esp_spec;
examples/ipsec-secgw/sa.c +2 -2
index c4bac17cd77c..1a0afd2ed2e8 100644
@@ -1571,8 +1571,8 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size,
 	};
 
 	if (IS_IP6_TUNNEL(lsa->flags)) {
-		memcpy(v6.src_addr, lsa->src.ip.ip6.ip6_b, sizeof(v6.src_addr));
-		memcpy(v6.dst_addr, lsa->dst.ip.ip6.ip6_b, sizeof(v6.dst_addr));
+		memcpy(&v6.src_addr, lsa->src.ip.ip6.ip6_b, sizeof(v6.src_addr));
+		memcpy(&v6.dst_addr, lsa->dst.ip.ip6.ip6_b, sizeof(v6.dst_addr));
 	}
 
 	rc = fill_ipsec_sa_prm(&prm, lsa, &v4, &v6);
examples/ipsec-secgw/sad.h +6 -4
index 3224b6252c8d..fdb1d2ef1790 100644
@@ -5,6 +5,8 @@
 #ifndef __SAD_H__
 #define __SAD_H__
 
+#include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_ipsec_sad.h>
 
 #define SA_CACHE_SZ	128
@@ -37,8 +39,8 @@ cmp_sa_key(struct ipsec_sa *sa, int is_v4, struct rte_ipv4_hdr *ipv4,
 			(sa->dst.ip.ip4 == ipv4->dst_addr)) ||
 			/* IPv6 check */
 			(!is_v4 && (sa_type == IP6_TUNNEL) &&
-			(!memcmp(sa->src.ip.ip6.ip6, ipv6->src_addr, 16)) &&
-			(!memcmp(sa->dst.ip.ip6.ip6, ipv6->dst_addr, 16))))
+			(!memcmp(sa->src.ip.ip6.ip6, &ipv6->src_addr, 16)) &&
+			(!memcmp(sa->dst.ip.ip6.ip6, &ipv6->dst_addr, 16))))
 		return 1;
 
 	return 0;
@@ -128,9 +130,9 @@ sad_lookup(struct ipsec_sad *sad, struct rte_mbuf *pkts[],
 				}
 			}
 			v6[nb_v6].spi = esp->spi;
-			memcpy(v6[nb_v6].dip, ipv6->dst_addr,
+			memcpy(v6[nb_v6].dip, &ipv6->dst_addr,
 					sizeof(ipv6->dst_addr));
-			memcpy(v6[nb_v6].sip, ipv6->src_addr,
+			memcpy(v6[nb_v6].sip, &ipv6->src_addr,
 					sizeof(ipv6->src_addr));
 			keys_v6[nb_v6] = (const union rte_ipsec_sad_key *)
 						&v6[nb_v6];
examples/l3fwd/l3fwd_fib.c +1 -1
index f38b19af3f57..4a9534e9dbef 100644
@@ -65,7 +65,7 @@ fib_parse_packet(struct rte_mbuf *mbuf,
 	/* IPv6 */
 	else {
 		ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
-		rte_mov16(ipv6, (const uint8_t *)ipv6_hdr->dst_addr);
+		rte_mov16(ipv6, ipv6_hdr->dst_addr.a);
 		*ip_type = 0;
 		(*ipv6_cnt)++;
 	}
examples/l3fwd/l3fwd_lpm.c +2 -2
index e8fd95aae9ce..422fdb70054d 100644
@@ -62,7 +62,7 @@ lpm_get_ipv6_dst_port(const struct rte_ipv6_hdr *ipv6_hdr,
 		      uint16_t portid,
 		      struct rte_lpm6 *ipv6_l3fwd_lookup_struct)
 {
-	const uint8_t *dst_ip = ipv6_hdr->dst_addr;
+	const uint8_t *dst_ip = ipv6_hdr->dst_addr.a;
 	uint32_t next_hop;
 
 	if (rte_lpm6_lookup(ipv6_l3fwd_lookup_struct, dst_ip, &next_hop) == 0)
@@ -122,7 +122,7 @@ lpm_get_dst_port_with_ipv4(const struct lcore_conf *qconf, struct rte_mbuf *pkt,
 		ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
 
 		return (uint16_t) ((rte_lpm6_lookup(qconf->ipv6_lookup_struct,
-				ipv6_hdr->dst_addr, &next_hop) == 0)
+				ipv6_hdr->dst_addr.a, &next_hop) == 0)
 				? next_hop : portid);
 
 	}
lib/ethdev/rte_flow.h +2 -6
index 3a3ab781c494..3990bda14980 100644
@@ -1006,12 +1006,8 @@ struct rte_flow_item_ipv6 {
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
 	.hdr = {
-		.src_addr =
-			"\xff\xff\xff\xff\xff\xff\xff\xff"
-			"\xff\xff\xff\xff\xff\xff\xff\xff",
-		.dst_addr =
-			"\xff\xff\xff\xff\xff\xff\xff\xff"
-			"\xff\xff\xff\xff\xff\xff\xff\xff",
+		.src_addr = RTE_IPV6_MASK_FULL,
+		.dst_addr = RTE_IPV6_MASK_FULL,
 	},
 };
 #endif
lib/hash/rte_thash.h +6 -6
index 18adafbd99fc..d988df15a9ba 100644
@@ -140,24 +140,24 @@ rte_thash_load_v6_addrs(const struct rte_ipv6_hdr *orig,
 			union rte_thash_tuple *targ)
 {
 #ifdef RTE_ARCH_X86
-	__m128i ipv6 = _mm_loadu_si128((const __m128i *)orig->src_addr);
+	__m128i ipv6 = _mm_loadu_si128((const __m128i *)&orig->src_addr);
 	*(__m128i *)targ->v6.src_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
-	ipv6 = _mm_loadu_si128((const __m128i *)orig->dst_addr);
+	ipv6 = _mm_loadu_si128((const __m128i *)&orig->dst_addr);
 	*(__m128i *)targ->v6.dst_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 #elif defined(__ARM_NEON)
-	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)orig->src_addr);
+	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)&orig->src_addr);
 	vst1q_u8((uint8_t *)targ->v6.src_addr, vrev32q_u8(ipv6));
-	ipv6 = vld1q_u8((uint8_t const *)orig->dst_addr);
+	ipv6 = vld1q_u8((uint8_t const *)&orig->dst_addr);
 	vst1q_u8((uint8_t *)targ->v6.dst_addr, vrev32q_u8(ipv6));
 #else
 	int i;
 	for (i = 0; i < 4; i++) {
 		*((uint32_t *)targ->v6.src_addr + i) =
-			rte_be_to_cpu_32(*((const uint32_t *)orig->src_addr + i));
+			rte_be_to_cpu_32(*((const uint32_t *)&orig->src_addr + i));
 		*((uint32_t *)targ->v6.dst_addr + i) =
-			rte_be_to_cpu_32(*((const uint32_t *)orig->dst_addr + i));
+			rte_be_to_cpu_32(*((const uint32_t *)&orig->dst_addr + i));
 	}
 #endif
 }
lib/ip_frag/rte_ipv6_reassembly.c +2 -2
index 88863a98d1fe..9471ce5333d7 100644
@@ -143,8 +143,8 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 	int32_t ip_len;
 	int32_t trim;
 
-	rte_memcpy(&key.src_dst[0], ip_hdr->src_addr, 16);
-	rte_memcpy(&key.src_dst[2], ip_hdr->dst_addr, 16);
+	rte_memcpy(&key.src_dst[0], &ip_hdr->src_addr, 16);
+	rte_memcpy(&key.src_dst[2], &ip_hdr->dst_addr, 16);
 
 	key.id = frag_hdr->id;
 	key.key_len = IPV6_KEYLEN;
lib/net/rte_ip6.h +3 -3
index 725402e6d08e..d364295b11d2 100644
@@ -217,8 +217,8 @@ struct rte_ipv6_hdr {
 	rte_be16_t payload_len;	/**< IP payload size, including ext. headers */
 	uint8_t  proto;		/**< Protocol, next header. */
 	uint8_t  hop_limits;	/**< Hop limits. */
-	uint8_t  src_addr[16];	/**< IP address of source host. */
-	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
+	struct rte_ipv6_addr src_addr;	/**< IP address of source host. */
+	struct rte_ipv6_addr dst_addr;	/**< IP address of destination host(s). */
 } __rte_packed;
 
 /* IPv6 routing extension type definition. */
@@ -286,7 +286,7 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 	else
 		psd_hdr.len = ipv6_hdr->payload_len;
 
-	sum = __rte_raw_cksum(ipv6_hdr->src_addr,
+	sum = __rte_raw_cksum(&ipv6_hdr->src_addr,
 		sizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr),
 		0);
 	sum = __rte_raw_cksum(&psd_hdr, sizeof(psd_hdr), sum);
lib/node/ip6_lookup.c +5 -5
index 309964f60fd6..6bbcf14e2aa8 100644
@@ -112,28 +112,28 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf0, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(ip_batch[0], ipv6_hdr->dst_addr, 16);
+		rte_memcpy(ip_batch[0], &ipv6_hdr->dst_addr, 16);
 
 		/* Extract DIP of mbuf1 */
 		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf1, struct rte_ipv6_hdr *,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf1, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(ip_batch[1], ipv6_hdr->dst_addr, 16);
+		rte_memcpy(ip_batch[1], &ipv6_hdr->dst_addr, 16);
 
 		/* Extract DIP of mbuf2 */
 		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf2, struct rte_ipv6_hdr *,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf2, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(ip_batch[2], ipv6_hdr->dst_addr, 16);
+		rte_memcpy(ip_batch[2], &ipv6_hdr->dst_addr, 16);
 
 		/* Extract DIP of mbuf3 */
 		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf3, struct rte_ipv6_hdr *,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf3, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(ip_batch[3], ipv6_hdr->dst_addr, 16);
+		rte_memcpy(ip_batch[3], &ipv6_hdr->dst_addr, 16);
 
 		rte_lpm6_lookup_bulk_func(lpm6, ip_batch, next_hop, 4);
 
@@ -223,7 +223,7 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 		/* Extract TTL as IPv6 hdr is in cache */
 		node_mbuf_priv1(mbuf0, dyn)->ttl = ipv6_hdr->hop_limits;
 
-		rc = rte_lpm6_lookup(lpm6, ipv6_hdr->dst_addr, &next_hop);
+		rc = rte_lpm6_lookup(lpm6, ipv6_hdr->dst_addr.a, &next_hop);
 		next_hop = (rc == 0) ? next_hop : drop_nh;
 
 		node_mbuf_priv1(mbuf0, dyn)->nh = (uint16_t)next_hop;
lib/pipeline/rte_swx_ipsec.c +2 -4
index 56a401d0fa63..5920178f38e5 100644
@@ -1387,13 +1387,11 @@ tunnel_ipv6_header_set(struct rte_ipv6_hdr *h, struct rte_swx_ipsec_sa_params *p
 		.payload_len = 0, /* Cannot be pre-computed. */
 		.proto = IPPROTO_ESP,
 		.hop_limits = 64,
-		.src_addr = {0},
-		.dst_addr = {0},
 	};
 
 	memcpy(h, &ipv6_hdr, sizeof(ipv6_hdr));
-	memcpy(h->src_addr, p->encap.tunnel.ipv6.src_addr.s6_addr, 16);
-	memcpy(h->dst_addr, p->encap.tunnel.ipv6.dst_addr.s6_addr, 16);
+	memcpy(&h->src_addr, p->encap.tunnel.ipv6.src_addr.s6_addr, 16);
+	memcpy(&h->dst_addr, p->encap.tunnel.ipv6.dst_addr.s6_addr, 16);
 }
 
 /* IPsec library SA parameters. */
lib/pipeline/rte_table_action.c +12 -12
index ebbdd3f4cebe..89a63f024a1f 100644
@@ -872,10 +872,10 @@ 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,
+			memcpy(&d->ipv6.src_addr,
 				p->vxlan.ipv6.sa,
 				sizeof(p->vxlan.ipv6.sa));
-			memcpy(d->ipv6.dst_addr,
+			memcpy(&d->ipv6.dst_addr,
 				p->vxlan.ipv6.da,
 				sizeof(p->vxlan.ipv6.da));
 
@@ -907,10 +907,10 @@ 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,
+			memcpy(&d->ipv6.src_addr,
 				p->vxlan.ipv6.sa,
 				sizeof(p->vxlan.ipv6.sa));
-			memcpy(d->ipv6.dst_addr,
+			memcpy(&d->ipv6.dst_addr,
 				p->vxlan.ipv6.da,
 				sizeof(p->vxlan.ipv6.da));
 
@@ -1437,12 +1437,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t tcp_cksum;
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
-				(uint16_t *)ip->src_addr,
+				(uint16_t *)&ip->src_addr,
 				(uint16_t *)data->addr,
 				tcp->src_port,
 				data->port);
 
-			rte_memcpy(ip->src_addr, data->addr, 16);
+			rte_memcpy(&ip->src_addr, data->addr, 16);
 			tcp->src_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1450,12 +1450,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t udp_cksum;
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
-				(uint16_t *)ip->src_addr,
+				(uint16_t *)&ip->src_addr,
 				(uint16_t *)data->addr,
 				udp->src_port,
 				data->port);
 
-			rte_memcpy(ip->src_addr, data->addr, 16);
+			rte_memcpy(&ip->src_addr, data->addr, 16);
 			udp->src_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
@@ -1465,12 +1465,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t tcp_cksum;
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
-				(uint16_t *)ip->dst_addr,
+				(uint16_t *)&ip->dst_addr,
 				(uint16_t *)data->addr,
 				tcp->dst_port,
 				data->port);
 
-			rte_memcpy(ip->dst_addr, data->addr, 16);
+			rte_memcpy(&ip->dst_addr, data->addr, 16);
 			tcp->dst_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1478,12 +1478,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t udp_cksum;
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
-				(uint16_t *)ip->dst_addr,
+				(uint16_t *)&ip->dst_addr,
 				(uint16_t *)data->addr,
 				udp->dst_port,
 				data->port);
 
-			rte_memcpy(ip->dst_addr, data->addr, 16);
+			rte_memcpy(&ip->dst_addr, data->addr, 16);
 			udp->dst_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
Signature · 1 line
2.46.2
#73 lore raw

PATCH v3 6/17 fib6,rib6,lpm6: use struct rte_ipv6_addr

In reply to Robin Jarry

Replace ad-hoc uint8_t[16] array types in the API of rte_fib6, rte_rib6 and rte_lpm6 with rte_ipv6_addr structures Update all code accordingly.

Unfortunately, these three libraries are strongly intertwined, it is not possible to split this change in separate commits.

NB: the conversion between 16 bytes arrays and RTE_IPV6() literals was done automatically with the following python script and adjusted manually afterwards:

import argparse
import re
import struct

ip = re.compile(

    r"""
    \{
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*
    \}
    """,
    re.VERBOSE,

)

def repl(match):

    u8 = bytes(int(g, 0) for g in match.groups("0"))
    nums = []
    for u16 in struct.unpack("!HHHHHHHH", u8):
        if u16:
            nums.append(f"0x{u16:04x}")
        else:
            nums.append("0")
    return f"RTE_IPV6({', '.join(nums)})"

p = argparse.ArgumentParser()
p.add_argument("args", nargs="+")
args = p.parse_args()

for a in args.args:

with open(a) as f:
buf = f.read()

buf = ip.sub(repl, buf)
with open(a, "w") as f:
f.write(buf)

---

Notes:
v3:

- replace *memcpy(ipv6) with direct struct assignments
- use RTE_IPV6_ADDR_FMT and RTE_IPV6_ADDR_SPLIT when possible
- use RTE_IPV6_ADDR_UNSPEC instead of {0}
- use RTE_IPV6() instead of RTE_IPV6_ADDR()
- replace stray in6_addr uses with rte_ipv6_addr

 app/test-fib/main.c                    |   51 +-
 app/test-pipeline/pipeline_lpm_ipv6.c  |   11 +-
 app/test/test_fib6.c                   |   51 +-
 app/test/test_fib6_perf.c              |    8 +-
 app/test/test_lpm6.c                   |  490 +++---
 app/test/test_lpm6_data.h              | 2025 ++++++++++++------------
 app/test/test_lpm6_perf.c              |   10 +-
 app/test/test_rib6.c                   |   55 +-
 app/test/test_table_combined.c         |    2 +-
 app/test/test_table_tables.c           |    8 +-
 doc/guides/rel_notes/deprecation.rst   |   20 -
 doc/guides/rel_notes/release_24_11.rst |    1 +
 examples/ip_fragmentation/main.c       |   23 +-
 examples/ip_pipeline/thread.c          |    2 +-
 examples/ip_reassembly/main.c          |   23 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h  |    7 +-
 examples/ipsec-secgw/ipsec_worker.c    |   11 +-
 examples/ipsec-secgw/ipsec_worker.h    |    4 +-
 examples/ipsec-secgw/rt.c              |   22 +-
 examples/l3fwd/l3fwd_fib.c             |   39 +-
 examples/l3fwd/l3fwd_lpm.c             |    8 +-
 examples/l3fwd/l3fwd_route.h           |    9 +-
 examples/l3fwd/lpm_route_parse.c       |    9 +-
 examples/l3fwd/main.c                  |   32 +-
 lib/fib/meson.build                    |    4 +-
 lib/fib/rte_fib6.c                     |   13 +-
 lib/fib/rte_fib6.h                     |   11 +-
 lib/fib/trie.c                         |   99 +-
 lib/fib/trie.h                         |   16 +-
 lib/fib/trie_avx512.c                  |   38 +-
 lib/fib/trie_avx512.h                  |   10 +-
 lib/lpm/meson.build                    |    1 +
 lib/lpm/rte_lpm6.c                     |  114 +-
 lib/lpm/rte_lpm6.h                     |   14 +-
 lib/node/ip6_lookup.c                  |   16 +-
 lib/rib/meson.build                    |    2 +-
 lib/rib/rte_rib6.c                     |   74 +-
 lib/rib/rte_rib6.h                     |   13 +-
 lib/table/rte_table_lpm_ipv6.c         |   12 +-
 lib/table/rte_table_lpm_ipv6.h         |    7 +-
 40 files changed, 1652 insertions(+), 1713 deletions(-)
app/test-fib/main.c +25 -26
index c49bfe8bcec3..91a3eeecf6ee 100644
@@ -123,7 +123,7 @@ struct rt_rule_4 {
 };
 
 struct rt_rule_6 {
-	uint8_t		addr[16];
+	struct rte_ipv6_addr addr;
 	uint8_t		depth;
 	uint64_t	nh;
 };
@@ -306,15 +306,15 @@ shuffle_rt_6(struct rt_rule_6 *rt, int n)
 
 	for (i = 0; i < n; i++) {
 		j = rte_rand() % n;
-		memcpy(tmp.addr, rt[i].addr, 16);
+		tmp.addr = rt[i].addr;
 		tmp.depth = rt[i].depth;
 		tmp.nh = rt[i].nh;
 
-		memcpy(rt[i].addr, rt[j].addr, 16);
+		rt[i].addr = rt[j].addr;
 		rt[i].depth = rt[j].depth;
 		rt[i].nh = rt[j].nh;
 
-		memcpy(rt[j].addr, tmp.addr, 16);
+		rt[j].addr = tmp.addr;
 		rt[j].depth = tmp.depth;
 		rt[j].nh = tmp.nh;
 	}
@@ -364,7 +364,7 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 	uint32_t a, i, j, k = 0;
 
 	if (config.nb_routes_per_depth[0] != 0) {
-		memset(rt[k].addr, 0, 16);
+		memset(&rt[k].addr, 0, 16);
 		rt[k].depth = 0;
 		rt[k++].nh = rte_rand() & get_max_nh(nh_sz);
 	}
@@ -380,7 +380,7 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 				uint64_t rnd_val = get_rnd_rng((uint64_t)edge,
 					(uint64_t)(edge + step));
 				rnd = rte_cpu_to_be_32(rnd_val << (32 - i));
-				complete_v6_addr((uint32_t *)rt[k].addr,
+				complete_v6_addr((uint32_t *)&rt[k].addr,
 					rnd, a);
 				rt[k].depth = (a * 32) + i;
 				rt[k].nh = rte_rand() & get_max_nh(nh_sz);
@@ -390,19 +390,19 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 }
 
 static inline void
-set_rnd_ipv6(uint8_t *addr, uint8_t *route, int depth)
+set_rnd_ipv6(struct rte_ipv6_addr *addr, struct rte_ipv6_addr *route, int depth)
 {
 	int i;
 
 	for (i = 0; i < 16; i++)
-		addr[i] = rte_rand();
+		addr->a[i] = rte_rand();
 
 	for (i = 0; i < 16; i++) {
 		if (depth >= 8)
-			addr[i] = route[i];
+			addr->a[i] = route->a[i];
 		else if (depth > 0) {
-			addr[i] &= (uint16_t)UINT8_MAX >> depth;
-			addr[i] |= route[i] & UINT8_MAX << (8 - depth);
+			addr->a[i] &= (uint16_t)UINT8_MAX >> depth;
+			addr->a[i] |= route->a[i] & UINT8_MAX << (8 - depth);
 		} else
 			return;
 		depth -= 8;
@@ -413,7 +413,7 @@ static void
 gen_rnd_lookup_tbl(int af)
 {
 	uint32_t *tbl4 = config.lookup_tbl;
-	uint8_t *tbl6 = config.lookup_tbl;
+	struct rte_ipv6_addr *tbl6 = config.lookup_tbl;
 	struct rt_rule_4 *rt4 = (struct rt_rule_4 *)config.rt;
 	struct rt_rule_6 *rt6 = (struct rt_rule_6 *)config.rt;
 	uint32_t i, j;
@@ -432,11 +432,10 @@ gen_rnd_lookup_tbl(int af)
 		for (i = 0, j = 0; i < config.nb_lookup_ips;
 				i++, j = (j + 1) % config.nb_routes) {
 			if ((rte_rand() % 100) < config.rnd_lookup_ips_ratio) {
-				set_rnd_ipv6(&tbl6[i * 16], rt6[j].addr, 0);
+				set_rnd_ipv6(&tbl6[i], &rt6[j].addr, 0);
 				config.nb_lookup_ips_rnd++;
 			} else {
-				set_rnd_ipv6(&tbl6[i * 16], rt6[j].addr,
-					rt6[j].depth);
+				set_rnd_ipv6(&tbl6[i], &rt6[j].addr, rt6[j].depth);
 			}
 		}
 	}
@@ -522,7 +521,7 @@ parse_rt_6(FILE *f)
 			s = NULL;
 		}
 
-		ret = _inet_net_pton(AF_INET6, in[RT_PREFIX], rt[j].addr);
+		ret = _inet_net_pton(AF_INET6, in[RT_PREFIX], &rt[j].addr);
 		if (ret < 0)
 			return ret;
 
@@ -1023,7 +1022,7 @@ dump_rt_6(struct rt_rule_6 *rt)
 	}
 
 	for (i = 0; i < config.nb_routes; i++) {
-		fprintf(f, NIPQUAD6_FMT"/%d %"PRIu64"\n", NIPQUAD6(rt[i].addr),
+		fprintf(f, NIPQUAD6_FMT"/%d %"PRIu64"\n", NIPQUAD6(&rt[i].addr),
 			rt[i].depth, rt[i].nh);
 
 	}
@@ -1043,7 +1042,7 @@ run_v6(void)
 	int ret = 0;
 	struct rte_lpm6	*lpm = NULL;
 	struct rte_lpm6_config lpm_conf;
-	uint8_t *tbl6;
+	struct rte_ipv6_addr *tbl6;
 	uint64_t fib_nh[BURST_SZ];
 	int32_t lpm_nh[BURST_SZ];
 
@@ -1094,7 +1093,7 @@ run_v6(void)
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++) {
-			ret = rte_fib6_add(fib, rt[i + j].addr,
+			ret = rte_fib6_add(fib, &rt[i + j].addr,
 				rt[i + j].depth, rt[i + j].nh);
 			if (unlikely(ret != 0)) {
 				printf("Can not add a route to FIB, err %d\n",
@@ -1120,7 +1119,7 @@ run_v6(void)
 		for (k = config.print_fract, i = 0; k > 0; k--) {
 			start = rte_rdtsc_precise();
 			for (j = 0; j < (config.nb_routes - i) / k; j++) {
-				ret = rte_lpm6_add(lpm, rt[i + j].addr,
+				ret = rte_lpm6_add(lpm, &rt[i + j].addr,
 					rt[i + j].depth, rt[i + j].nh);
 				if (ret != 0) {
 					if (rt[i + j].depth == 0)
@@ -1139,7 +1138,7 @@ run_v6(void)
 	acc = 0;
 	for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 		start = rte_rdtsc_precise();
-		ret = rte_fib6_lookup_bulk(fib, (uint8_t (*)[16])(tbl6 + i*16),
+		ret = rte_fib6_lookup_bulk(fib, &tbl6[i],
 			fib_nh, BURST_SZ);
 		acc += rte_rdtsc_precise() - start;
 		if (ret != 0) {
@@ -1154,7 +1153,7 @@ run_v6(void)
 		for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 			start = rte_rdtsc_precise();
 			ret = rte_lpm6_lookup_bulk_func(lpm,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				lpm_nh, BURST_SZ);
 			acc += rte_rdtsc_precise() - start;
 			if (ret != 0) {
@@ -1166,10 +1165,10 @@ run_v6(void)
 
 		for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 			rte_fib6_lookup_bulk(fib,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				fib_nh, BURST_SZ);
 			rte_lpm6_lookup_bulk_func(lpm,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				lpm_nh, BURST_SZ);
 			for (j = 0; j < BURST_SZ; j++) {
 				if ((fib_nh[j] != (uint32_t)lpm_nh[j]) &&
@@ -1186,7 +1185,7 @@ run_v6(void)
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++)
-			rte_fib6_delete(fib, rt[i + j].addr, rt[i + j].depth);
+			rte_fib6_delete(fib, &rt[i + j].addr, rt[i + j].depth);
 
 		printf("AVG FIB delete %"PRIu64"\n",
 			(rte_rdtsc_precise() - start) / j);
@@ -1197,7 +1196,7 @@ run_v6(void)
 		for (k = config.print_fract, i = 0; k > 0; k--) {
 			start = rte_rdtsc_precise();
 			for (j = 0; j < (config.nb_routes - i) / k; j++)
-				rte_lpm6_delete(lpm, rt[i + j].addr,
+				rte_lpm6_delete(lpm, &rt[i + j].addr,
 					rt[i + j].depth);
 
 			printf("AVG LPM delete %"PRIu64"\n",
app/test-pipeline/pipeline_lpm_ipv6.c +3 -8
index 207ffbeff00f..6558e887c859 100644
@@ -127,16 +127,11 @@ app_main_loop_worker_pipeline_lpm_ipv6(void) {
 
 		ip = rte_bswap32(i << (24 -
 			rte_popcount32(app.n_ports - 1)));
-		memcpy(key.ip, &ip, sizeof(uint32_t));
+		memcpy(&key.ip, &ip, sizeof(uint32_t));
 
 		printf("Adding rule to IPv6 LPM table (IPv6 destination = "
-			"%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:"
-			"%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x/%u => "
-			"port out = %u)\n",
-			key.ip[0], key.ip[1], key.ip[2], key.ip[3],
-			key.ip[4], key.ip[5], key.ip[6], key.ip[7],
-			key.ip[8], key.ip[9], key.ip[10], key.ip[11],
-			key.ip[12], key.ip[13], key.ip[14], key.ip[15],
+			RTE_IPV6_ADDR_FMT "/%u => port out = %u)\n",
+			RTE_IPV6_ADDR_SPLIT(&key.ip),
 			key.depth, i);
 
 		status = rte_pipeline_table_entry_add(p, table_id, &key, &entry,
app/test/test_fib6.c +25 -26

133 lines not on this page · raw message

app/test/test_fib6_perf.c +4 -4
index fe713e7094e5..a96a0d6b2cdc 100644
@@ -73,7 +73,7 @@ test_fib6_perf(void)
 	uint64_t next_hop_add;
 	int status = 0;
 	int64_t count = 0;
-	uint8_t ip_batch[NUM_IPS_ENTRIES][16];
+	struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES];
 	uint64_t next_hops[NUM_IPS_ENTRIES];
 
 	conf.type = RTE_FIB6_TRIE;
@@ -101,7 +101,7 @@ test_fib6_perf(void)
 
 	for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
 		next_hop_add = (i & ((1 << 14) - 1)) + 1;
-		if (rte_fib6_add(fib, large_route_table[i].ip,
+		if (rte_fib6_add(fib, &large_route_table[i].ip,
 				large_route_table[i].depth, next_hop_add) == 0)
 			status++;
 	}
@@ -117,7 +117,7 @@ test_fib6_perf(void)
 	count = 0;
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++)
-		memcpy(ip_batch[i], large_ips_table[i].ip, 16);
+		ip_batch[i] = large_ips_table[i].ip;
 
 	for (i = 0; i < ITERATIONS; i++) {
 
@@ -140,7 +140,7 @@ test_fib6_perf(void)
 
 	for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
 		/* rte_fib_delete(fib, ip, depth) */
-		status += rte_fib6_delete(fib, large_route_table[i].ip,
+		status += rte_fib6_delete(fib, &large_route_table[i].ip,
 				large_route_table[i].depth);
 	}
 
app/test/test_lpm6.c +232 -258

1,258 lines not on this page · raw message

app/test/test_lpm6_data.h +1013 -1012

1,387 lines not on this page · raw message

app/test/test_lpm6_perf.c +5 -5
index c847dcb18375..1860a99ed6f1 100644

Lines of this file are not shown. View the raw message.

app/test/test_rib6.c +25 -30

55 lines not on this page · raw message

app/test/test_table_combined.c +1 -1
index 1c2efe649ded..04503baa5180 100644

Lines of this file are not shown. View the raw message.

app/test/test_table_tables.c +4 -4
index 26908e6112fc..920aa555cbd2 100644

Lines of this file are not shown. View the raw message.

doc/guides/rel_notes/deprecation.rst +0 -20
index 439867289cf3..ee958c689b3a 100644

Lines of this file are not shown. View the raw message.

doc/guides/rel_notes/release_24_11.rst +1 -0
index e769d275f784..dc8926a6078e 100644

Lines of this file are not shown. View the raw message.

examples/ip_fragmentation/main.c +11 -12
index 4c0fa5054a2e..1f841028442f 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/thread.c +1 -1
index 8a912dc1b392..9d8082b73080 100644

Lines of this file are not shown. View the raw message.

examples/ip_reassembly/main.c +11 -12
index 4da692eb23e6..17ae76d4badb 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_lpm_neon.h +4 -3
index 9573f53ae957..752401d9f27f 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_worker.c +3 -8
index c9c43ebd2b99..c205e70ad0be 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_worker.h +2 -2
index 8f6a1c06aa7f..8f9616129362 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/rt.c +11 -11
index ce854ccb6018..059fc0c8f28c 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_fib.c +18 -21
index 4a9534e9dbef..f98795071faf 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_lpm.c +4 -4
index 422fdb70054d..fc4f5878fcd8 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_route.h +4 -5
index 467c4d285915..62263c354054 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/lpm_route_parse.c +4 -5
index f2028d79e180..9c179dc065c0 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/main.c +16 -16
index 01b763e5ba11..6e2155e0052e 100644

Lines of this file are not shown. View the raw message.

lib/fib/meson.build +2 -2
index 6795f41a0ad2..268007ef6c93 100644

Lines of this file are not shown. View the raw message.

lib/fib/rte_fib6.c +7 -6
index 9ad990724a8b..d95cac79cbb5 100644

Lines of this file are not shown. View the raw message.

lib/fib/rte_fib6.h +6 -5
index 2eb8b8267647..d26a0c7c0b77 100644

Lines of this file are not shown. View the raw message.

lib/fib/trie.c +48 -51

99 lines not on this page · raw message

lib/fib/trie.h +9 -7
index 2c20184a26a3..6e235edaf89c 100644

Lines of this file are not shown. View the raw message.

lib/fib/trie_avx512.c +19 -19
index d4d70d84bf60..f49482a95dfa 100644

Lines of this file are not shown. View the raw message.

lib/fib/trie_avx512.h +7 -3
index ef8c7f0e3474..1028a4899fc7 100644

Lines of this file are not shown. View the raw message.

lib/lpm/meson.build +1 -0
index ae30f80b69c8..fae4f79fb938 100644

Lines of this file are not shown. View the raw message.

lib/lpm/rte_lpm6.c +54 -60

114 lines not on this page · raw message

lib/lpm/rte_lpm6.h +8 -6
index c93683e6240c..87392194237c 100644

Lines of this file are not shown. View the raw message.

lib/node/ip6_lookup.c +8 -8
index 6bbcf14e2aa8..f291ef74832b 100644

Lines of this file are not shown. View the raw message.

lib/rib/meson.build +1 -1
index 7bacbb453592..e98f70848189 100644

Lines of this file are not shown. View the raw message.

lib/rib/rte_rib6.c +37 -37

74 lines not on this page · raw message

lib/rib/rte_rib6.h +7 -6
index 775286f965f2..47dcb6d15183 100644

Lines of this file are not shown. View the raw message.

lib/table/rte_table_lpm_ipv6.c +6 -6
index c1a7412f92cf..dea11130d3d5 100644

Lines of this file are not shown. View the raw message.

lib/table/rte_table_lpm_ipv6.h +5 -2
index 166a5ba9ee67..3ea888360635 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.46.2

Part of the diff is not shown here. View the raw message.

#74 lore raw

PATCH v3 7/17 fib6,rib6,lpm6: use ipv6 utils

In reply to Robin Jarry

Replace duplicated and/or private functions by utilities from rte_ip6.h.

Mark rib6 functions that deal with ipv6 addresses as deprecated.

---

Notes:
v3:

- replace rte_ipv6_addr_cpy with direct assignments

 app/test/test_fib6.c |  9 +++++---
 app/test/test_rib6.c |  2 +-
 lib/fib/trie.c       | 22 ++++++-------------
 lib/lpm/rte_lpm6.c   | 32 ++++-----------------------
 lib/rib/rte_rib6.c   | 51 ++++++++++++++------------------------------
 lib/rib/rte_rib6.h   |  8 +++++++
 6 files changed, 42 insertions(+), 82 deletions(-)
app/test/test_fib6.c +6 -3
index d8149e028e4f..8853adeaac7c 100644
@@ -278,9 +278,12 @@ check_fib(struct rte_fib6 *fib)
 	int ret;
 
 	for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) {
-		for (j = 0; j < RTE_FIB6_IPV6_ADDR_SIZE; j++) {
-			ip_arr[i].a[j] = ip_add.a[j] |
-				~get_msk_part(RTE_FIB6_MAXDEPTH - i, j);
+		ip_arr[i] = ip_add;
+		j = (RTE_FIB6_MAXDEPTH - i) / CHAR_BIT;
+		if (j < RTE_FIB6_IPV6_ADDR_SIZE) {
+			ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_FIB6_MAXDEPTH - i) % CHAR_BIT);
+			for (j++; j < RTE_FIB6_IPV6_ADDR_SIZE; j++)
+				ip_arr[i].a[j] = 0xff;
 		}
 	}
 
app/test/test_rib6.c +1 -1
index 6a3445297cb1..ba54a3794ea7 100644
@@ -215,7 +215,7 @@ test_get_fn(void)
 
 	/* check the return values */
 	ret = rte_rib6_get_ip(node, &ip_ret);
-	RTE_TEST_ASSERT((ret == 0) && (rte_rib6_is_equal(ip_ret.a, ip.a)),
+	RTE_TEST_ASSERT((ret == 0) && (rte_ipv6_addr_eq(&ip_ret, &ip)),
 		"Failed to get proper node ip\n");
 	ret = rte_rib6_get_depth(node, &depth_ret);
 	RTE_TEST_ASSERT((ret == 0) && (depth_ret == depth),
lib/fib/trie.c +7 -15
index 0b459b3749b9..b0d80c3db815 100644
@@ -451,14 +451,6 @@ get_nxt_net(struct rte_ipv6_addr *ip, uint8_t depth)
 	}
 }
 
-static int
-v6_addr_is_zero(const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE])
-{
-	uint8_t ip_addr[RTE_FIB6_IPV6_ADDR_SIZE] = {0};
-
-	return rte_rib6_is_equal(ip, ip_addr);
-}
-
 static int
 modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 	const struct rte_ipv6_addr *ip,
@@ -481,7 +473,7 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 			if (tmp_depth == depth)
 				continue;
 			rte_rib6_get_ip(tmp, &redge);
-			if (rte_rib6_is_equal(ledge.a, redge.a)) {
+			if (rte_ipv6_addr_eq(&ledge, &redge)) {
 				get_nxt_net(&ledge, tmp_depth);
 				continue;
 			}
@@ -494,13 +486,13 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 			 * we got to the end of address space
 			 * and wrapped around
 			 */
-			if (v6_addr_is_zero(ledge.a))
+			if (rte_ipv6_addr_is_unspec(&ledge))
 				break;
 		} else {
 			redge = *ip;
 			get_nxt_net(&redge, depth);
-			if (rte_rib6_is_equal(ledge.a, redge.a) &&
-					!v6_addr_is_zero(ledge.a))
+			if (rte_ipv6_addr_eq(&ledge, &redge) &&
+					!rte_ipv6_addr_is_unspec(&ledge))
 				break;
 
 			ret = install_to_dp(dp, &ledge, &redge, next_hop);
@@ -522,7 +514,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	struct rte_rib6_node *node;
 	struct rte_rib6_node *parent;
 	struct rte_ipv6_addr ip_masked;
-	int i, ret = 0;
+	int ret = 0;
 	uint64_t par_nh, node_nh;
 	uint8_t tmp_depth, depth_diff = 0, parent_depth = 24;
 
@@ -534,8 +526,8 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	rib = rte_fib6_get_rib(fib);
 	RTE_ASSERT(rib);
 
-	for (i = 0; i < RTE_FIB6_IPV6_ADDR_SIZE; i++)
-		ip_masked.a[i] = ip->a[i] & get_msk_part(depth, i);
+	ip_masked = *ip;
+	rte_ipv6_addr_mask(&ip_masked, depth);
 
 	if (depth > 24) {
 		tmp = rte_rib6_get_nxt(rib, &ip_masked,
lib/lpm/rte_lpm6.c +4 -28
index b03221d013c5..1d5577f263b1 100644
@@ -111,30 +111,6 @@ struct rte_lpm6 {
 			/**< LPM tbl8 table. */
 };
 
-/*
- * Takes an array of uint8_t (IPv6 address) and masks it using the depth.
- * It leaves untouched one bit per unit in the depth variable
- * and set the rest to 0.
- */
-static inline void
-ip6_mask_addr(uint8_t *ip, uint8_t depth)
-{
-	int16_t part_depth, mask;
-	int i;
-
-	part_depth = depth;
-
-	for (i = 0; i < RTE_LPM6_IPV6_ADDR_SIZE; i++) {
-		if (part_depth < BYTE_SIZE && part_depth >= 0) {
-			mask = (uint16_t)(~(UINT8_MAX >> part_depth));
-			ip[i] = (uint8_t)(ip[i] & mask);
-		} else if (part_depth < 0)
-			ip[i] = 0;
-
-		part_depth -= BYTE_SIZE;
-	}
-}
-
 /*
  * LPM6 rule hash function
  *
@@ -861,7 +837,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t depth
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
 	masked_ip = *ip;
-	ip6_mask_addr(masked_ip.a, depth);
+	rte_ipv6_addr_mask(&masked_ip, depth);
 
 	/* Simulate adding a new route */
 	int ret = simulate_add(lpm, &masked_ip, depth);
@@ -1022,7 +998,7 @@ rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, u
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
 	masked_ip = *ip;
-	ip6_mask_addr(masked_ip.a, depth);
+	rte_ipv6_addr_mask(&masked_ip, depth);
 
 	return rule_find(lpm, &masked_ip, depth, next_hop);
 }
@@ -1072,7 +1048,7 @@ rte_lpm6_delete_bulk_func(struct rte_lpm6 *lpm,
 
 	for (i = 0; i < n; i++) {
 		masked_ip = ips[i];
-		ip6_mask_addr(masked_ip.a, depths[i]);
+		rte_ipv6_addr_mask(&masked_ip, depths[i]);
 		rule_delete(lpm, &masked_ip, depths[i]);
 	}
 
@@ -1297,7 +1273,7 @@ rte_lpm6_delete(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t de
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
 	masked_ip = *ip;
-	ip6_mask_addr(masked_ip.a, depth);
+	rte_ipv6_addr_mask(&masked_ip, depth);
 
 	/* Delete the rule from the rule table. */
 	ret = rule_delete(lpm, &masked_ip, depth);
lib/rib/rte_rib6.c +16 -35

130 lines not on this page · raw message

lib/rib/rte_rib6.h +8 -0
index 47dcb6d15183..ec62fdafecb6 100644
@@ -57,6 +57,9 @@ struct rte_rib6_conf {
  * @param src
  *  pointer from where to copy
  */
+static inline void rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
+	__rte_deprecated_msg("use direct struct assignment");
+
 static inline void
 rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
 {
@@ -77,6 +80,9 @@ rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
  *  1 if equal
  *  0 otherwise
  */
+static inline int rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2)
+	__rte_deprecated_msg("use rte_ipv6_addr_eq");
+
 static inline int
 rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
 	int i;
@@ -101,6 +107,8 @@ rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
  * @return
  *  8-bit chunk of the 128-bit IPv6 mask
  */
+static inline uint8_t get_msk_part(uint8_t depth, int byte) __rte_deprecated;
+
 static inline uint8_t
 get_msk_part(uint8_t depth, int byte) {
 	uint8_t part;
Signature · 1 line
2.46.2
#75 lore raw

PATCH v3 8/17 rib6,fib6,lpm6: remove duplicate constants

In reply to Robin Jarry

Replace all address size and max depth macros with common ones from rte_ip6.h. Mark the old symbols as deprecated.

---

Notes:
v3:

- replace memcpy() with direct struct assignments
- restore RTE_FIB6_IPV6_ADDR_SIZE, RTE_FIB6_MAXDEPTH, TRIE_MAX_DEPTH, RTE_LPM6_MAX_DEPTH, RTE_LPM6_IPV6_ADDR_SIZE, RTE_RIB6_IPV6_ADDR_SIZE and mark them as RTE_DEPRECATED()
- replace string initializers with RTE_IPV6()

 app/test/test_fib6.c        | 50 ++++++++++++++++++-------------------
 examples/l3fwd-graph/main.c |  4 +--
 lib/fib/rte_fib6.c          |  6 ++---
 lib/fib/rte_fib6.h          |  5 ++--
 lib/fib/trie.c              |  6 ++---
 lib/fib/trie.h              |  3 ++-
 lib/lpm/rte_lpm6.c          | 10 ++++----
 lib/lpm/rte_lpm6.h          |  5 ++--
 lib/node/ip6_lookup.c       |  2 +-
 lib/rib/rte_rib6.c          | 11 ++++----
 lib/rib/rte_rib6.h          |  6 ++---
 11 files changed, 55 insertions(+), 53 deletions(-)
app/test/test_fib6.c +25 -25
index 8853adeaac7c..79220a88b112 100644
@@ -170,13 +170,13 @@ test_add_del_invalid(void)
 	fib = rte_fib6_create(__func__, SOCKET_ID_ANY, &config);
 	RTE_TEST_ASSERT(fib != NULL, "Failed to create FIB\n");
 
-	/* rte_fib6_add: depth > RTE_FIB6_MAXDEPTH */
-	ret = rte_fib6_add(fib, &ip, RTE_FIB6_MAXDEPTH + 1, nh);
+	/* rte_fib6_add: depth > RTE_IPV6_MAX_DEPTH */
+	ret = rte_fib6_add(fib, &ip, RTE_IPV6_MAX_DEPTH + 1, nh);
 	RTE_TEST_ASSERT(ret < 0,
 		"Call succeeded with invalid parameters\n");
 
-	/* rte_fib6_delete: depth > RTE_FIB6_MAXDEPTH */
-	ret = rte_fib6_delete(fib, &ip, RTE_FIB6_MAXDEPTH + 1);
+	/* rte_fib6_delete: depth > RTE_IPV6_MAX_DEPTH */
+	ret = rte_fib6_delete(fib, &ip, RTE_IPV6_MAX_DEPTH + 1);
 	RTE_TEST_ASSERT(ret < 0,
 		"Call succeeded with invalid parameters\n");
 
@@ -216,18 +216,18 @@ lookup_and_check_asc(struct rte_fib6 *fib,
 	struct rte_ipv6_addr *ip_missing, uint64_t def_nh,
 	uint32_t n)
 {
-	uint64_t nh_arr[RTE_FIB6_MAXDEPTH];
+	uint64_t nh_arr[RTE_IPV6_MAX_DEPTH];
 	int ret;
 	uint32_t i = 0;
 
-	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_FIB6_MAXDEPTH);
+	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_IPV6_MAX_DEPTH);
 	RTE_TEST_ASSERT(ret == 0, "Failed to lookup\n");
 
-	for (; i <= RTE_FIB6_MAXDEPTH - n; i++)
+	for (; i <= RTE_IPV6_MAX_DEPTH - n; i++)
 		RTE_TEST_ASSERT(nh_arr[i] == n,
 			"Failed to get proper nexthop\n");
 
-	for (; i < RTE_FIB6_MAXDEPTH; i++)
+	for (; i < RTE_IPV6_MAX_DEPTH; i++)
 		RTE_TEST_ASSERT(nh_arr[i] == --n,
 			"Failed to get proper nexthop\n");
 
@@ -244,18 +244,18 @@ lookup_and_check_desc(struct rte_fib6 *fib,
 	struct rte_ipv6_addr *ip_missing, uint64_t def_nh,
 	uint32_t n)
 {
-	uint64_t nh_arr[RTE_FIB6_MAXDEPTH];
+	uint64_t nh_arr[RTE_IPV6_MAX_DEPTH];
 	int ret;
 	uint32_t i = 0;
 
-	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_FIB6_MAXDEPTH);
+	ret = rte_fib6_lookup_bulk(fib, ip_arr, nh_arr, RTE_IPV6_MAX_DEPTH);
 	RTE_TEST_ASSERT(ret == 0, "Failed to lookup\n");
 
 	for (; i < n; i++)
-		RTE_TEST_ASSERT(nh_arr[i] == RTE_FIB6_MAXDEPTH - i,
+		RTE_TEST_ASSERT(nh_arr[i] == RTE_IPV6_MAX_DEPTH - i,
 			"Failed to get proper nexthop\n");
 
-	for (; i < RTE_FIB6_MAXDEPTH; i++)
+	for (; i < RTE_IPV6_MAX_DEPTH; i++)
 		RTE_TEST_ASSERT(nh_arr[i] == def_nh,
 			"Failed to get proper nexthop\n");
 
@@ -270,19 +270,19 @@ static int
 check_fib(struct rte_fib6 *fib)
 {
 	uint64_t def_nh = 100;
-	struct rte_ipv6_addr ip_arr[RTE_FIB6_MAXDEPTH];
+	struct rte_ipv6_addr ip_arr[RTE_IPV6_MAX_DEPTH];
 	struct rte_ipv6_addr ip_add = RTE_IPV6(0x8000, 0, 0, 0, 0, 0, 0, 0);
 	struct rte_ipv6_addr ip_missing =
 		RTE_IPV6(0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff);
 	uint32_t i, j;
 	int ret;
 
-	for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) {
+	for (i = 0; i < RTE_IPV6_MAX_DEPTH; i++) {
 		ip_arr[i] = ip_add;
-		j = (RTE_FIB6_MAXDEPTH - i) / CHAR_BIT;
-		if (j < RTE_FIB6_IPV6_ADDR_SIZE) {
-			ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_FIB6_MAXDEPTH - i) % CHAR_BIT);
-			for (j++; j < RTE_FIB6_IPV6_ADDR_SIZE; j++)
+		j = (RTE_IPV6_MAX_DEPTH - i) / CHAR_BIT;
+		if (j < RTE_IPV6_ADDR_SIZE) {
+			ip_arr[i].a[j] |= UINT8_MAX >> ((RTE_IPV6_MAX_DEPTH - i) % CHAR_BIT);
+			for (j++; j < RTE_IPV6_ADDR_SIZE; j++)
 				ip_arr[i].a[j] = 0xff;
 		}
 	}
@@ -290,7 +290,7 @@ check_fib(struct rte_fib6 *fib)
 	ret = lookup_and_check_desc(fib, ip_arr, &ip_missing, def_nh, 0);
 	RTE_TEST_ASSERT(ret == TEST_SUCCESS, "Lookup and check fails\n");
 
-	for (i = 1; i <= RTE_FIB6_MAXDEPTH; i++) {
+	for (i = 1; i <= RTE_IPV6_MAX_DEPTH; i++) {
 		ret = rte_fib6_add(fib, &ip_add, i, i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to add a route\n");
 		ret = lookup_and_check_asc(fib, ip_arr, &ip_missing, def_nh, i);
@@ -298,7 +298,7 @@ check_fib(struct rte_fib6 *fib)
 			"Lookup and check fails\n");
 	}
 
-	for (i = RTE_FIB6_MAXDEPTH; i > 1; i--) {
+	for (i = RTE_IPV6_MAX_DEPTH; i > 1; i--) {
 		ret = rte_fib6_delete(fib, &ip_add, i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to delete a route\n");
 		ret = lookup_and_check_asc(fib, ip_arr, &ip_missing,
@@ -313,9 +313,9 @@ check_fib(struct rte_fib6 *fib)
 	RTE_TEST_ASSERT(ret == TEST_SUCCESS,
 		"Lookup and check fails\n");
 
-	for (i = 0; i < RTE_FIB6_MAXDEPTH; i++) {
-		ret = rte_fib6_add(fib, &ip_add, RTE_FIB6_MAXDEPTH - i,
-			RTE_FIB6_MAXDEPTH - i);
+	for (i = 0; i < RTE_IPV6_MAX_DEPTH; i++) {
+		ret = rte_fib6_add(fib, &ip_add, RTE_IPV6_MAX_DEPTH - i,
+			RTE_IPV6_MAX_DEPTH - i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to add a route\n");
 		ret = lookup_and_check_desc(fib, ip_arr, &ip_missing,
 			def_nh, i + 1);
@@ -323,11 +323,11 @@ check_fib(struct rte_fib6 *fib)
 			"Lookup and check fails\n");
 	}
 
-	for (i = 1; i <= RTE_FIB6_MAXDEPTH; i++) {
+	for (i = 1; i <= RTE_IPV6_MAX_DEPTH; i++) {
 		ret = rte_fib6_delete(fib, &ip_add, i);
 		RTE_TEST_ASSERT(ret == 0, "Failed to delete a route\n");
 		ret = lookup_and_check_desc(fib, ip_arr, &ip_missing, def_nh,
-			RTE_FIB6_MAXDEPTH - i);
+			RTE_IPV6_MAX_DEPTH - i);
 		RTE_TEST_ASSERT(ret == TEST_SUCCESS,
 			"Lookup and check fails\n");
 	}
examples/l3fwd-graph/main.c +2 -2
index a13dc011380d..9bda0ab633e1 100644
@@ -151,7 +151,7 @@ struct ipv4_l3fwd_lpm_route {
 };
 
 struct ipv6_l3fwd_lpm_route {
-	uint8_t ip[RTE_LPM6_IPV6_ADDR_SIZE];
+	uint8_t ip[RTE_IPV6_ADDR_SIZE];
 	uint8_t depth;
 	uint8_t if_out;
 };
@@ -1371,7 +1371,7 @@ main(int argc, char **argv)
 
 		dst_port = ipv6_l3fwd_lpm_route_array[i].if_out;
 
-		memcpy(in6.s6_addr, ipv6_l3fwd_lpm_route_array[i].ip, RTE_LPM6_IPV6_ADDR_SIZE);
+		memcpy(in6.s6_addr, ipv6_l3fwd_lpm_route_array[i].ip, RTE_IPV6_ADDR_SIZE);
 		snprintf(route_str, sizeof(route_str), "%s / %d (%d)",
 			 inet_ntop(AF_INET6, &in6, abuf, sizeof(abuf)),
 			 ipv6_l3fwd_lpm_route_array[i].depth,
lib/fib/rte_fib6.c +3 -3
index d95cac79cbb5..9c7d4fde433a 100644
@@ -71,7 +71,7 @@ dummy_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth, uint64_t next_hop, int op)
 {
 	struct rte_rib6_node *node;
-	if ((fib == NULL) || (depth > RTE_FIB6_MAXDEPTH))
+	if ((fib == NULL) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	node = rte_rib6_lookup_exact(fib->rib, ip, depth);
@@ -123,7 +123,7 @@ rte_fib6_add(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth, uint64_t next_hop)
 {
 	if ((fib == NULL) || (ip == NULL) || (fib->modify == NULL) ||
-			(depth > RTE_FIB6_MAXDEPTH))
+			(depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 	return fib->modify(fib, ip, depth, next_hop, RTE_FIB6_ADD);
 }
@@ -133,7 +133,7 @@ rte_fib6_delete(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth)
 {
 	if ((fib == NULL) || (ip == NULL) || (fib->modify == NULL) ||
-			(depth > RTE_FIB6_MAXDEPTH))
+			(depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 	return fib->modify(fib, ip, depth, 0, RTE_FIB6_DEL);
 }
lib/fib/rte_fib6.h +3 -2
index d26a0c7c0b77..21f0492374d9 100644
@@ -17,15 +17,16 @@
 
 #include <stdint.h>
 
+#include <rte_common.h>
 #include <rte_ip6.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define RTE_FIB6_IPV6_ADDR_SIZE		16
+#define RTE_FIB6_IPV6_ADDR_SIZE (RTE_DEPRECATED(RTE_FIB6_IPV6_ADDR_SIZE) RTE_IPV6_ADDR_SIZE)
 /** Maximum depth value possible for IPv6 FIB. */
-#define RTE_FIB6_MAXDEPTH       128
+#define RTE_FIB6_MAXDEPTH (RTE_DEPRECATED(RTE_FIB6_MAXDEPTH) RTE_IPV6_MAX_DEPTH)
 
 struct rte_fib6;
 struct rte_rib6;
lib/fib/trie.c +3 -3
index b0d80c3db815..ee9c2395414d 100644
@@ -350,9 +350,9 @@ write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop,
 	return ret;
 }
 
-#define IPV6_MAX_IDX	(RTE_FIB6_IPV6_ADDR_SIZE - 1)
+#define IPV6_MAX_IDX	(RTE_IPV6_ADDR_SIZE - 1)
 #define TBL24_BYTES	3
-#define TBL8_LEN	(RTE_FIB6_IPV6_ADDR_SIZE - TBL24_BYTES)
+#define TBL8_LEN	(RTE_IPV6_ADDR_SIZE - TBL24_BYTES)
 
 static int
 install_to_dp(struct rte_trie_tbl *dp, const struct rte_ipv6_addr *ledge,
@@ -518,7 +518,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint64_t par_nh, node_nh;
 	uint8_t tmp_depth, depth_diff = 0, parent_depth = 24;
 
-	if ((fib == NULL) || (ip == NULL) || (depth > RTE_FIB6_MAXDEPTH))
+	if ((fib == NULL) || (ip == NULL) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	dp = rte_fib6_get_dp(fib);
lib/fib/trie.h +2 -1
index 6e235edaf89c..6004ec49ce7c 100644
@@ -8,6 +8,7 @@
 
 #include <stdalign.h>
 
+#include <rte_common.h>
 #include <rte_fib6.h>
 
 /**
@@ -18,7 +19,7 @@
 /* @internal Total number of tbl24 entries. */
 #define TRIE_TBL24_NUM_ENT	(1 << 24)
 /* Maximum depth value possible for IPv6 LPM. */
-#define TRIE_MAX_DEPTH		128
+#define TRIE_MAX_DEPTH (RTE_DEPRECATED(TRIE_MAX_DEPTH) RTE_IPV6_MAX_DEPTH)
 /* @internal Number of entries in a tbl8 group. */
 #define TRIE_TBL8_GRP_NUM_ENT	256ULL
 /* @internal Total number of tbl8 groups in the tbl8. */
lib/lpm/rte_lpm6.c +5 -5
index 1d5577f263b1..8beb394c4701 100644
@@ -802,7 +802,7 @@ simulate_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *masked_ip, uint8_
 	 * Inspect one by one the rest of the bytes until
 	 * the process is completed.
 	 */
-	for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && ret == 1; i++) {
+	for (i = ADD_FIRST_BYTE; i < RTE_IPV6_ADDR_SIZE && ret == 1; i++) {
 		tbl = tbl_next;
 		ret = simulate_add_step(lpm, tbl, &tbl_next, masked_ip, 1,
 			(uint8_t)(i + 1), depth, &need_tbl_nb);
@@ -832,7 +832,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t depth
 	int i;
 
 	/* Check user arguments. */
-	if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
+	if ((lpm == NULL) || (depth < 1) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
@@ -861,7 +861,7 @@ rte_lpm6_add(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t depth
 	 * Inspect one by one the rest of the bytes until
 	 * the process is completed.
 	 */
-	for (i = ADD_FIRST_BYTE; i < RTE_LPM6_IPV6_ADDR_SIZE && status == 1; i++) {
+	for (i = ADD_FIRST_BYTE; i < RTE_IPV6_ADDR_SIZE && status == 1; i++) {
 		tbl = tbl_next;
 		status = add_step(lpm, tbl, tbl_next_num, &tbl_next,
 			&tbl_next_num, &masked_ip, 1, (uint8_t)(i + 1),
@@ -993,7 +993,7 @@ rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, u
 
 	/* Check user arguments. */
 	if ((lpm == NULL) || next_hop == NULL || ip == NULL ||
-			(depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
+			(depth < 1) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
@@ -1268,7 +1268,7 @@ rte_lpm6_delete(struct rte_lpm6 *lpm, const struct rte_ipv6_addr *ip, uint8_t de
 	struct rte_lpm6_tbl_entry *from, *to;
 
 	/* Check input arguments. */
-	if ((lpm == NULL) || (depth < 1) || (depth > RTE_LPM6_MAX_DEPTH))
+	if ((lpm == NULL) || (depth < 1) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
 	/* Copy the IP and mask it to avoid modifying user's input data. */
lib/lpm/rte_lpm6.h +3 -2
index 87392194237c..d7ebe9245c8e 100644
@@ -9,6 +9,7 @@
  * RTE Longest Prefix Match for IPv6 (LPM6)
  */
 
+#include <rte_common.h>
 #include <rte_ip6.h>
 
 #include <stdint.h>
@@ -18,8 +19,8 @@ extern "C" {
 #endif
 
 
-#define RTE_LPM6_MAX_DEPTH               128
-#define RTE_LPM6_IPV6_ADDR_SIZE           16
+#define RTE_LPM6_MAX_DEPTH (RTE_DEPRECATED(RTE_LPM6_MAX_DEPTH) RTE_IPV6_MAX_DEPTH)
+#define RTE_LPM6_IPV6_ADDR_SIZE (RTE_DEPRECATED(RTE_LPM6_IPV6_ADDR_SIZE) RTE_IPV6_ADDR_SIZE)
 /** Max number of characters in LPM name. */
 #define RTE_LPM6_NAMESIZE                 32
 
lib/node/ip6_lookup.c +1 -1
index f291ef74832b..faaea5085938 100644
@@ -267,7 +267,7 @@ rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop,
 	uint32_t val;
 	int ret;
 
-	memcpy(in6.s6_addr, ip, RTE_LPM6_IPV6_ADDR_SIZE);
+	memcpy(in6.s6_addr, ip, RTE_IPV6_ADDR_SIZE);
 	inet_ntop(AF_INET6, &in6, abuf, sizeof(abuf));
 	/* Embedded next node id into 24 bit next hop */
 	val = ((next_node << 16) | next_hop) & ((1ull << 24) - 1);
lib/rib/rte_rib6.c +5 -6
index 75175c6aaf98..84c47fed6d1f 100644
@@ -20,7 +20,6 @@
 #include "rib_log.h"
 
 #define RTE_RIB_VALID_NODE	1
-#define RIB6_MAXDEPTH		128
 /* Maximum length of a RIB6 name. */
 #define RTE_RIB6_NAMESIZE	64
 
@@ -89,7 +88,7 @@ static inline struct rte_rib6_node *
 get_nxt_node(struct rte_rib6_node *node,
 	const struct rte_ipv6_addr *ip)
 {
-	if (node->depth == RIB6_MAXDEPTH)
+	if (node->depth == RTE_IPV6_MAX_DEPTH)
 		return NULL;
 
 	return (get_dir(ip, node->depth)) ? node->right : node->left;
@@ -158,7 +157,7 @@ rte_rib6_lookup_exact(struct rte_rib6 *rib,
 	struct rte_rib6_node *cur;
 	struct rte_ipv6_addr tmp_ip;
 
-	if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
+	if (unlikely(rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -196,7 +195,7 @@ rte_rib6_get_nxt(struct rte_rib6 *rib,
 	struct rte_rib6_node *tmp, *prev = NULL;
 	struct rte_ipv6_addr tmp_ip;
 
-	if (unlikely(rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH)) {
+	if (unlikely(rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH)) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -279,7 +278,7 @@ rte_rib6_insert(struct rte_rib6 *rib,
 	int i, d;
 	uint8_t common_depth, ip_xor;
 
-	if (unlikely((rib == NULL || ip == NULL || depth > RIB6_MAXDEPTH))) {
+	if (unlikely((rib == NULL || ip == NULL || depth > RTE_IPV6_MAX_DEPTH))) {
 		rte_errno = EINVAL;
 		return NULL;
 	}
@@ -341,7 +340,7 @@ rte_rib6_insert(struct rte_rib6 *rib,
 
 	/* closest node found, new_node should be inserted in the middle */
 	common_depth = RTE_MIN(depth, (*tmp)->depth);
-	for (i = 0, d = 0; i < RTE_RIB6_IPV6_ADDR_SIZE; i++) {
+	for (i = 0, d = 0; i < RTE_IPV6_ADDR_SIZE; i++) {
 		ip_xor = tmp_ip.a[i] ^ (*tmp)->ip.a[i];
 		if (ip_xor == 0)
 			d += 8;
lib/rib/rte_rib6.h +3 -3
index ec62fdafecb6..a60756f798d8 100644
@@ -22,7 +22,7 @@
 extern "C" {
 #endif
 
-#define RTE_RIB6_IPV6_ADDR_SIZE	16
+#define RTE_RIB6_IPV6_ADDR_SIZE (RTE_DEPRECATED(RTE_RIB6_IPV6_ADDR_SIZE) RTE_IPV6_ADDR_SIZE)
 
 /**
  * rte_rib6_get_nxt() flags
@@ -65,7 +65,7 @@ rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
 {
 	if ((dst == NULL) || (src == NULL))
 		return;
-	rte_memcpy(dst, src, RTE_RIB6_IPV6_ADDR_SIZE);
+	rte_memcpy(dst, src, RTE_IPV6_ADDR_SIZE);
 }
 
 /**
@@ -89,7 +89,7 @@ rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
 
 	if ((ip1 == NULL) || (ip2 == NULL))
 		return 0;
-	for (i = 0; i < RTE_RIB6_IPV6_ADDR_SIZE; i++) {
+	for (i = 0; i < RTE_IPV6_ADDR_SIZE; i++) {
 		if (ip1[i] != ip2[i])
 			return 0;
 	}
Signature · 1 line
2.46.2
#76 lore raw

PATCH v3 9/17 cmdline: replace in6_addr with rte_ipv6_addr

In reply to Robin Jarry

From: Robin Jarry <[email protected]>

The previous commits introduced a new rte_ipv6_addr structure without any alignment requirements. It is not compatible with the in6_addr POSIX type available in netinet/in.h.

The main issue is that in6_addr is not uniform on all platforms which causes unaligned access warnings when compiling without -Wno-address-of-packed-member (set in dpdk by default).

In order to have a consistent code base, replace in6_addr with rte_ipv6_addr in the cmdline library. Update all code accordingly.

---

Notes:
v3: new patch

 app/graph/ethdev.c                     |  4 +--
 app/graph/ip6_route.c                  |  6 ++--
 app/graph/neigh.c                      |  2 +-
 app/test-pmd/cmdline.c                 |  4 +--
 app/test-pmd/cmdline_flow.c            | 14 +++-----
 app/test-pmd/testpmd.h                 | 16 ++++-----
 app/test/test_cmdline_ipaddr.c         | 49 ++++----------------------
 doc/guides/rel_notes/release_24_11.rst |  1 +
 examples/cmdline/commands.c            | 30 +++-------------
 lib/cmdline/cmdline_parse_ipaddr.h     |  3 +-
 10 files changed, 33 insertions(+), 96 deletions(-)
app/graph/ethdev.c +2 -2
index cfc1b1856910..13ed791412e1 100644
@@ -627,10 +627,10 @@ cmd_ethdev_dev_ip6_addr_add_parsed(void *parsed_result, __rte_unused struct cmdl
 	int rc = -EINVAL, i;
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.ip[i] = res->ip.addr.ipv6.s6_addr[i];
+		config.ip[i] = res->ip.addr.ipv6.a[i];
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.mask[i] = res->mask.addr.ipv6.s6_addr[i];
+		config.mask[i] = res->mask.addr.ipv6.a[i];
 
 	rc = ethdev_ip6_addr_add(res->dev, &config);
 	if (rc < 0)
app/graph/ip6_route.c +3 -3
index 834719ecaeb4..d91466cd78d6 100644
@@ -157,13 +157,13 @@ cmd_ipv6_lookup_route_add_ipv6_parsed(void *parsed_result, __rte_unused struct c
 	int rc = -EINVAL, i;
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.ip[i] = res->ip.addr.ipv6.s6_addr[i];
+		config.ip[i] = res->ip.addr.ipv6.a[i];
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.mask[i] = res->mask.addr.ipv6.s6_addr[i];
+		config.mask[i] = res->mask.addr.ipv6.a[i];
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.gateway[i] = res->via_ip.addr.ipv6.s6_addr[i];
+		config.gateway[i] = res->via_ip.addr.ipv6.a[i];
 
 	rc = route_ip6_add(&config);
 	if (rc)
app/graph/neigh.c +1 -1
index 79fd542c8948..eb7a09f1f145 100644
@@ -266,7 +266,7 @@ cmd_neigh_add_ipv6_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
 	uint64_t mac;
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		ip[i] = res->ip.addr.ipv6.s6_addr[i];
+		ip[i] = res->ip.addr.ipv6.a[i];
 
 	if (parser_mac_read(&mac, res->mac)) {
 		printf(MSG_ARG_INVALID, "mac");
app/test-pmd/cmdline.c +1 -3
index b7759e38a871..9de626f20850 100644
@@ -8603,9 +8603,7 @@ do { \
 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
 do { \
 	if ((ip_addr).family == AF_INET6) \
-		rte_memcpy(&(ip), \
-				 &((ip_addr).addr.ipv6), \
-				 sizeof(struct in6_addr)); \
+		ip = ip_addr.addr.ipv6; \
 	else { \
 		fprintf(stderr, "invalid parameter.\n"); \
 		return; \
app/test-pmd/cmdline_flow.c +5 -9
index d04280eb3e46..ff3041b37543 100644
@@ -900,10 +900,8 @@ struct vxlan_encap_conf vxlan_encap_conf = {
 	.udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
 	.ipv4_src = RTE_IPV4(127, 0, 0, 1),
 	.ipv4_dst = RTE_IPV4(255, 255, 255, 255),
-	.ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
-		"\x00\x00\x00\x00\x00\x00\x00\x01",
-	.ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
-		"\x00\x00\x00\x00\x00\x00\x11\x11",
+	.ipv6_src = RTE_IPV6_ADDR_LOOPBACK,
+	.ipv6_dst = RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0x1111),
 	.vlan_tci = 0,
 	.ip_tos = 0,
 	.ip_ttl = 255,
@@ -934,10 +932,8 @@ struct nvgre_encap_conf nvgre_encap_conf = {
 	.tni = "\x00\x00\x00",
 	.ipv4_src = RTE_IPV4(127, 0, 0, 1),
 	.ipv4_dst = RTE_IPV4(255, 255, 255, 255),
-	.ipv6_src = "\x00\x00\x00\x00\x00\x00\x00\x00"
-		"\x00\x00\x00\x00\x00\x00\x00\x01",
-	.ipv6_dst = "\x00\x00\x00\x00\x00\x00\x00\x00"
-		"\x00\x00\x00\x00\x00\x00\x11\x11",
+	.ipv6_src = RTE_IPV6_ADDR_LOOPBACK,
+	.ipv6_dst = RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0x1111),
 	.vlan_tci = 0,
 	.eth_src = "\x00\x00\x00\x00\x00\x00",
 	.eth_dst = "\xff\xff\xff\xff\xff\xff",
@@ -11890,7 +11886,7 @@ parse_ipv6_addr(struct context *ctx, const struct token *token,
 {
 	const struct arg *arg = pop_args(ctx);
 	char str2[len + 1];
-	struct in6_addr tmp;
+	struct rte_ipv6_addr tmp;
 	int ret;
 
 	(void)token;
app/test-pmd/testpmd.h +8 -8
index 9facd7f281d9..2751c441112b 100644
@@ -712,8 +712,8 @@ struct vxlan_encap_conf {
 	rte_be16_t udp_dst;
 	rte_be32_t ipv4_src;
 	rte_be32_t ipv4_dst;
-	uint8_t ipv6_src[16];
-	uint8_t ipv6_dst[16];
+	struct rte_ipv6_addr ipv6_src;
+	struct rte_ipv6_addr ipv6_dst;
 	rte_be16_t vlan_tci;
 	uint8_t ip_tos;
 	uint8_t ip_ttl;
@@ -730,8 +730,8 @@ struct nvgre_encap_conf {
 	uint8_t tni[3];
 	rte_be32_t ipv4_src;
 	rte_be32_t ipv4_dst;
-	uint8_t ipv6_src[16];
-	uint8_t ipv6_dst[16];
+	struct rte_ipv6_addr ipv6_src;
+	struct rte_ipv6_addr ipv6_dst;
 	rte_be16_t vlan_tci;
 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
@@ -762,8 +762,8 @@ struct mplsogre_encap_conf {
 	uint8_t label[3];
 	rte_be32_t ipv4_src;
 	rte_be32_t ipv4_dst;
-	uint8_t ipv6_src[16];
-	uint8_t ipv6_dst[16];
+	struct rte_ipv6_addr ipv6_src;
+	struct rte_ipv6_addr ipv6_dst;
 	rte_be16_t vlan_tci;
 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
@@ -786,8 +786,8 @@ struct mplsoudp_encap_conf {
 	rte_be16_t udp_dst;
 	rte_be32_t ipv4_src;
 	rte_be32_t ipv4_dst;
-	uint8_t ipv6_src[16];
-	uint8_t ipv6_dst[16];
+	struct rte_ipv6_addr ipv6_src;
+	struct rte_ipv6_addr ipv6_dst;
 	rte_be16_t vlan_tci;
 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
app/test/test_cmdline_ipaddr.c +6 -43

87 lines not on this page · raw message

doc/guides/rel_notes/release_24_11.rst +1 -0
index dc8926a6078e..f5a2ac3cfb4f 100644
@@ -145,6 +145,7 @@ API Changes
 * net: IPv6 related symbols were moved from ``<rte_ip.h>`` to the new ``<rte_ip6.h>`` header.
 * net: The ``rte_ipv6_hdr`` structure was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
 * rib6,fib6,lpm6: All public API functions were modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` parameters.
+* cmdline: ``cmdline_ipaddr_t`` was modified to use ``struct rte_ipv6_addr`` instead of ``in6_addr``.
 
 ABI Changes
 -----------
examples/cmdline/commands.c +4 -26
index aec151d08987..09a42a9917cb 100644
@@ -33,28 +33,6 @@ struct object_list global_obj_list;
 	(unsigned)((unsigned char *)&addr)[3]
 #endif
 
-#ifndef NIP6
-#define NIP6_FMT "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x"
-#define NIP6(addr)					\
-	(unsigned)((addr).s6_addr[0]),			\
-	(unsigned)((addr).s6_addr[1]),			\
-	(unsigned)((addr).s6_addr[2]),			\
-	(unsigned)((addr).s6_addr[3]),			\
-	(unsigned)((addr).s6_addr[4]),			\
-	(unsigned)((addr).s6_addr[5]),			\
-	(unsigned)((addr).s6_addr[6]),			\
-	(unsigned)((addr).s6_addr[7]),			\
-	(unsigned)((addr).s6_addr[8]),			\
-	(unsigned)((addr).s6_addr[9]),			\
-	(unsigned)((addr).s6_addr[10]),			\
-	(unsigned)((addr).s6_addr[11]),			\
-	(unsigned)((addr).s6_addr[12]),			\
-	(unsigned)((addr).s6_addr[13]),			\
-	(unsigned)((addr).s6_addr[14]),			\
-	(unsigned)((addr).s6_addr[15])
-#endif
-
-
 /**********************************************************/
 
 /* Show or delete tokens. 8< */
@@ -74,8 +52,8 @@ static void cmd_obj_del_show_parsed(void *parsed_result,
 		snprintf(ip_str, sizeof(ip_str), NIPQUAD_FMT,
 			 NIPQUAD(res->obj->ip.addr.ipv4));
 	else
-		snprintf(ip_str, sizeof(ip_str), NIP6_FMT,
-			 NIP6(res->obj->ip.addr.ipv6));
+		snprintf(ip_str, sizeof(ip_str), RTE_IPV6_ADDR_FMT,
+			 RTE_IPV6_ADDR_SPLIT(&res->obj->ip.addr.ipv6));
 
 	if (strcmp(res->action, "del") == 0) {
 		SLIST_REMOVE(&global_obj_list, res->obj, object, next);
@@ -145,8 +123,8 @@ static void cmd_obj_add_parsed(void *parsed_result,
 		snprintf(ip_str, sizeof(ip_str), NIPQUAD_FMT,
 			 NIPQUAD(o->ip.addr.ipv4));
 	else
-		snprintf(ip_str, sizeof(ip_str), NIP6_FMT,
-			 NIP6(o->ip.addr.ipv6));
+		snprintf(ip_str, sizeof(ip_str), RTE_IPV6_ADDR_FMT,
+			 RTE_IPV6_ADDR_SPLIT(&o->ip.addr.ipv6));
 
 	cmdline_printf(cl, "Object %s added, ip=%s\n",
 		       o->name, ip_str);
lib/cmdline/cmdline_parse_ipaddr.h +2 -1
index 0118c31d4484..8653de8237fc 100644
@@ -9,6 +9,7 @@
 
 #include <cmdline_parse.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -22,7 +23,7 @@ struct cmdline_ipaddr {
 	uint8_t family;
 	union {
 		struct in_addr ipv4;
-		struct in6_addr ipv6;
+		struct rte_ipv6_addr ipv6;
 	} addr;
 	unsigned int prefixlen; /* in case of network only */
 };
Signature · 1 line
2.46.2
#77 lore raw

PATCH v3 10/17 graph,node: use struct rte_ipv6_addr and utils

In reply to Robin Jarry

Replace ad-hoc uint8_t[16] arrays with rte_ipv6_addr structures. Replace duplicated code with utils from rte_ip6.h.

---

Notes:
v3:

- replace *memcpy() with direct struct assignments
- replace string initializers with RTE_IPV6()
- replace in6_addr with rte_ipv6_addr now that libcmdline uses it as well

 app/graph/ethdev.c                     | 44 +++++++---------------
 app/graph/ethdev.h                     |  9 ++---
 app/graph/ip6_route.c                  | 51 +++++++-------------------
 app/graph/meson.build                  |  2 +-
 app/graph/neigh.c                      | 21 ++++-------
 app/graph/neigh_priv.h                 |  4 +-
 app/graph/route.h                      |  8 ++--
 doc/guides/rel_notes/deprecation.rst   |  2 -
 doc/guides/rel_notes/release_24_11.rst |  1 +
 examples/l3fwd-graph/main.c            | 33 ++++++-----------
 lib/node/ip6_lookup.c                  |  9 ++---
 lib/node/rte_node_ip6_api.h            |  3 +-
 12 files changed, 65 insertions(+), 122 deletions(-)
app/graph/ethdev.c +14 -30
index 13ed791412e1..b890efecb52a 100644
@@ -124,30 +124,19 @@ ethdev_portid_by_ip4(uint32_t ip, uint32_t mask)
 }
 
 int16_t
-ethdev_portid_by_ip6(uint8_t *ip, uint8_t *mask)
+ethdev_portid_by_ip6(struct rte_ipv6_addr *ip, struct rte_ipv6_addr *mask)
 {
-	int portid = -EINVAL;
 	struct ethdev *port;
-	int j;
 
 	TAILQ_FOREACH(port, &eth_node, next) {
-		for (j = 0; j < ETHDEV_IPV6_ADDR_LEN; j++) {
-			if (mask == NULL) {
-				if ((port->ip6_addr.ip[j] & port->ip6_addr.mask[j]) !=
-				    (ip[j] & port->ip6_addr.mask[j]))
-					break;
-
-			} else {
-				if ((port->ip6_addr.ip[j] & port->ip6_addr.mask[j]) !=
-				    (ip[j] & mask[j]))
-					break;
-			}
-		}
-		if (j == ETHDEV_IPV6_ADDR_LEN)
+		uint8_t depth = rte_ipv6_mask_depth(&port->ip6_addr.mask);
+		if (mask != NULL)
+			depth = RTE_MAX(depth, rte_ipv6_mask_depth(mask));
+		if (rte_ipv6_addr_eq_prefix(&port->ip6_addr.ip, ip, depth))
 			return port->config.port_id;
 	}
 
-	return portid;
+	return -EINVAL;
 }
 
 void
@@ -285,7 +274,7 @@ ethdev_ip6_addr_add(const char *name, struct ipv6_addr_config *config)
 {
 	struct ethdev *eth_hdl;
 	uint16_t portid = 0;
-	int rc, i;
+	int rc;
 
 	rc = rte_eth_dev_get_port_by_name(name, &portid);
 	if (rc < 0)
@@ -294,10 +283,8 @@ ethdev_ip6_addr_add(const char *name, struct ipv6_addr_config *config)
 	eth_hdl = ethdev_port_by_id(portid);
 
 	if (eth_hdl) {
-		for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) {
-			eth_hdl->ip6_addr.ip[i] = config->ip[i];
-			eth_hdl->ip6_addr.mask[i] = config->mask[i];
-		}
+		eth_hdl->ip6_addr.ip = config->ip;
+		eth_hdl->ip6_addr.mask = config->mask;
 		return 0;
 	}
 	rc = -EINVAL;
@@ -623,14 +610,11 @@ cmd_ethdev_dev_ip6_addr_add_parsed(void *parsed_result, __rte_unused struct cmdl
 				   void *data __rte_unused)
 {
 	struct cmd_ethdev_dev_ip6_addr_add_result *res = parsed_result;
-	struct ipv6_addr_config config;
-	int rc = -EINVAL, i;
-
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.ip[i] = res->ip.addr.ipv6.a[i];
-
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.mask[i] = res->mask.addr.ipv6.a[i];
+	struct ipv6_addr_config config = {
+		.ip = res->ip.addr.ipv6,
+		.mask = res->mask.addr.ipv6,
+	};
+	int rc;
 
 	rc = ethdev_ip6_addr_add(res->dev, &config);
 	if (rc < 0)
app/graph/ethdev.h +4 -5
index d0de593fc743..046689ee5fc7 100644
@@ -6,8 +6,7 @@
 #define APP_GRAPH_ETHDEV_H
 
 #include <cmdline_parse.h>
-
-#define ETHDEV_IPV6_ADDR_LEN	16
+#include <rte_ip6.h>
 
 struct ipv4_addr_config {
 	uint32_t ip;
@@ -15,8 +14,8 @@ struct ipv4_addr_config {
 };
 
 struct ipv6_addr_config {
-	uint8_t ip[ETHDEV_IPV6_ADDR_LEN];
-	uint8_t mask[ETHDEV_IPV6_ADDR_LEN];
+	struct rte_ipv6_addr ip;
+	struct rte_ipv6_addr mask;
 };
 
 extern uint32_t enabled_port_mask;
@@ -25,7 +24,7 @@ void ethdev_start(void);
 void ethdev_stop(void);
 void *ethdev_mempool_list_by_portid(uint16_t portid);
 int16_t ethdev_portid_by_ip4(uint32_t ip, uint32_t mask);
-int16_t ethdev_portid_by_ip6(uint8_t *ip, uint8_t *mask);
+int16_t ethdev_portid_by_ip6(struct rte_ipv6_addr *ip, struct rte_ipv6_addr *mask);
 int16_t ethdev_txport_by_rxport_get(uint16_t portid_rx);
 void ethdev_list_clean(void);
 
app/graph/ip6_route.c +13 -38

92 lines not on this page · raw message

app/graph/meson.build +1 -1
index 6dc54d5ee63f..344e4a418fc0 100644
@@ -9,7 +9,7 @@ if not build
     subdir_done()
 endif
 
-deps += ['graph', 'eal', 'lpm', 'ethdev', 'node', 'cmdline']
+deps += ['graph', 'eal', 'lpm', 'ethdev', 'node', 'cmdline', 'net']
 sources = files(
         'cli.c',
         'conn.c',
app/graph/neigh.c +7 -14
index eb7a09f1f145..3298f63c1a84 100644
@@ -62,12 +62,12 @@ find_neigh4_entry(uint32_t ip, uint64_t mac)
 }
 
 static struct neigh_ipv6_config *
-find_neigh6_entry(uint8_t *ip, uint64_t mac)
+find_neigh6_entry(struct rte_ipv6_addr *ip, uint64_t mac)
 {
 	struct neigh_ipv6_config *v6_config;
 
 	TAILQ_FOREACH(v6_config, &neigh6, next) {
-		if (!(memcmp(v6_config->ip, ip, 16)) && (v6_config->mac == mac))
+		if (rte_ipv6_addr_eq(&v6_config->ip, ip) && v6_config->mac == mac)
 			return v6_config;
 	}
 	return NULL;
@@ -82,7 +82,7 @@ ip6_rewrite_node_add(struct neigh_ipv6_config *v6_config)
 	int16_t portid = 0;
 	int rc;
 
-	portid = ethdev_portid_by_ip6(v6_config->ip, NULL);
+	portid = ethdev_portid_by_ip6(&v6_config->ip, NULL);
 	if (portid < 0) {
 		printf("Invalid portid found to add neigh\n");
 		return -EINVAL;
@@ -170,11 +170,10 @@ neigh_ip4_add(uint32_t ip, uint64_t mac)
 }
 
 static int
-neigh_ip6_add(uint8_t *ip, uint64_t mac)
+neigh_ip6_add(struct rte_ipv6_addr *ip, uint64_t mac)
 {
 	struct neigh_ipv6_config *v6_config;
 	int rc = -EINVAL;
-	int j;
 
 	v6_config = find_neigh6_entry(ip, mac);
 
@@ -184,9 +183,7 @@ neigh_ip6_add(uint8_t *ip, uint64_t mac)
 			return -ENOMEM;
 	}
 
-	for (j = 0; j < ETHDEV_IPV6_ADDR_LEN; j++)
-		v6_config->ip[j] = ip[j];
-
+	v6_config->ip = *ip;
 	v6_config->mac = mac;
 	v6_config->is_used = true;
 
@@ -261,19 +258,15 @@ cmd_neigh_add_ipv6_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
 			  void *data __rte_unused)
 {
 	struct cmd_neigh_add_ipv6_result *res = parsed_result;
-	uint8_t ip[ETHDEV_IPV6_ADDR_LEN];
-	int rc = -EINVAL, i;
+	int rc = -EINVAL;
 	uint64_t mac;
 
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		ip[i] = res->ip.addr.ipv6.a[i];
-
 	if (parser_mac_read(&mac, res->mac)) {
 		printf(MSG_ARG_INVALID, "mac");
 		return;
 	}
 
-	rc = neigh_ip6_add(ip, mac);
+	rc = neigh_ip6_add(&res->ip.addr.ipv6, mac);
 	if (rc < 0)
 		printf(MSG_CMD_FAIL, res->neigh);
 }
app/graph/neigh_priv.h +3 -1
index 1a7106c309bc..b2a7607e01bb 100644
@@ -5,6 +5,8 @@
 #ifndef APP_GRAPH_NEIGH_PRIV_H
 #define APP_GRAPH_NEIGH_PRIV_H
 
+#include <rte_ip6.h>
+
 #define MAX_NEIGH_ENTRIES 32
 
 struct neigh_ipv4_config {
@@ -18,7 +20,7 @@ TAILQ_HEAD(neigh4_head, neigh_ipv4_config);
 
 struct neigh_ipv6_config {
 	TAILQ_ENTRY(neigh_ipv6_config) next;
-	uint8_t ip[16];
+	struct rte_ipv6_addr ip;
 	uint64_t mac;
 	bool is_used;
 };
app/graph/route.h +5 -3
index 23a7951d2dad..455aab8634d4 100644
@@ -5,6 +5,8 @@
 #ifndef APP_GRAPH_ROUTE_H
 #define APP_GRAPH_ROUTE_H
 
+#include <rte_ip6.h>
+
 #define MAX_ROUTE_ENTRIES 32
 
 struct route_ipv4_config {
@@ -19,9 +21,9 @@ TAILQ_HEAD(ip4_route, route_ipv4_config);
 
 struct route_ipv6_config {
 	TAILQ_ENTRY(route_ipv6_config) next;
-	uint8_t ip[16];
-	uint8_t mask[16];
-	uint8_t gateway[16];
+	struct rte_ipv6_addr ip;
+	struct rte_ipv6_addr mask;
+	struct rte_ipv6_addr gateway;
 	bool is_used;
 };
 
doc/guides/rel_notes/deprecation.rst +0 -2
index ee958c689b3a..c268c497834c 100644
@@ -76,8 +76,6 @@ Deprecation Notices
     - ``struct rte_ipv6_tuple``
   ipsec
     - ``struct rte_ipsec_sadv6_key``
-  node
-    - ``rte_node_ip6_route_add()``
   pipeline
     - ``struct rte_table_action_ipv6_header``
 
doc/guides/rel_notes/release_24_11.rst +1 -0
index f5a2ac3cfb4f..4b2f6627b0d0 100644
@@ -146,6 +146,7 @@ API Changes
 * net: The ``rte_ipv6_hdr`` structure was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
 * rib6,fib6,lpm6: All public API functions were modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` parameters.
 * cmdline: ``cmdline_ipaddr_t`` was modified to use ``struct rte_ipv6_addr`` instead of ``in6_addr``.
+* node: ``rte_node_ip6_route_add()`` was modified to use a ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` parameter.
 
 ABI Changes
 -----------
examples/l3fwd-graph/main.c +12 -21
index 9bda0ab633e1..7fabd5b8d5cd 100644
@@ -151,7 +151,7 @@ struct ipv4_l3fwd_lpm_route {
 };
 
 struct ipv6_l3fwd_lpm_route {
-	uint8_t ip[RTE_IPV6_ADDR_SIZE];
+	struct rte_ipv6_addr ip;
 	uint8_t depth;
 	uint8_t if_out;
 };
@@ -170,23 +170,16 @@ static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = {
 #define IPV6_L3FWD_LPM_NUM_ROUTES                                              \
 	(sizeof(ipv6_l3fwd_lpm_route_array) /                                  \
 	 sizeof(ipv6_l3fwd_lpm_route_array[0]))
+
 static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = {
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00}, 48, 0},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x01}, 48, 1},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x02}, 48, 2},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x03}, 48, 3},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x04}, 48, 4},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x05}, 48, 5},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x06}, 48, 6},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x02}, 48, 7},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 0), 48, 0},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 1), 48, 1},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 2), 48, 2},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 3), 48, 3},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 4), 48, 4},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 5), 48, 5},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 6), 48, 6},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 2), 48, 7},
 };
 
 static int
@@ -1361,7 +1354,6 @@ main(int argc, char **argv)
 	for (i = 0; i < IPV6_L3FWD_LPM_NUM_ROUTES; i++) {
 		char route_str[INET6_ADDRSTRLEN * 4];
 		char abuf[INET6_ADDRSTRLEN];
-		struct in6_addr in6;
 		uint32_t dst_port;
 
 		/* Skip unused ports */
@@ -1371,14 +1363,13 @@ main(int argc, char **argv)
 
 		dst_port = ipv6_l3fwd_lpm_route_array[i].if_out;
 
-		memcpy(in6.s6_addr, ipv6_l3fwd_lpm_route_array[i].ip, RTE_IPV6_ADDR_SIZE);
 		snprintf(route_str, sizeof(route_str), "%s / %d (%d)",
-			 inet_ntop(AF_INET6, &in6, abuf, sizeof(abuf)),
+			 inet_ntop(AF_INET6, &ipv6_l3fwd_lpm_route_array[i].ip, abuf, sizeof(abuf)),
 			 ipv6_l3fwd_lpm_route_array[i].depth,
 			 ipv6_l3fwd_lpm_route_array[i].if_out);
 
 		/* Use route index 'i' as next hop id */
-		ret = rte_node_ip6_route_add(ipv6_l3fwd_lpm_route_array[i].ip,
+		ret = rte_node_ip6_route_add(&ipv6_l3fwd_lpm_route_array[i].ip,
 			ipv6_l3fwd_lpm_route_array[i].depth, i,
 			RTE_NODE_IP6_LOOKUP_NEXT_REWRITE);
 
lib/node/ip6_lookup.c +3 -6
index faaea5085938..f378d2d0646d 100644
@@ -258,17 +258,15 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 }
 
 int
-rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop,
+rte_node_ip6_route_add(const struct rte_ipv6_addr *ip, uint8_t depth, uint16_t next_hop,
 		       enum rte_node_ip6_lookup_next next_node)
 {
 	char abuf[INET6_ADDRSTRLEN];
-	struct in6_addr in6;
 	uint8_t socket;
 	uint32_t val;
 	int ret;
 
-	memcpy(in6.s6_addr, ip, RTE_IPV6_ADDR_SIZE);
-	inet_ntop(AF_INET6, &in6, abuf, sizeof(abuf));
+	inet_ntop(AF_INET6, ip, abuf, sizeof(abuf));
 	/* Embedded next node id into 24 bit next hop */
 	val = ((next_node << 16) | next_hop) & ((1ull << 24) - 1);
 	node_dbg("ip6_lookup", "LPM: Adding route %s / %d nh (0x%x)", abuf,
@@ -278,8 +276,7 @@ rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop,
 		if (!ip6_lookup_nm.lpm_tbl[socket])
 			continue;
 
-		ret = rte_lpm6_add(ip6_lookup_nm.lpm_tbl[socket],
-				   (const struct rte_ipv6_addr *)ip, depth, val);
+		ret = rte_lpm6_add(ip6_lookup_nm.lpm_tbl[socket], ip, depth, val);
 		if (ret < 0) {
 			node_err("ip6_lookup",
 				 "Unable to add entry %s / %d nh (%x) to LPM "
lib/node/rte_node_ip6_api.h +2 -1
index f467aac7b6db..2875bc981a47 100644
@@ -17,6 +17,7 @@
  */
 #include <rte_common.h>
 #include <rte_compat.h>
+#include <rte_ip6.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -48,7 +49,7 @@ enum rte_node_ip6_lookup_next {
  *   0 on success, negative otherwise.
  */
 __rte_experimental
-int rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop,
+int rte_node_ip6_route_add(const struct rte_ipv6_addr *ip, uint8_t depth, uint16_t next_hop,
 			   enum rte_node_ip6_lookup_next next_node);
 
 /**
Signature · 1 line
2.46.2
#78 lore raw

PATCH v3 11/17 pipeline: use struct rte_ipv6_addr

In reply to Robin Jarry

Update rte_table_action_ipv6_header and rte_table_action_nat_params to use rte_ipv6_addr structures instead of uint8_t[16] arrays.

---

Notes:
v3:

- replace *memcpy() with direct struct assignments
- replace more uint8_t arrays with rte_ipv6_addr in examples

 doc/guides/rel_notes/deprecation.rst   |  2 -
 doc/guides/rel_notes/release_24_11.rst |  1 +
 examples/ip_pipeline/cli.c             | 61 +++++++++++---------------
 examples/ip_pipeline/parser.c          |  2 +-
 examples/ip_pipeline/parser.h          |  3 +-
 examples/ip_pipeline/pipeline.h        |  6 +--
 examples/ip_pipeline/thread.c          | 15 +++----
 lib/pipeline/rte_table_action.c        | 36 ++++++---------
 lib/pipeline/rte_table_action.h        |  7 +--
 9 files changed, 56 insertions(+), 77 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -2
index c268c497834c..fcccb22593d8 100644
@@ -76,8 +76,6 @@ Deprecation Notices
     - ``struct rte_ipv6_tuple``
   ipsec
     - ``struct rte_ipsec_sadv6_key``
-  pipeline
-    - ``struct rte_table_action_ipv6_header``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +1 -0
index 4b2f6627b0d0..e517b5e5abe2 100644
@@ -147,6 +147,7 @@ API Changes
 * rib6,fib6,lpm6: All public API functions were modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` parameters.
 * cmdline: ``cmdline_ipaddr_t`` was modified to use ``struct rte_ipv6_addr`` instead of ``in6_addr``.
 * node: ``rte_node_ip6_route_add()`` was modified to use a ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` parameter.
+* pipeline: ``rte_table_action_ipv6_header`` and ``rte_table_action_nat_params`` were modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
 
 ABI Changes
 -----------
examples/ip_pipeline/cli.c +26 -35

188 lines not on this page · raw message

examples/ip_pipeline/parser.c +1 -1
index 62fc52f9db78..dfca026be58b 100644
@@ -387,7 +387,7 @@ parse_ipv4_addr(const char *token, struct in_addr *ipv4)
 }
 
 int
-parse_ipv6_addr(const char *token, struct in6_addr *ipv6)
+parse_ipv6_addr(const char *token, struct rte_ipv6_addr *ipv6)
 {
 	if (strlen(token) >= INET6_ADDRSTRLEN)
 		return -EINVAL;
examples/ip_pipeline/parser.h +2 -1
index 32b5ff99764b..758e0032ddc8 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_ether.h>
 
 #define PARSE_DELIMITER				" \f\n\r\t\v"
@@ -39,7 +40,7 @@ int parser_read_uint8_hex(uint8_t *value, const char *p);
 int parse_hex_string(char *src, uint8_t *dst, uint32_t *size);
 
 int parse_ipv4_addr(const char *token, struct in_addr *ipv4);
-int parse_ipv6_addr(const char *token, struct in6_addr *ipv6);
+int parse_ipv6_addr(const char *token, struct rte_ipv6_addr *ipv6);
 int parse_mac_addr(const char *token, struct rte_ether_addr *addr);
 int parse_mpls_labels(char *string, uint32_t *labels, uint32_t *n_labels);
 
examples/ip_pipeline/pipeline.h +3 -3
index 22f04fd752ca..89696480fc01 100644
@@ -218,8 +218,8 @@ struct table_rule_match_acl {
 		} ipv4;
 
 		struct {
-			uint8_t sa[16];
-			uint8_t da[16];
+			struct rte_ipv6_addr sa;
+			struct rte_ipv6_addr da;
 		} ipv6;
 	};
 
@@ -255,7 +255,7 @@ struct table_rule_match_lpm {
 
 	union {
 		uint32_t ipv4;
-		uint8_t ipv6[16];
+		struct rte_ipv6_addr ipv6;
 	};
 
 	uint8_t depth;
examples/ip_pipeline/thread.c +5 -10
index 9d8082b73080..0a44bddd90fc 100644
@@ -2409,10 +2409,8 @@ match_convert(struct table_rule_match *mh,
 			}
 		else
 			if (add) {
-				uint32_t *sa32 =
-					(uint32_t *) mh->match.acl.ipv6.sa;
-				uint32_t *da32 =
-					(uint32_t *) mh->match.acl.ipv6.da;
+				uint32_t *sa32 = (uint32_t *)&mh->match.acl.ipv6.sa;
+				uint32_t *da32 = (uint32_t *)&mh->match.acl.ipv6.da;
 				uint32_t sa32_depth[4], da32_depth[4];
 				int status;
 
@@ -2480,10 +2478,8 @@ match_convert(struct table_rule_match *mh,
 				ml->acl_add.priority =
 					(int32_t) mh->match.acl.priority;
 			} else {
-				uint32_t *sa32 =
-					(uint32_t *) mh->match.acl.ipv6.sa;
-				uint32_t *da32 =
-					(uint32_t *) mh->match.acl.ipv6.da;
+				uint32_t *sa32 = (uint32_t *)&mh->match.acl.ipv6.sa;
+				uint32_t *da32 = (uint32_t *)&mh->match.acl.ipv6.da;
 				uint32_t sa32_depth[4], da32_depth[4];
 				int status;
 
@@ -2563,8 +2559,7 @@ match_convert(struct table_rule_match *mh,
 			ml->lpm_ipv4.ip = mh->match.lpm.ipv4;
 			ml->lpm_ipv4.depth = mh->match.lpm.depth;
 		} else {
-			memcpy(&ml->lpm_ipv6.ip,
-				mh->match.lpm.ipv6, sizeof(ml->lpm_ipv6.ip));
+			ml->lpm_ipv6.ip = mh->match.lpm.ipv6;
 			ml->lpm_ipv6.depth = mh->match.lpm.depth;
 		}
 
lib/pipeline/rte_table_action.c +14 -22
index 89a63f024a1f..60b291bad4b8 100644
@@ -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));
+			d->ipv6.src_addr = p->vxlan.ipv6.sa;
+			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));
+			d->ipv6.src_addr = p->vxlan.ipv6.sa;
+			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));
+		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);
+			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);
+			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);
+			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,
-				(uint16_t *)data->addr,
+				(uint16_t *)&data->addr,
 				udp->dst_port,
 				data->port);
 
-			rte_memcpy(&ip->dst_addr, data->addr, 16);
+			ip->dst_addr = data->addr;
 			udp->dst_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
lib/pipeline/rte_table_action.h +4 -3
index bab4bfd2e23c..47a7bdfc01cc 100644
@@ -56,6 +56,7 @@
 
 #include <rte_compat.h>
 #include <rte_ether.h>
+#include <rte_ip6.h>
 #include <rte_meter.h>
 #include <rte_table_hash.h>
 
@@ -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. */
Signature · 1 line
2.46.2
#79 lore raw

PATCH v3 12/17 ipsec, security: use struct rte_ipv6_addr and utils

In reply to Robin Jarry

Update rte_ipsec_sadv6_key to use rte_ipv6_addr structures instead of ad-hoc uint8_t[16] arrays. Use the ipv6 utils that go along.

Update rte_security_ipsec_tunnel_param to use rte_ipv6_addr instead of in6_addr.

---

Notes:
v3:

- replace *memcpy() with direct struct assignments
- replace ad-hoc array initializers with RTE_IPV6()
- replace in6_addr with rte_ipv6_addr in rte_security
- replace more uint8_t arrays with rte_ipv6_addr in examples

 app/test-sad/main.c                    |  24 ++--
 app/test/test_ipsec_sad.c              |  46 ++++----
 doc/guides/prog_guide/ipsec_lib.rst    |   4 +-
 doc/guides/rel_notes/deprecation.rst   |   2 -
 doc/guides/rel_notes/release_24_11.rst |   3 +
 drivers/common/cnxk/cnxk_security.c    |  14 +--
 drivers/net/iavf/iavf_ipsec_crypto.c   |   3 +-
 drivers/net/nfp/nfp_ipsec.c            |   4 +-
 examples/ipsec-secgw/flow.c            |  20 ++--
 examples/ipsec-secgw/ipsec.c           |  33 ++----
 examples/ipsec-secgw/ipsec.h           |   5 +-
 examples/ipsec-secgw/parser.c          |   2 +-
 examples/ipsec-secgw/parser.h          |   4 +-
 examples/ipsec-secgw/rt.c              |   4 +-
 examples/ipsec-secgw/sa.c              |  37 +++---
 examples/ipsec-secgw/sad.h             |  12 +-
 examples/ipsec-secgw/sp6.c             | 154 ++++++++++++++-----------
 lib/ipsec/rte_ipsec_sad.h              |   5 +-
 lib/pipeline/rte_swx_ipsec.c           |   8 +-
 lib/pipeline/rte_swx_ipsec.h           |   5 +-
 lib/security/rte_security.h            |   5 +-
 21 files changed, 191 insertions(+), 203 deletions(-)
app/test-sad/main.c +10 -14
index addfc0714521..54e3fa0c91e6 100644
@@ -248,8 +248,8 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 						(uint64_t)(edge + step));
 			if (config.ipv6) {
 				for (j = 0; j < 16; j++) {
-					tbl[i].tuple.v6.dip[j] = rte_rand();
-					tbl[i].tuple.v6.sip[j] = rte_rand();
+					tbl[i].tuple.v6.dip.a[j] = rte_rand();
+					tbl[i].tuple.v6.sip.a[j] = rte_rand();
 				}
 			} else {
 				tbl[i].tuple.v4.dip = rte_rand();
@@ -274,9 +274,9 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 					(uint64_t)(edge + step));
 				if (config.ipv6) {
 					for (j = 0; j < 16; j++) {
-						tbl[i].tuple.v6.dip[j] =
+						tbl[i].tuple.v6.dip.a[j] =
 								rte_rand();
-						tbl[i].tuple.v6.sip[j] =
+						tbl[i].tuple.v6.sip.a[j] =
 								rte_rand();
 					}
 				} else {
@@ -289,12 +289,8 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 					config.nb_rules].tuple.v4.spi;
 				if (config.ipv6) {
 					int r_idx = i % config.nb_rules;
-					memcpy(tbl[i].tuple.v6.dip,
-						rules_tbl[r_idx].tuple.v6.dip,
-						sizeof(tbl[i].tuple.v6.dip));
-					memcpy(tbl[i].tuple.v6.sip,
-						rules_tbl[r_idx].tuple.v6.sip,
-						sizeof(tbl[i].tuple.v6.sip));
+					tbl[i].tuple.v6.dip = rules_tbl[r_idx].tuple.v6.dip;
+					tbl[i].tuple.v6.sip = rules_tbl[r_idx].tuple.v6.sip;
 				} else {
 					tbl[i].tuple.v4.dip = rules_tbl[i %
 						config.nb_rules].tuple.v4.dip;
@@ -472,8 +468,8 @@ print_result(const union rte_ipsec_sad_key *key, void *res)
 	v4 = &key->v4;
 	v6 = &key->v6;
 	spi = (config.ipv6 == 0) ? v4->spi : v6->spi;
-	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)v6->dip;
-	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)v6->sip;
+	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)&v6->dip;
+	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)&v6->sip;
 
 	if (res == NULL) {
 		printf("TUPLE: ");
@@ -500,8 +496,8 @@ print_result(const union rte_ipsec_sad_key *key, void *res)
 	v4 = &rule->tuple.v4;
 	v6 = &rule->tuple.v6;
 	spi = (config.ipv6 == 0) ? v4->spi : v6->spi;
-	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)v6->dip;
-	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)v6->sip;
+	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)&v6->dip;
+	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)&v6->sip;
 	printf("\n\tpoints to RULE ID %zu ",
 		RTE_PTR_DIFF(res, rules_tbl)/sizeof(struct rule));
 	print_tuple(af, spi, dip, sip);
app/test/test_ipsec_sad.c +24 -22

82 lines not on this page · raw message

doc/guides/prog_guide/ipsec_lib.rst +2 -2
index 0bdbdad1e4e8..03383651a8a8 100644
@@ -275,8 +275,8 @@ and v6 is a tuple for IPv6:
 
     struct rte_ipsec_sadv6_key {
         uint32_t spi;
-        uint8_t dip[16];
-        uint8_t sip[16];
+        struct rte_ipv6_addr dip;
+        struct rte_ipv6_addr sip;
     };
 
 As an example, lookup related code could look like that:
doc/guides/rel_notes/deprecation.rst +0 -2
index fcccb22593d8..838e22b44444 100644
@@ -74,8 +74,6 @@ Deprecation Notices
     - ``struct tcp6_flow_key``
   hash
     - ``struct rte_ipv6_tuple``
-  ipsec
-    - ``struct rte_ipsec_sadv6_key``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +3 -0
index e517b5e5abe2..3c273ce25c75 100644
@@ -148,6 +148,9 @@ API Changes
 * cmdline: ``cmdline_ipaddr_t`` was modified to use ``struct rte_ipv6_addr`` instead of ``in6_addr``.
 * node: ``rte_node_ip6_route_add()`` was modified to use a ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` parameter.
 * pipeline: ``rte_table_action_ipv6_header`` and ``rte_table_action_nat_params`` were modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
+* pipeline: ``rte_swx_ipsec_sa_encap_params`` was modified to use ``rte_ipv6_addr`` instead of ``in6_addr``.
+* ipsec: ``rte_ipsec_sadv6_key`` was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
+* security: ``rte_security_ipsec_tunnel_param`` was modified to use ``rte_ipv6_addr`` instead of ``in6_addr``.
 
 ABI Changes
 -----------
drivers/common/cnxk/cnxk_security.c +6 -8
index 41987299b6b3..e8037ee9b603 100644
@@ -272,9 +272,9 @@ ot_ipsec_inb_tunnel_hdr_fill(struct roc_ot_ipsec_inb_sa *sa,
 	case RTE_SECURITY_IPSEC_TUNNEL_IPV6:
 		sa->w2.s.outer_ip_ver = ROC_IE_SA_IP_VERSION_6;
 		memcpy(&sa->outer_hdr.ipv6.src_addr, &tunnel->ipv6.src_addr,
-		       sizeof(struct in6_addr));
+		       sizeof(sa->outer_hdr.ipv6.src_addr));
 		memcpy(&sa->outer_hdr.ipv6.dst_addr, &tunnel->ipv6.dst_addr,
-		       sizeof(struct in6_addr));
+		       sizeof(sa->outer_hdr.ipv6.dst_addr));
 
 		/* IP Source and Dest are in LE/CPU endian */
 		ot_ipsec_update_ipv6_addr_endianness((uint64_t *)&sa->outer_hdr.ipv6.src_addr);
@@ -473,9 +473,9 @@ cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa,
 	case RTE_SECURITY_IPSEC_TUNNEL_IPV6:
 		sa->w2.s.outer_ip_ver = ROC_IE_SA_IP_VERSION_6;
 		memcpy(&sa->outer_hdr.ipv6.src_addr, &tunnel->ipv6.src_addr,
-		       sizeof(struct in6_addr));
+		       sizeof(sa->outer_hdr.ipv6.src_addr));
 		memcpy(&sa->outer_hdr.ipv6.dst_addr, &tunnel->ipv6.dst_addr,
-		       sizeof(struct in6_addr));
+		       sizeof(sa->outer_hdr.ipv6.dst_addr));
 
 		/* IP Source and Dest are in LE/CPU endian */
 		ot_ipsec_update_ipv6_addr_endianness((uint64_t *)&sa->outer_hdr.ipv6.src_addr);
@@ -1088,10 +1088,8 @@ cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipsec,
 			ip6->hop_limits = ipsec->tunnel.ipv6.hlimit ?
 						  ipsec->tunnel.ipv6.hlimit :
 						  0x40;
-			memcpy(&ip6->src_addr, &ipsec->tunnel.ipv6.src_addr,
-			       sizeof(struct in6_addr));
-			memcpy(&ip6->dst_addr, &ipsec->tunnel.ipv6.dst_addr,
-			       sizeof(struct in6_addr));
+			ip6->src_addr = ipsec->tunnel.ipv6.src_addr;
+			ip6->dst_addr = ipsec->tunnel.ipv6.dst_addr;
 		}
 	} else
 		ctx_len += sizeof(template->ip4);
drivers/net/iavf/iavf_ipsec_crypto.c +1 -2
index 89dd5af5500f..90421a66c309 100644
@@ -510,8 +510,7 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,
 		*((uint32_t *)sa_cfg->dst_addr)	=
 			htonl(conf->ipsec.tunnel.ipv4.dst_ip.s_addr);
 	} else {
-		uint32_t *v6_dst_addr =
-			(uint32_t *)conf->ipsec.tunnel.ipv6.dst_addr.s6_addr;
+		uint32_t *v6_dst_addr = (uint32_t *)&conf->ipsec.tunnel.ipv6.dst_addr;
 
 		sa_cfg->virtchnl_ip_type = VIRTCHNL_IPV6;
 
drivers/net/nfp/nfp_ipsec.c +2 -2
index 647bc2bb6d7d..2f5b60984edc 100644
@@ -1042,8 +1042,8 @@ nfp_ipsec_msg_build(struct rte_eth_dev *eth_dev,
 			cfg->dst_ip[0] = rte_be_to_cpu_32(dst_ip[0]);
 			cfg->ipv6 = 0;
 		} else if (type == RTE_SECURITY_IPSEC_TUNNEL_IPV6) {
-			src_ip = (rte_be32_t *)conf->ipsec.tunnel.ipv6.src_addr.s6_addr;
-			dst_ip = (rte_be32_t *)conf->ipsec.tunnel.ipv6.dst_addr.s6_addr;
+			src_ip = (rte_be32_t *)&conf->ipsec.tunnel.ipv6.src_addr;
+			dst_ip = (rte_be32_t *)&conf->ipsec.tunnel.ipv6.dst_addr;
 			for (i = 0; i < 4; i++) {
 				cfg->src_ip[i] = rte_be_to_cpu_32(src_ip[i]);
 				cfg->dst_ip[i] = rte_be_to_cpu_32(dst_ip[i]);
examples/ipsec-secgw/flow.c +10 -10
index 3f7630f5fd53..70742387c6be 100644
@@ -88,10 +88,10 @@ ipv6_hdr_print(struct rte_ipv6_hdr *hdr)
 }
 
 static int
-ipv6_addr_cpy(uint8_t *spec, uint8_t *mask, char *token,
+ipv6_addr_cpy(struct rte_ipv6_addr *spec, struct rte_ipv6_addr *mask, char *token,
 	      struct parse_status *status)
 {
-	struct in6_addr ip;
+	struct rte_ipv6_addr ip;
 	uint32_t depth, i;
 
 	APP_CHECK(parse_ipv6_addr(token, &ip, &depth) == 0, status,
@@ -99,11 +99,11 @@ ipv6_addr_cpy(uint8_t *spec, uint8_t *mask, char *token,
 	if (status->status < 0)
 		return -1;
 
-	memcpy(mask, &rte_flow_item_ipv6_mask.hdr.src_addr, sizeof(ip));
-	memcpy(spec, ip.s6_addr, sizeof(struct in6_addr));
+	*mask = rte_flow_item_ipv6_mask.hdr.src_addr;
+	*spec = ip;
 
-	for (i = 0; i < depth && (i%8 <= sizeof(struct in6_addr)); i++)
-		mask[i/8] &= ~(1 << (7-i%8));
+	for (i = 0; i < depth && (i%8 <= sizeof(*mask)); i++)
+		mask->a[i/8] &= ~(1 << (7-i%8));
 
 	return 0;
 }
@@ -175,8 +175,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.src_addr.a,
-						  rule->ipv6.mask.hdr.src_addr.a,
+				if (ipv6_addr_cpy(&rule->ipv6.spec.hdr.src_addr,
+						  &rule->ipv6.mask.hdr.src_addr,
 						  tokens[ti], status))
 					return;
 			}
@@ -184,8 +184,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.dst_addr.a,
-						  rule->ipv6.mask.hdr.dst_addr.a,
+				if (ipv6_addr_cpy(&rule->ipv6.spec.hdr.dst_addr,
+						  &rule->ipv6.mask.hdr.dst_addr,
 						  tokens[ti], status))
 					return;
 			}
examples/ipsec-secgw/ipsec.c +10 -23
index ebde28639c12..c65efd1c166a 100644
@@ -41,12 +41,8 @@ set_ipsec_conf(struct ipsec_sa *sa, struct rte_security_ipsec_xform *ipsec)
 			tunnel->ipv6.hlimit = IPDEFTTL;
 			tunnel->ipv6.dscp = 0;
 			tunnel->ipv6.flabel = 0;
-
-			memcpy((uint8_t *)&tunnel->ipv6.src_addr,
-				(uint8_t *)&sa->src.ip.ip6.ip6_b, 16);
-
-			memcpy((uint8_t *)&tunnel->ipv6.dst_addr,
-				(uint8_t *)&sa->dst.ip.ip6.ip6_b, 16);
+			tunnel->ipv6.src_addr = sa->src.ip.ip6;
+			tunnel->ipv6.dst_addr = sa->dst.ip.ip6;
 		}
 		/* TODO support for Transport */
 	}
@@ -450,10 +446,8 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sess_conf.ipsec.tunnel.type =
 				RTE_SECURITY_IPSEC_TUNNEL_IPV6;
 
-			memcpy(sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr,
-				sa->src.ip.ip6.ip6_b, 16);
-			memcpy(sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr,
-				sa->dst.ip.ip6.ip6_b, 16);
+			sess_conf.ipsec.tunnel.ipv6.src_addr = sa->src.ip.ip6;
+			sess_conf.ipsec.tunnel.ipv6.dst_addr = sa->dst.ip.ip6;
 		}
 	} else if (IS_TUNNEL(sa->flags)) {
 		sess_conf.ipsec.mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL;
@@ -470,10 +464,8 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sess_conf.ipsec.tunnel.type =
 				RTE_SECURITY_IPSEC_TUNNEL_IPV6;
 
-			memcpy(sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr,
-				sa->src.ip.ip6.ip6_b, 16);
-			memcpy(sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr,
-				sa->dst.ip.ip6.ip6_b, 16);
+			sess_conf.ipsec.tunnel.ipv6.src_addr = sa->src.ip.ip6;
+			sess_conf.ipsec.tunnel.ipv6.dst_addr = sa->dst.ip.ip6;
 		} else {
 			RTE_LOG(ERR, IPSEC, "invalid tunnel type\n");
 			return -1;
@@ -528,11 +520,8 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sa->pattern[1].mask = &rte_flow_item_ipv6_mask;
 			sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 			sa->pattern[1].spec = &sa->ipv6_spec;
-
-			memcpy(&sa->ipv6_spec.hdr.dst_addr,
-				sa->dst.ip.ip6.ip6_b, 16);
-			memcpy(&sa->ipv6_spec.hdr.src_addr,
-			       sa->src.ip.ip6.ip6_b, 16);
+			sa->ipv6_spec.hdr.dst_addr = sa->dst.ip.ip6;
+			sa->ipv6_spec.hdr.src_addr = sa->src.ip.ip6;
 		} else if (IS_IP4(sa->flags)) {
 			sa->pattern[1].mask = &rte_flow_item_ipv4_mask;
 			sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV4;
@@ -735,10 +724,8 @@ create_ipsec_esp_flow(struct ipsec_sa *sa)
 		sa->pattern[1].mask = &rte_flow_item_ipv6_mask;
 		sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 		sa->pattern[1].spec = &sa->ipv6_spec;
-		memcpy(&sa->ipv6_spec.hdr.dst_addr,
-			sa->dst.ip.ip6.ip6_b, sizeof(sa->dst.ip.ip6.ip6_b));
-		memcpy(&sa->ipv6_spec.hdr.src_addr,
-			sa->src.ip.ip6.ip6_b, sizeof(sa->src.ip.ip6.ip6_b));
+		sa->ipv6_spec.hdr.dst_addr = sa->dst.ip.ip6;
+		sa->ipv6_spec.hdr.src_addr = sa->src.ip.ip6;
 		sa->pattern[2].type = RTE_FLOW_ITEM_TYPE_ESP;
 		sa->pattern[2].spec = &sa->esp_spec;
 		sa->pattern[2].mask = &rte_flow_item_esp_mask;
examples/ipsec-secgw/ipsec.h +1 -4
index 1fe6b97168db..f12f57e2d5c7 100644
@@ -65,10 +65,7 @@ typedef int32_t (*ipsec_xform_fn)(struct rte_mbuf *m, struct ipsec_sa *sa,
 struct ip_addr {
 	union {
 		uint32_t ip4;
-		union {
-			uint64_t ip6[2];
-			uint8_t ip6_b[16];
-		} ip6;
+		struct rte_ipv6_addr ip6;
 	} ip;
 };
 
examples/ipsec-secgw/parser.c +1 -1
index 2bd6df335b47..cb463c704f97 100644
@@ -75,7 +75,7 @@ parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask)
 }
 
 int
-parse_ipv6_addr(const char *token, struct in6_addr *ipv6, uint32_t *mask)
+parse_ipv6_addr(const char *token, struct rte_ipv6_addr *ipv6, uint32_t *mask)
 {
 	char ip_str[256] = {0};
 	char *pch;
examples/ipsec-secgw/parser.h +3 -1
index b5c5d0210f04..63f7844ed89f 100644
@@ -11,6 +11,8 @@
 #include <netinet/ip.h>
 #include <string.h>
 
+#include <rte_ip6.h>
+
 struct parse_status {
 	int status;
 	char parse_msg[256];
@@ -63,7 +65,7 @@ int
 parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask);
 
 int
-parse_ipv6_addr(const char *token, struct in6_addr *ipv6, uint32_t *mask);
+parse_ipv6_addr(const char *token, struct rte_ipv6_addr *ipv6, uint32_t *mask);
 
 int
 parse_range(const char *token, uint16_t *low, uint16_t *high);
examples/ipsec-secgw/rt.c +2 -2
index 059fc0c8f28c..132e200adb2a 100644
@@ -89,7 +89,7 @@ parse_rt_tokens(char **tokens, uint32_t n_tokens,
 					(uint32_t)ip.s_addr);
 				route_ipv4->depth = (uint8_t)depth;
 			} else {
-				struct in6_addr ip;
+				struct rte_ipv6_addr ip;
 				uint32_t depth;
 
 				APP_CHECK(parse_ipv6_addr(tokens[ti],
@@ -99,7 +99,7 @@ parse_rt_tokens(char **tokens, uint32_t n_tokens,
 					tokens[ti]);
 				if (status->status < 0)
 					return;
-				memcpy(&route_ipv6->ip, ip.s6_addr, 16);
+				route_ipv6->ip = ip;
 				route_ipv6->depth = (uint8_t)depth;
 			}
 		}
examples/ipsec-secgw/sa.c +13 -24
index 1a0afd2ed2e8..425bfbf590fc 100644
@@ -32,7 +32,7 @@
 
 #define IP4_FULL_MASK (sizeof(((struct ip_addr *)NULL)->ip.ip4) * CHAR_BIT)
 
-#define IP6_FULL_MASK (sizeof(((struct ip_addr *)NULL)->ip.ip6.ip6) * CHAR_BIT)
+#define IP6_FULL_MASK RTE_IPV6_MAX_DEPTH
 
 #define MBUF_NO_SEC_OFFLOAD(m) ((m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD) == 0)
 
@@ -661,7 +661,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 				rule->src.ip.ip4 = rte_bswap32(
 					(uint32_t)ip.s_addr);
 			} else if (IS_IP6_TUNNEL(rule->flags)) {
-				struct in6_addr ip;
+				struct rte_ipv6_addr ip;
 
 				APP_CHECK(parse_ipv6_addr(tokens[ti], &ip,
 					NULL) == 0, status,
@@ -670,8 +670,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 					tokens[ti]);
 				if (status->status < 0)
 					return;
-				memcpy(rule->src.ip.ip6.ip6_b,
-					ip.s6_addr, 16);
+
+				rule->src.ip.ip6 = ip;
 			} else if (IS_TRANSPORT(rule->flags)) {
 				APP_CHECK(0, status, "unrecognized input "
 					"\"%s\"", tokens[ti]);
@@ -704,7 +704,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 				rule->dst.ip.ip4 = rte_bswap32(
 					(uint32_t)ip.s_addr);
 			} else if (IS_IP6_TUNNEL(rule->flags)) {
-				struct in6_addr ip;
+				struct rte_ipv6_addr ip;
 
 				APP_CHECK(parse_ipv6_addr(tokens[ti], &ip,
 					NULL) == 0, status,
@@ -713,7 +713,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 					tokens[ti]);
 				if (status->status < 0)
 					return;
-				memcpy(rule->dst.ip.ip6.ip6_b, ip.s6_addr, 16);
+
+				rule->dst.ip.ip6 = ip;
 			} else if (IS_TRANSPORT(rule->flags)) {
 				APP_CHECK(0, status, "unrecognized "
 					"input \"%s\"",	tokens[ti]);
@@ -1010,19 +1011,9 @@ print_one_sa_rule(const struct ipsec_sa *sa, int inbound)
 		break;
 	case IP6_TUNNEL:
 		printf("IP6Tunnel ");
-		for (i = 0; i < 16; i++) {
-			if (i % 2 && i != 15)
-				printf("%.2x:", sa->src.ip.ip6.ip6_b[i]);
-			else
-				printf("%.2x", sa->src.ip.ip6.ip6_b[i]);
-		}
+		printf(RTE_IPV6_ADDR_FMT, RTE_IPV6_ADDR_SPLIT(&sa->src.ip.ip6));
 		printf(" ");
-		for (i = 0; i < 16; i++) {
-			if (i % 2 && i != 15)
-				printf("%.2x:", sa->dst.ip.ip6.ip6_b[i]);
-			else
-				printf("%.2x", sa->dst.ip.ip6.ip6_b[i]);
-		}
+		printf(RTE_IPV6_ADDR_FMT, RTE_IPV6_ADDR_SPLIT(&sa->dst.ip.ip6));
 		break;
 	case TRANSPORT:
 		printf("Transport ");
@@ -1220,10 +1211,8 @@ sa_add_address_inline_crypto(struct ipsec_sa *sa)
 		sa->flags |= IP6_TRANSPORT;
 		if (mask[0] == IP6_FULL_MASK &&
 				mask[1] == IP6_FULL_MASK &&
-				(ip_addr[0].ip.ip6.ip6[0] != 0 ||
-				ip_addr[0].ip.ip6.ip6[1] != 0) &&
-				(ip_addr[1].ip.ip6.ip6[0] != 0 ||
-				ip_addr[1].ip.ip6.ip6[1] != 0)) {
+				!rte_ipv6_addr_is_unspec(&ip_addr[0].ip.ip6) &&
+				!rte_ipv6_addr_is_unspec(&ip_addr[1].ip.ip6)) {
 
 			sa->src.ip.ip6 = ip_addr[0].ip.ip6;
 			sa->dst.ip.ip6 = ip_addr[1].ip.ip6;
@@ -1571,8 +1560,8 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size,
 	};
 
 	if (IS_IP6_TUNNEL(lsa->flags)) {
-		memcpy(&v6.src_addr, lsa->src.ip.ip6.ip6_b, sizeof(v6.src_addr));
-		memcpy(&v6.dst_addr, lsa->dst.ip.ip6.ip6_b, sizeof(v6.dst_addr));
+		v6.src_addr = lsa->src.ip.ip6;
+		v6.dst_addr = lsa->dst.ip.ip6;
 	}
 
 	rc = fill_ipsec_sa_prm(&prm, lsa, &v4, &v6);
examples/ipsec-secgw/sad.h +6 -6
index fdb1d2ef1790..d8f3a91e7aa8 100644
@@ -9,6 +9,8 @@
 #include <rte_ip6.h>
 #include <rte_ipsec_sad.h>
 
+#include "ipsec.h"
+
 #define SA_CACHE_SZ	128
 #define SPI2IDX(spi, mask)	((spi) & (mask))
 
@@ -39,8 +41,8 @@ cmp_sa_key(struct ipsec_sa *sa, int is_v4, struct rte_ipv4_hdr *ipv4,
 			(sa->dst.ip.ip4 == ipv4->dst_addr)) ||
 			/* IPv6 check */
 			(!is_v4 && (sa_type == IP6_TUNNEL) &&
-			(!memcmp(sa->src.ip.ip6.ip6, &ipv6->src_addr, 16)) &&
-			(!memcmp(sa->dst.ip.ip6.ip6, &ipv6->dst_addr, 16))))
+			(rte_ipv6_addr_eq(&sa->src.ip.ip6, &ipv6->src_addr)) &&
+			(rte_ipv6_addr_eq(&sa->dst.ip.ip6, &ipv6->dst_addr))))
 		return 1;
 
 	return 0;
@@ -130,10 +132,8 @@ sad_lookup(struct ipsec_sad *sad, struct rte_mbuf *pkts[],
 				}
 			}
 			v6[nb_v6].spi = esp->spi;
-			memcpy(v6[nb_v6].dip, &ipv6->dst_addr,
-					sizeof(ipv6->dst_addr));
-			memcpy(v6[nb_v6].sip, &ipv6->src_addr,
-					sizeof(ipv6->src_addr));
+			v6[nb_v6].dip = ipv6->dst_addr;
+			v6[nb_v6].sip = ipv6->src_addr;
 			keys_v6[nb_v6] = (const union rte_ipsec_sad_key *)
 						&v6[nb_v6];
 			v6_idxes[nb_v6++] = i;
examples/ipsec-secgw/sp6.c +84 -70

226 lines not on this page · raw message

lib/ipsec/rte_ipsec_sad.h +3 -2
index 0adf89d9310c..c7fb4744304e 100644
@@ -8,6 +8,7 @@
 
 #include <stdint.h>
 
+#include <rte_ip6.h>
 
 /**
  * @file rte_ipsec_sad.h
@@ -38,8 +39,8 @@ struct rte_ipsec_sadv4_key {
 
 struct rte_ipsec_sadv6_key {
 	uint32_t spi;
-	uint8_t dip[16];
-	uint8_t sip[16];
+	struct rte_ipv6_addr dip;
+	struct rte_ipv6_addr sip;
 };
 
 union rte_ipsec_sad_key {
lib/pipeline/rte_swx_ipsec.c +4 -4
index 5920178f38e5..ea10213cc91d 100644
@@ -1321,14 +1321,14 @@ rte_swx_ipsec_sa_read(struct rte_swx_ipsec *ipsec __rte_unused,
 			CHECK(!strcmp(t[2], "srcaddr"), "Missing \"srcaddr\" keyword");
 
 			status = hex_string_parse(t[3],
-						  p->encap.tunnel.ipv6.src_addr.s6_addr,
+						  p->encap.tunnel.ipv6.src_addr.a,
 						  16);
 			CHECK(!status, "Tunnel IPv6 source address invalid format");
 
 			CHECK(!strcmp(t[4], "dstaddr"), "Missing \"dstaddr\" keyword");
 
 			status = hex_string_parse(t[5],
-						  p->encap.tunnel.ipv6.dst_addr.s6_addr,
+						  p->encap.tunnel.ipv6.dst_addr.a,
 						  16);
 			CHECK(!status, "Tunnel IPv6 destination address invalid format");
 
@@ -1387,11 +1387,11 @@ tunnel_ipv6_header_set(struct rte_ipv6_hdr *h, struct rte_swx_ipsec_sa_params *p
 		.payload_len = 0, /* Cannot be pre-computed. */
 		.proto = IPPROTO_ESP,
 		.hop_limits = 64,
+		.src_addr = p->encap.tunnel.ipv6.src_addr,
+		.dst_addr = p->encap.tunnel.ipv6.dst_addr,
 	};
 
 	memcpy(h, &ipv6_hdr, sizeof(ipv6_hdr));
-	memcpy(&h->src_addr, p->encap.tunnel.ipv6.src_addr.s6_addr, 16);
-	memcpy(&h->dst_addr, p->encap.tunnel.ipv6.dst_addr.s6_addr, 16);
 }
 
 /* IPsec library SA parameters. */
lib/pipeline/rte_swx_ipsec.h +3 -2
index d2e5abef7d61..6cff18084f9c 100644
@@ -48,6 +48,7 @@
 
 #include <rte_compat.h>
 #include <rte_crypto_sym.h>
+#include <rte_ip6.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -248,10 +249,10 @@ struct rte_swx_ipsec_sa_encap_params {
 		/** IPv6 header. */
 		struct {
 			/** Source address. */
-			struct in6_addr src_addr;
+			struct rte_ipv6_addr src_addr;
 
 			/** Destination address. */
-			struct in6_addr dst_addr;
+			struct rte_ipv6_addr dst_addr;
 		} ipv6;
 	} tunnel;
 };
lib/security/rte_security.h +3 -2
index 7a9bafa0fa72..032bf9c5fbfa 100644
@@ -18,6 +18,7 @@
 #include <rte_common.h>
 #include <rte_crypto.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_mbuf_dyn.h>
 
 #ifdef __cplusplus
@@ -85,9 +86,9 @@ struct rte_security_ipsec_tunnel_param {
 		} ipv4;
 		/**< IPv4 header parameters */
 		struct {
-			struct in6_addr src_addr;
+			struct rte_ipv6_addr src_addr;
 			/**< IPv6 source address */
-			struct in6_addr dst_addr;
+			struct rte_ipv6_addr dst_addr;
 			/**< IPv6 destination address */
 			uint8_t dscp;
 			/**< IPv6 Differentiated Services Code Point */
Signature · 1 line
2.46.2
#80 lore raw

PATCH v3 13/17 thash: use struct rte_ipv6_addr

In reply to Robin Jarry

Update rte_ipv6_tuple to use rte_ipv6_addr structures instead of uint8_t[16] arrays. Use IPv6 utils that go along.

---

Notes:
v3:

- replace memcpy() with direct struct assignments
- replace string initializers with RTE_IPV6()

 app/test/test_thash.c                  | 46 ++++++++++----------------
 doc/guides/rel_notes/deprecation.rst   |  2 --
 doc/guides/rel_notes/release_24_11.rst |  1 +
 lib/hash/rte_thash.h                   | 20 +++++------
 4 files changed, 28 insertions(+), 41 deletions(-)
app/test/test_thash.c +17 -29
index 952da6a52954..0ad6943cf839 100644
@@ -25,8 +25,8 @@ struct test_thash_v4 {
 };
 
 struct test_thash_v6 {
-	uint8_t		dst_ip[16];
-	uint8_t		src_ip[16];
+	struct rte_ipv6_addr dst_ip;
+	struct rte_ipv6_addr src_ip;
 	uint16_t	dst_port;
 	uint16_t	src_port;
 	uint32_t	hash_l3;
@@ -49,25 +49,19 @@ struct test_thash_v4 v4_tbl[] = {
 
 struct test_thash_v6 v6_tbl[] = {
 /*3ffe:2501:200:3::1*/
-{{0x3f, 0xfe, 0x25, 0x01, 0x02, 0x00, 0x00, 0x03,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,},
+{RTE_IPV6(0x3ffe, 0x2501, 0x0200, 0x0003, 0, 0, 0, 0x0001),
 /*3ffe:2501:200:1fff::7*/
-{0x3f, 0xfe, 0x25, 0x01, 0x02, 0x00, 0x1f, 0xff,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,},
+RTE_IPV6(0x3ffe, 0x2501, 0x0200, 0x1fff, 0, 0, 0, 0x0007),
 1766, 2794, 0x2cc18cd5, 0x40207d3d},
 /*ff02::1*/
-{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,},
+{RTE_IPV6(0xff02, 0, 0, 0, 0, 0, 0, 0x0001),
 /*3ffe:501:8::260:97ff:fe40:efab*/
-{0x3f, 0xfe, 0x05, 0x01, 0x00, 0x08, 0x00, 0x00,
-0x02, 0x60, 0x97, 0xff, 0xfe, 0x40, 0xef, 0xab,},
+RTE_IPV6(0x3ffe, 0x0501, 0x0008, 0, 0x0260, 0x97ff, 0xfe40, 0xefab),
 4739, 14230, 0x0f0c461c, 0xdde51bbf},
 /*fe80::200:f8ff:fe21:67cf*/
-{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x02, 0x00, 0xf8, 0xff, 0xfe, 0x21, 0x67, 0xcf,},
+{RTE_IPV6(0xfe80, 0, 0, 0, 0x0200, 0xf8ff, 0xfe21, 0x67cf),
 /*3ffe:1900:4545:3:200:f8ff:fe21:67cf*/
-{0x3f, 0xfe, 0x19, 0x00, 0x45, 0x45, 0x00, 0x03,
-0x02, 0x00, 0xf8, 0xff, 0xfe, 0x21, 0x67, 0xcf,},
+RTE_IPV6(0x3ffe, 0x1900, 0x4545, 0x0003, 0x0200, 0xf8ff, 0xfe21, 0x67cf),
 38024, 44251, 0x4b61e985, 0x02d1feef},
 };
 
@@ -110,7 +104,7 @@ static const uint8_t big_rss_key[] = {
 static int
 test_toeplitz_hash_calc(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple;
 	uint32_t rss_l3, rss_l3l4;
 	uint8_t rss_key_be[RTE_DIM(default_rss_key)];
@@ -145,10 +139,8 @@ test_toeplitz_hash_calc(void)
 	}
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
 		/*Fill ipv6 hdr*/
-		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr.a); j++)
-			ipv6_hdr.src_addr.a[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr.a); j++)
-			ipv6_hdr.dst_addr.a[j] = v6_tbl[i].dst_ip[j];
+		ipv6_hdr.src_addr = v6_tbl[i].src_ip;
+		ipv6_hdr.dst_addr = v6_tbl[i].dst_ip;
 		/*Load and convert ipv6 address into tuple*/
 		rte_thash_load_v6_addrs(&ipv6_hdr, &tuple);
 		tuple.v6.sport = v6_tbl[i].src_port;
@@ -176,7 +168,7 @@ test_toeplitz_hash_calc(void)
 static int
 test_toeplitz_hash_gfni(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple;
 	uint32_t rss_l3, rss_l3l4;
 	uint64_t rss_key_matrixes[RTE_DIM(default_rss_key)];
@@ -204,10 +196,8 @@ test_toeplitz_hash_gfni(void)
 	}
 
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
-		for (j = 0; j < RTE_DIM(tuple.v6.src_addr); j++)
-			tuple.v6.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(tuple.v6.dst_addr); j++)
-			tuple.v6.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		tuple.v6.src_addr = v6_tbl[i].src_ip;
+		tuple.v6.dst_addr = v6_tbl[i].dst_ip;
 		tuple.v6.sport = rte_cpu_to_be_16(v6_tbl[i].dst_port);
 		tuple.v6.dport = rte_cpu_to_be_16(v6_tbl[i].src_port);
 		rss_l3 = rte_thash_gfni(rss_key_matrixes, (uint8_t *)&tuple,
@@ -299,7 +289,7 @@ enum {
 static int
 test_toeplitz_hash_gfni_bulk(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple[2];
 	uint8_t *tuples[2];
 	uint32_t rss[2] = { 0 };
@@ -328,10 +318,8 @@ test_toeplitz_hash_gfni_bulk(void)
 		rte_memcpy(tuples[0], &tuple[0], RTE_THASH_V4_L4_LEN * 4);
 
 		/*Load IPv6 headers and copy it into the corresponding tuple*/
-		for (j = 0; j < RTE_DIM(tuple[1].v6.src_addr); j++)
-			tuple[1].v6.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(tuple[1].v6.dst_addr); j++)
-			tuple[1].v6.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		tuple[1].v6.src_addr = v6_tbl[i].src_ip;
+		tuple[1].v6.dst_addr = v6_tbl[i].dst_ip;
 		tuple[1].v6.sport = rte_cpu_to_be_16(v6_tbl[i].dst_port);
 		tuple[1].v6.dport = rte_cpu_to_be_16(v6_tbl[i].src_port);
 		rte_memcpy(tuples[1], &tuple[1], RTE_THASH_V6_L4_LEN * 4);
doc/guides/rel_notes/deprecation.rst +0 -2
index 838e22b44444..dc0c6e4182ff 100644
@@ -72,8 +72,6 @@ Deprecation Notices
     - ``struct rte_flow_tunnel``
   gro
     - ``struct tcp6_flow_key``
-  hash
-    - ``struct rte_ipv6_tuple``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +1 -0
index 3c273ce25c75..54badeeecabd 100644
@@ -151,6 +151,7 @@ API Changes
 * pipeline: ``rte_swx_ipsec_sa_encap_params`` was modified to use ``rte_ipv6_addr`` instead of ``in6_addr``.
 * ipsec: ``rte_ipsec_sadv6_key`` was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
 * security: ``rte_security_ipsec_tunnel_param`` was modified to use ``rte_ipv6_addr`` instead of ``in6_addr``.
+* hash: ``rte_ipv6_tuple`` was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
 
 ABI Changes
 -----------
lib/hash/rte_thash.h +10 -10
index d988df15a9ba..61f6fa1b08b4 100644
@@ -89,8 +89,8 @@ struct rte_ipv4_tuple {
  * ports/sctp_tag have to be CPU byte order
  */
 struct rte_ipv6_tuple {
-	uint8_t		src_addr[16];
-	uint8_t		dst_addr[16];
+	struct rte_ipv6_addr src_addr;
+	struct rte_ipv6_addr dst_addr;
 	union {
 		struct {
 			uint16_t dport;
@@ -141,22 +141,22 @@ rte_thash_load_v6_addrs(const struct rte_ipv6_hdr *orig,
 {
 #ifdef RTE_ARCH_X86
 	__m128i ipv6 = _mm_loadu_si128((const __m128i *)&orig->src_addr);
-	*(__m128i *)targ->v6.src_addr =
+	*(__m128i *)&targ->v6.src_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 	ipv6 = _mm_loadu_si128((const __m128i *)&orig->dst_addr);
-	*(__m128i *)targ->v6.dst_addr =
+	*(__m128i *)&targ->v6.dst_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 #elif defined(__ARM_NEON)
-	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)&orig->src_addr);
-	vst1q_u8((uint8_t *)targ->v6.src_addr, vrev32q_u8(ipv6));
-	ipv6 = vld1q_u8((uint8_t const *)&orig->dst_addr);
-	vst1q_u8((uint8_t *)targ->v6.dst_addr, vrev32q_u8(ipv6));
+	uint8x16_t ipv6 = vld1q_u8(orig->src_addr.a);
+	vst1q_u8(targ->v6.src_addr.a, vrev32q_u8(ipv6));
+	ipv6 = vld1q_u8(orig->dst_addr.a);
+	vst1q_u8(targ->v6.dst_addr.a, vrev32q_u8(ipv6));
 #else
 	int i;
 	for (i = 0; i < 4; i++) {
-		*((uint32_t *)targ->v6.src_addr + i) =
+		*((uint32_t *)&targ->v6.src_addr + i) =
 			rte_be_to_cpu_32(*((const uint32_t *)&orig->src_addr + i));
-		*((uint32_t *)targ->v6.dst_addr + i) =
+		*((uint32_t *)&targ->v6.dst_addr + i) =
 			rte_be_to_cpu_32(*((const uint32_t *)&orig->dst_addr + i));
 	}
 #endif
Signature · 1 line
2.46.2
#81 lore raw

PATCH v3 14/17 gro: use struct rte_ipv6_addr

In reply to Robin Jarry

Update tcp6_flow_key to use rte_ipv6_addr structures instead of uint8_t[16] arrays. Use the IPv6 utils that go along.

---

Notes:
v3: replace memcpy() with direct struct assignments

 doc/guides/rel_notes/deprecation.rst   | 2 --
 doc/guides/rel_notes/release_24_11.rst | 1 +
 lib/gro/gro_tcp6.c                     | 8 ++++----
 lib/gro/gro_tcp6.h                     | 6 ++++--
 4 files changed, 9 insertions(+), 8 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -2
index dc0c6e4182ff..f384a4b414c9 100644
@@ -70,8 +70,6 @@ Deprecation Notices
     - ``struct rte_flow_item_icmp6_nd_na``
     - ``struct rte_flow_action_set_ipv6``
     - ``struct rte_flow_tunnel``
-  gro
-    - ``struct tcp6_flow_key``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +1 -0
index 54badeeecabd..f912f78017d7 100644
@@ -152,6 +152,7 @@ API Changes
 * ipsec: ``rte_ipsec_sadv6_key`` was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
 * security: ``rte_security_ipsec_tunnel_param`` was modified to use ``rte_ipv6_addr`` instead of ``in6_addr``.
 * hash: ``rte_ipv6_tuple`` was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
+* gro: ``tcp6_flow_key`` was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
 
 ABI Changes
 -----------
lib/gro/gro_tcp6.c +4 -4
index 6edfb6045cf6..ab4cd6c68bf0 100644
@@ -99,8 +99,8 @@ insert_new_flow(struct gro_tcp6_tbl *tbl,
 	dst = &(tbl->flows[flow_idx].key);
 
 	ASSIGN_COMMON_TCP_KEY((&src->cmn_key), (&dst->cmn_key));
-	memcpy(&dst->src_addr[0], &src->src_addr[0], sizeof(dst->src_addr));
-	memcpy(&dst->dst_addr[0], &src->dst_addr[0], sizeof(dst->dst_addr));
+	dst->src_addr = src->src_addr;
+	dst->dst_addr = src->dst_addr;
 	dst->vtc_flow = src->vtc_flow;
 
 	tbl->flows[flow_idx].start_index = item_idx;
@@ -168,8 +168,8 @@ gro_tcp6_reassemble(struct rte_mbuf *pkt,
 
 	rte_ether_addr_copy(&(eth_hdr->src_addr), &(key.cmn_key.eth_saddr));
 	rte_ether_addr_copy(&(eth_hdr->dst_addr), &(key.cmn_key.eth_daddr));
-	memcpy(&key.src_addr[0], &ipv6_hdr->src_addr, sizeof(key.src_addr));
-	memcpy(&key.dst_addr[0], &ipv6_hdr->dst_addr, sizeof(key.dst_addr));
+	key.src_addr = ipv6_hdr->src_addr;
+	key.dst_addr = ipv6_hdr->dst_addr;
 	key.cmn_key.src_port = tcp_hdr->src_port;
 	key.cmn_key.dst_port = tcp_hdr->dst_port;
 	key.cmn_key.recv_ack = tcp_hdr->recv_ack;
lib/gro/gro_tcp6.h +4 -2
index 073122f0ec84..acf3971bb6e9 100644
@@ -5,6 +5,8 @@
 #ifndef _GRO_TCP6_H_
 #define _GRO_TCP6_H_
 
+#include <rte_ip6.h>
+
 #include "gro_tcp.h"
 
 #define GRO_TCP6_TBL_MAX_ITEM_NUM (1024UL * 1024UL)
@@ -12,8 +14,8 @@
 /* Header fields representing a TCP/IPv6 flow */
 struct tcp6_flow_key {
 	struct cmn_tcp_key cmn_key;
-	uint8_t  src_addr[16];
-	uint8_t  dst_addr[16];
+	struct rte_ipv6_addr src_addr;
+	struct rte_ipv6_addr dst_addr;
 	rte_be32_t vtc_flow;
 };
 
Signature · 1 line
2.46.2
#82 lore raw

PATCH v3 15/17 rte_flow: use struct rte_ipv6_addr

In reply to Robin Jarry

Update rte_flow_tunnel, rte_flow_action_set_ipv6, rte_flow_item_icmp6_nd_na and rte_flow_item_icmp6_nd_ns to use rte_ipv6_addr structures instead of uint8_t[16] arrays. Use the IPv6 utils that go along.

Update all code accordingly.

---

Notes:
v3: replace string initializers with RTE_IPV6_MASK_FULL

 app/test-flow-perf/actions_gen.c         |  4 ++--
 doc/guides/rel_notes/deprecation.rst     | 10 ----------
 doc/guides/rel_notes/release_24_11.rst   |  1 +
 drivers/net/cxgbe/cxgbe_flow.c           |  4 ++--
 drivers/net/nfp/flower/nfp_flower_flow.c |  2 +-
 lib/ethdev/rte_flow.h                    | 18 +++++++-----------
 6 files changed, 13 insertions(+), 26 deletions(-)
app/test-flow-perf/actions_gen.c +2 -2
index b5336e83ff9f..54fcbacb98ce 100644
@@ -304,7 +304,7 @@ add_set_src_ipv6(struct rte_flow_action *actions,
 
 	/* IPv6 value to set is random each time */
 	for (i = 0; i < 16; i++) {
-		set_ipv6[para.core_idx].ipv6_addr[i] = ipv6 & 0xff;
+		set_ipv6[para.core_idx].ipv6_addr.a[i] = ipv6 & 0xff;
 		ipv6 = ipv6 >> 8;
 	}
 
@@ -327,7 +327,7 @@ add_set_dst_ipv6(struct rte_flow_action *actions,
 
 	/* IPv6 value to set is random each time */
 	for (i = 0; i < 16; i++) {
-		set_ipv6[para.core_idx].ipv6_addr[i] = ipv6 & 0xff;
+		set_ipv6[para.core_idx].ipv6_addr.a[i] = ipv6 & 0xff;
 		ipv6 = ipv6 >> 8;
 	}
 
doc/guides/rel_notes/deprecation.rst +0 -10
index f384a4b414c9..7b77987bffa2 100644
@@ -61,16 +61,6 @@ Deprecation Notices
   us extending existing enum/define.
   One solution can be using a fixed size array instead of ``.*MAX.*`` value.
 
-* net: A new IPv6 address structure will be introduced in DPDK 24.11.
-  It will replace all ad-hoc ``uint8_t[16]`` arrays in all public APIs and structures.
-  The following libraries and symbols are expected to be affected:
-
-  ethdev
-    - ``struct rte_flow_item_icmp6_nd_ns``
-    - ``struct rte_flow_item_icmp6_nd_na``
-    - ``struct rte_flow_action_set_ipv6``
-    - ``struct rte_flow_tunnel``
-
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
   The struct ``rte_flow_item_vxlan_gpe`` and its mask ``rte_flow_item_vxlan_gpe_mask``
doc/guides/rel_notes/release_24_11.rst +1 -0
index f912f78017d7..027ac3ce9177 100644
@@ -153,6 +153,7 @@ API Changes
 * security: ``rte_security_ipsec_tunnel_param`` was modified to use ``rte_ipv6_addr`` instead of ``in6_addr``.
 * hash: ``rte_ipv6_tuple`` was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
 * gro: ``tcp6_flow_key`` was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
+* ethdev: ``rte_flow_*`` structures were modified to use  ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields.
 
 ABI Changes
 -----------
drivers/net/cxgbe/cxgbe_flow.c +2 -2
index 9c7fa19bef00..9cb36172f818 100644
@@ -680,7 +680,7 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a,
 						  "found.");
 
 		ipv6 = (const struct rte_flow_action_set_ipv6 *)a->conf;
-		memcpy(fs->nat_fip, ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
+		memcpy(fs->nat_fip, &ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
 		*nmode |= 1 << 0;
 		break;
 	case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST:
@@ -693,7 +693,7 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a,
 						  "found.");
 
 		ipv6 = (const struct rte_flow_action_set_ipv6 *)a->conf;
-		memcpy(fs->nat_lip, ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
+		memcpy(fs->nat_lip, &ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
 		*nmode |= 1 << 1;
 		break;
 	case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
drivers/net/nfp/flower/nfp_flower_flow.c +1 -1
index 56352893d832..8c35ec539e59 100644
@@ -2972,7 +2972,7 @@ nfp_flow_action_set_ipv6(char *act_data,
 	set_ip->reserved = 0;
 
 	for (i = 0; i < 4; i++) {
-		rte_memcpy(&tmp, &set_ipv6->ipv6_addr[i * 4], 4);
+		rte_memcpy(&tmp, &set_ipv6->ipv6_addr.a[i * 4], 4);
 		set_ip->ipv6[i].exact = tmp;
 		set_ip->ipv6[i].mask = RTE_BE32(0xffffffff);
 	}
lib/ethdev/rte_flow.h +7 -11
index 3990bda14980..c58b49586b5d 100644
@@ -1499,16 +1499,14 @@ struct rte_flow_item_icmp6_nd_ns {
 	uint8_t code; /**< ICMPv6 code, normally 0. */
 	rte_be16_t checksum; /**< ICMPv6 checksum. */
 	rte_be32_t reserved; /**< Reserved, normally 0. */
-	uint8_t target_addr[16]; /**< Target address. */
+	struct rte_ipv6_addr target_addr; /**< Target address. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
 #ifndef __cplusplus
 static const
 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
-	.target_addr =
-		"\xff\xff\xff\xff\xff\xff\xff\xff"
-		"\xff\xff\xff\xff\xff\xff\xff\xff",
+	.target_addr = RTE_IPV6_MASK_FULL,
 };
 #endif
 
@@ -1526,16 +1524,14 @@ struct rte_flow_item_icmp6_nd_na {
 	 * reserved (29b).
 	 */
 	rte_be32_t rso_reserved;
-	uint8_t target_addr[16]; /**< Target address. */
+	struct rte_ipv6_addr target_addr; /**< Target address. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
 #ifndef __cplusplus
 static const
 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
-	.target_addr =
-		"\xff\xff\xff\xff\xff\xff\xff\xff"
-		"\xff\xff\xff\xff\xff\xff\xff\xff",
+	.target_addr = RTE_IPV6_MASK_FULL,
 };
 #endif
 
@@ -3806,7 +3802,7 @@ struct rte_flow_action_set_ipv4 {
  * specified outermost IPv6 header.
  */
 struct rte_flow_action_set_ipv6 {
-	uint8_t ipv6_addr[16];
+	struct rte_ipv6_addr ipv6_addr;
 };
 
 /**
@@ -5190,8 +5186,8 @@ struct rte_flow_tunnel {
 			rte_be32_t dst_addr; /**< IPv4 destination address. */
 		} ipv4;
 		struct {
-			uint8_t src_addr[16]; /**< IPv6 source address. */
-			uint8_t dst_addr[16]; /**< IPv6 destination address. */
+			struct rte_ipv6_addr src_addr; /**< IPv6 source address. */
+			struct rte_ipv6_addr dst_addr; /**< IPv6 destination address. */
 		} ipv6;
 	};
 	rte_be16_t tp_src; /**< Tunnel port source. */
Signature · 1 line
2.46.2
#83 lore raw

PATCH v3 16/17 net: add utilities for well known ipv6 address types

In reply to Robin Jarry

Add more utilities to work with IPv6 addresses. These functions will be required in order to help building IPv6 routing applications.

---

Notes:
v3:

- replace string initializers and RTE_IPV6_ADDR() with RTE_IPV6()

 app/test/test_net_ip6.c |  68 +++++++++++++++++++
 lib/net/rte_ip6.h       | 143 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 211 insertions(+)
app/test/test_net_ip6.c +68 -0
index dcc80c1309d1..94033421ad0b 100644
@@ -81,20 +81,85 @@ static int
 test_ipv6_addr_kind(void)
 {
 	TEST_ASSERT(rte_ipv6_addr_is_unspec(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&zero_addr), "");
 
 	const struct rte_ipv6_addr ucast =
 		RTE_IPV6(0x2a01, 0xcb00, 0x0254, 0x3300, 0x6239, 0xe1f4, 0x7a0b, 0x2371);
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&ucast), "");
 
 	const struct rte_ipv6_addr mcast = RTE_IPV6(0xff01, 0, 0, 0, 0, 0, 0, 1);
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&mcast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&mcast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&mcast), "");
+	TEST_ASSERT(rte_ipv6_addr_is_mcast(&mcast), "");
 
 	const struct rte_ipv6_addr lo = RTE_IPV6_ADDR_LOOPBACK;
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&lo), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&lo), "");
+	TEST_ASSERT(rte_ipv6_addr_is_loopback(&lo), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&lo), "");
 
 	const struct rte_ipv6_addr local =
 		RTE_IPV6(0xfe80, 0, 0, 0, 0x5a84, 0xc52c, 0x6aef, 0x4639);
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&local), "");
+	TEST_ASSERT(rte_ipv6_addr_is_linklocal(&local), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&local), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&local), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ipv6_llocal_from_ethernet(void)
+{
+	const struct rte_ether_addr local_mac = {{0x04, 0x7b, 0xcb, 0x5c, 0x08, 0x44}};
+	const struct rte_ipv6_addr local_ip =
+		RTE_IPV6(0xfe80, 0, 0, 0, 0x047b, 0xcbff, 0xfe5c, 0x0844);
+	struct rte_ipv6_addr ip;
+
+	rte_ipv6_llocal_from_ethernet(&ip, &local_mac);
+	TEST_ASSERT(rte_ipv6_addr_eq(&ip, &local_ip), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ipv6_solnode_from_addr(void)
+{
+	struct rte_ipv6_addr sol;
+
+	const struct rte_ipv6_addr llocal =
+		RTE_IPV6(0xfe80, 0, 0, 0, 0x047b, 0xcbff, 0xfe5c, 0x0844);
+	const struct rte_ipv6_addr llocal_sol =
+		RTE_IPV6(0xff02, 0, 0, 0, 0, 0x0001, 0xff5c, 0x0844);
+	rte_ipv6_solnode_from_addr(&sol, &llocal);
+	TEST_ASSERT(rte_ipv6_addr_eq(&sol, &llocal_sol), "");
+
+	const struct rte_ipv6_addr ucast =
+		RTE_IPV6(0x2a01, 0xcb00, 0x0254, 0x3300, 0x1b9f, 0x8071, 0x67cd, 0xbf20);
+	const struct rte_ipv6_addr ucast_sol =
+		RTE_IPV6(0xff02, 0, 0, 0, 0, 0x0001, 0xffcd, 0xbf20);
+	rte_ipv6_solnode_from_addr(&sol, &ucast);
+	TEST_ASSERT(rte_ipv6_addr_eq(&sol, &ucast_sol), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ether_mcast_from_ipv6(void)
+{
+	const struct rte_ether_addr mcast_mac = {{0x33, 0x33, 0xd3, 0x00, 0x02, 0x01}};
+	const struct rte_ipv6_addr mcast_ip =
+		RTE_IPV6(0xff02, 0, 0, 0x0201, 0, 0, 0xd300, 0x0201);
+	struct rte_ether_addr mac;
+
+	rte_ether_mcast_from_ipv6(&mac, &mcast_ip);
+	TEST_ASSERT(rte_is_same_ether_addr(&mac, &mcast_mac), "");
 
 	return TEST_SUCCESS;
 }
@@ -105,6 +170,9 @@ test_net_ipv6(void)
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_mask(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_eq_prefix(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_kind(), "");
+	TEST_ASSERT_SUCCESS(test_ipv6_llocal_from_ethernet(), "");
+	TEST_ASSERT_SUCCESS(test_ipv6_solnode_from_addr(), "");
+	TEST_ASSERT_SUCCESS(test_ether_mcast_from_ipv6(), "");
 	return TEST_SUCCESS;
 }
 
lib/net/rte_ip6.h +143 -0

155 lines not on this page · raw message

Signature · 1 line
2.46.2
#84 lore raw

PATCH v3 17/17 ipv6: add function to check ipv6 version

In reply to Robin Jarry

Add a function to check the version in IPv6 headers.

---

Notes:
v3: only check for the first byte

 app/test/test_net_ip6.c | 16 ++++++++++++++++
 lib/net/rte_ip6.h       | 14 ++++++++++++++
 2 files changed, 30 insertions(+)
app/test/test_net_ip6.c +16 -0
index 94033421ad0b..9cc10b1f714f 100644
@@ -9,6 +9,21 @@
 static const struct rte_ipv6_addr mask_full = RTE_IPV6_MASK_FULL;
 static const struct rte_ipv6_addr zero_addr = RTE_IPV6_ADDR_UNSPEC;
 
+static int
+test_ipv6_check_version(void)
+{
+	struct rte_ipv6_hdr h;
+
+	h.vtc_flow = 0;
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, "");
+	h.vtc_flow = RTE_BE32(0x7f00ba44);
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, "");
+	h.vtc_flow = RTE_BE32(0x6badcaca);
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), 0, "");
+
+	return 0;
+}
+
 static int
 test_ipv6_addr_mask(void)
 {
@@ -167,6 +182,7 @@ test_ether_mcast_from_ipv6(void)
 static int
 test_net_ipv6(void)
 {
+	TEST_ASSERT_SUCCESS(test_ipv6_check_version(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_mask(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_eq_prefix(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_kind(), "");
lib/net/rte_ip6.h +14 -0
index d02b225303e9..94bc5a39b348 100644
@@ -364,6 +364,20 @@ struct rte_ipv6_hdr {
 	struct rte_ipv6_addr dst_addr;	/**< IP address of destination host(s). */
 } __rte_packed;
 
+/**
+ * Check that the IPv6 header version field is valid according to RFC 8200 section 3.
+ *
+ * @return
+ *   0 if the version field is valid. -EINVAL otherwise.
+ */
+static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip)
+{
+	uint8_t version = ((const uint8_t *)ip)[0];
+	if ((version & 0xf0) != 0x60)
+		return -EINVAL;
+	return 0;
+}
+
 /* IPv6 routing extension type definition. */
 #define RTE_IPV6_SRCRT_TYPE_4 4
 
Signature · 1 line
2.46.2
#86 lore raw
In reply to Robin Jarry

Hello Robin,

Quoted 183 lines · Robin Jarry

As discussed recently [1], here is a first draft of the IPv6 APIs rework. The API change was announced before the 24.07 release [2]. This series is intended for 24.11.

[1] http://inbox.dpdk.org/dev/[email protected]/
[2] https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc1b5764

I tried to keep the patches as small as possible; unfortunately some of them are quite big and cannot be broken down if we want to preserve a bisectable tree.

Let me know what you think.

Thanks!

Cc Bruce Richardson <[email protected]>
Cc Ferruh Yigit <[email protected]>
Cc Konstantin Ananyev <[email protected]>
Cc Morten Brørup <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Vladimir Medvedkin <[email protected]>

Changelog:

v3:

- replace *memcpy(ipv6) with direct struct assignments
- replace in6_addr with rte_ipv6_addr
- add more ipv6 utils to deal with addresses
- replace string initializers and RTE_IPV6_ADDR() with RTE_IPV6()
- restore deleted macro constants and mark them as RTE_DEPRECATED()

Robin Jarry (17):
net: split raw checksum functions in separate header
net: split ipv6 symbols in separate header
net: add structure for ipv6 addresses
net: add ipv6 address utilities
net: use struct rte_ipv6_addr for header addresses fib6,rib6,lpm6: use struct rte_ipv6_addr fib6,rib6,lpm6: use ipv6 utils rib6,fib6,lpm6: remove duplicate constants
cmdline: replace in6_addr with rte_ipv6_addr graph,node: use struct rte_ipv6_addr and utils
pipeline: use struct rte_ipv6_addr ipsec,security: use struct rte_ipv6_addr and utils
thash: use struct rte_ipv6_addr
gro: use struct rte_ipv6_addr
rte_flow: use struct rte_ipv6_addr
net: add utilities for well known ipv6 address types
ipv6: add function to check ipv6 version

 MAINTAINERS                                 |    1 +
 app/graph/ethdev.c                          |   44 +-
 app/graph/ethdev.h                          |    9 +-
 app/graph/ip6_route.c                       |   51 +-
 app/graph/meson.build                       |    2 +-
 app/graph/neigh.c                           |   21 +-
 app/graph/neigh_priv.h                      |    4 +-
 app/graph/route.h                           |    8 +-
 app/test-fib/main.c                         |   51 +-
 app/test-flow-perf/actions_gen.c            |    4 +-
 app/test-flow-perf/items_gen.c              |    4 +-
 app/test-pipeline/pipeline_hash.c           |    4 +-
 app/test-pipeline/pipeline_lpm_ipv6.c       |   11 +-
 app/test-pmd/cmdline.c                      |    4 +-
 app/test-pmd/cmdline_flow.c                 |   14 +-
 app/test-pmd/testpmd.h                      |   16 +-
 app/test-sad/main.c                         |   24 +-
 app/test/meson.build                        |    1 +
 app/test/packet_burst_generator.c           |    5 +-
 app/test/test_cmdline_ipaddr.c              |   49 +-
 app/test/test_cryptodev_security_ipsec.c    |    1 +
 app/test/test_fib6.c                        |   92 +-
 app/test/test_fib6_perf.c                   |    8 +-
 app/test/test_ipfrag.c                      |    4 +-
 app/test/test_ipsec_sad.c                   |   46 +-
 app/test/test_lpm6.c                        |  490 +++--
 app/test/test_lpm6_data.h                   | 2025 ++++++++++---------
 app/test/test_lpm6_perf.c                   |   10 +-
 app/test/test_net_ip6.c                     |  195 ++
 app/test/test_reassembly_perf.c             |   23 +-
 app/test/test_rib6.c                        |   55 +-
 app/test/test_table_combined.c              |    2 +-
 app/test/test_table_tables.c                |    8 +-
 app/test/test_thash.c                       |   46 +-
 doc/guides/prog_guide/ipsec_lib.rst         |    4 +-
 doc/guides/rel_notes/deprecation.rst        |   42 -
 doc/guides/rel_notes/release_24_11.rst      |   12 +
 drivers/common/cnxk/cnxk_security.c         |   15 +-
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c    |    1 +
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c |    1 +
 drivers/net/bnxt/bnxt_flow.c                |   12 +-
 drivers/net/bonding/rte_eth_bond_pmd.c      |    6 +-
 drivers/net/cxgbe/cxgbe_flow.c              |   20 +-
 drivers/net/dpaa2/dpaa2_flow.c              |   24 +-
 drivers/net/hinic/hinic_pmd_flow.c          |    6 +-
 drivers/net/hinic/hinic_pmd_tx.c            |    2 +-
 drivers/net/hns3/hns3_flow.c                |    8 +-
 drivers/net/i40e/i40e_flow.c                |   12 +-
 drivers/net/iavf/iavf_fdir.c                |    8 +-
 drivers/net/iavf/iavf_fsub.c                |    8 +-
 drivers/net/iavf/iavf_ipsec_crypto.c        |    9 +-
 drivers/net/ice/ice_fdir_filter.c           |   12 +-
 drivers/net/ice/ice_switch_filter.c         |   16 +-
 drivers/net/igc/igc_flow.c                  |    4 +-
 drivers/net/ixgbe/ixgbe_flow.c              |   12 +-
 drivers/net/ixgbe/ixgbe_ipsec.c             |    4 +-
 drivers/net/mlx5/hws/mlx5dr_definer.c       |   36 +-
 drivers/net/mlx5/mlx5_flow.c                |    8 +-
 drivers/net/mlx5/mlx5_flow_dv.c             |   20 +-
 drivers/net/mlx5/mlx5_flow_hw.c             |   12 +-
 drivers/net/mlx5/mlx5_flow_verbs.c          |    8 +-
 drivers/net/mvpp2/mrvl_flow.c               |   16 +-
 drivers/net/nfp/flower/nfp_flower_flow.c    |   34 +-
 drivers/net/nfp/nfp_ipsec.c                 |    4 +-
 drivers/net/nfp/nfp_net_flow.c              |   38 +-
 drivers/net/qede/qede_filter.c              |    4 +-
 drivers/net/sfc/sfc_flow.c                  |   22 +-
 drivers/net/tap/tap_flow.c                  |   14 +-
 drivers/net/txgbe/txgbe_flow.c              |   12 +-
 drivers/net/txgbe/txgbe_ipsec.c             |    4 +-
 examples/cmdline/commands.c                 |   30 +-
 examples/ip_fragmentation/main.c            |   23 +-
 examples/ip_pipeline/cli.c                  |   61 +-
 examples/ip_pipeline/parser.c               |    2 +-
 examples/ip_pipeline/parser.h               |    3 +-
 examples/ip_pipeline/pipeline.c             |   17 +-
 examples/ip_pipeline/pipeline.h             |    6 +-
 examples/ip_pipeline/thread.c               |   15 +-
 examples/ip_reassembly/main.c               |   23 +-
 examples/ipsec-secgw/flow.c                 |   45 +-
 examples/ipsec-secgw/ipsec.c                |   33 +-
 examples/ipsec-secgw/ipsec.h                |    5 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h       |    7 +-
 examples/ipsec-secgw/ipsec_worker.c         |   11 +-
 examples/ipsec-secgw/ipsec_worker.h         |    4 +-
 examples/ipsec-secgw/parser.c               |    2 +-
 examples/ipsec-secgw/parser.h               |    4 +-
 examples/ipsec-secgw/rt.c                   |   24 +-
 examples/ipsec-secgw/sa.c                   |   37 +-
 examples/ipsec-secgw/sad.h                  |   14 +-
 examples/ipsec-secgw/sp6.c                  |  154 +-
 examples/l3fwd-graph/main.c                 |   33 +-
 examples/l3fwd/l3fwd_fib.c                  |   39 +-
 examples/l3fwd/l3fwd_lpm.c                  |    8 +-
 examples/l3fwd/l3fwd_route.h                |    9 +-
 examples/l3fwd/lpm_route_parse.c            |    9 +-
 examples/l3fwd/main.c                       |   32 +-
 lib/cmdline/cmdline_parse_ipaddr.h          |    3 +-
 lib/ethdev/rte_flow.h                       |   27 +-
 lib/fib/meson.build                         |    4 +-
 lib/fib/rte_fib6.c                          |   19 +-
 lib/fib/rte_fib6.h                          |   16 +-
 lib/fib/trie.c                              |  117 +-
 lib/fib/trie.h                              |   19 +-
 lib/fib/trie_avx512.c                       |   38 +-
 lib/fib/trie_avx512.h                       |   10 +-
 lib/gro/gro_tcp6.c                          |    8 +-
 lib/gro/gro_tcp6.h                          |    6 +-
 lib/hash/rte_thash.h                        |   29 +-
 lib/ip_frag/rte_ip_frag.h                   |    1 +
 lib/ip_frag/rte_ipv6_reassembly.c           |    4 +-
 lib/ipsec/iph.h                             |    1 +
 lib/ipsec/rte_ipsec_sad.h                   |    5 +-
 lib/lpm/meson.build                         |    1 +
 lib/lpm/rte_lpm6.c                          |  148 +-
 lib/lpm/rte_lpm6.h                          |   19 +-
 lib/net/meson.build                         |    2 +
 lib/net/rte_cksum.h                         |  180 ++
 lib/net/rte_ip.h                            |  467 +----
 lib/net/rte_ip6.h                           |  691 +++++++
 lib/net/rte_net.c                           |    1 +
 lib/net/rte_net.h                           |    1 +
 lib/node/ip6_lookup.c                       |   21 +-
 lib/node/rte_node_ip6_api.h                 |    3 +-
 lib/pipeline/rte_swx_ipsec.c                |   11 +-
 lib/pipeline/rte_swx_ipsec.h                |    5 +-
 lib/pipeline/rte_table_action.c             |   45 +-
 lib/pipeline/rte_table_action.h             |    7 +-
 lib/rib/meson.build                         |    2 +-
 lib/rib/rte_rib6.c                          |  112 +-
 lib/rib/rte_rib6.h                          |   27 +-
Quoted 8 lines
 lib/security/rte_security.h                 |    5 +-
 lib/table/rte_table_lpm_ipv6.c              |   12 +-
 lib/table/rte_table_lpm_ipv6.h              |    7 +-
 lib/vhost/virtio_net.c                      |    1 +
 135 files changed, 3399 insertions(+), 3128 deletions(-)
 create mode 100644 app/test/test_net_ip6.c
 create mode 100644 lib/net/rte_cksum.h
 create mode 100644 lib/net/rte_ip6.h

- Now that many changes hit the main repo, this series needs some rebasing (conflicts are not too difficult, but having this rebase run through a bit in the CI would be great).

- From a compatibility pov, I am not fond of the rte_ip.h => rte_ip.h, rte_ip6.h split.

Applications will need to be updated for something that was ambiguous so far: rte_ip.h defined all symbols, regardless of IPv4 and IPv6. What do you think of keeping a rte_ip.h compat header that just includes new rte_ip4.h and rte_ip6.h headers?

- With current patch, since only rte_ip.h is parsed in doxygen, we lost documentation for IPv6.
Regardless of keeping a compat header, doc/api/doxy-api-index.md needs some update.

- bonus 1:
It would be worth cleaning unneeded includes in rte_ip*.h.
But changing this is risky if we want to take this series in rc1. Please don't do this in next revision, this will wait after merging this series.

For example, running iwyu returns:

lib/net/rte_ip.h should remove these lines:
- #include <arpa/inet.h> // lines 26-26
- #include <netinet/ip6.h> // lines 28-28
- #include <rte_mbuf.h> // lines 33-33
- #include <sys/socket.h> // lines 23-23
- #include <sys/types.h> // lines 24-24

lib/net/rte_ip6.h should remove these lines:
- #include <arpa/inet.h> // lines 26-26
- #include <netinet/ip6.h> // lines 27-27
- #include <rte_mbuf.h> // lines 31-31
- #include <sys/socket.h> // lines 23-23

- bonus 2:
Would it be possible to provide a cocci script or some shellscript for an application to convert to the updated APIs (especially the impact on rte_flow and other structures)?
We did something similar for the prefixing of dpdk structures with RTE_.

Idem, not necessary for rc1.

Signature · 1 line
David Marchand
#87 lore raw

David Marchand, Oct 17, 2024 at 15:52:

Quoted 2 lines

Hello Robin,

[snip]

Quoted 3 lines

- Now that many changes hit the main repo, this series needs some rebasing (conflicts are not too difficult, but having this rebase run through a bit in the CI would be great).

Will do.

Quoted 7 lines

- From a compatibility pov, I am not fond of the rte_ip.h => rte_ip.h, rte_ip6.h split.

Applications will need to be updated for something that was ambiguous so far: rte_ip.h defined all symbols, regardless of IPv4 and IPv6. What do you think of keeping a rte_ip.h compat header that just includes new rte_ip4.h and rte_ip6.h headers?

I can include rte_ip6.h in rte_ip.h for backward compatibility.

Quoted 4 lines

- With current patch, since only rte_ip.h is parsed in doxygen, we lost documentation for IPv6.
Regardless of keeping a compat header, doc/api/doxy-api-index.md needs some update.

Got it. I will add a new "IPv6" section in "layers" and a checksum section in "basic" (rte_cksum.h split also removed some symbols from the "IP" section).

Quoted 14 lines

- bonus 1:
It would be worth cleaning unneeded includes in rte_ip*.h.
But changing this is risky if we want to take this series in rc1. Please don't do this in next revision, this will wait after merging this series.

For example, running iwyu returns:

lib/net/rte_ip.h should remove these lines:
- #include <arpa/inet.h> // lines 26-26
- #include <netinet/ip6.h> // lines 28-28
- #include <rte_mbuf.h> // lines 33-33
- #include <sys/socket.h> // lines 23-23
- #include <sys/types.h> // lines 24-24

Quoted 5 lines

lib/net/rte_ip6.h should remove these lines:
- #include <arpa/inet.h> // lines 26-26
- #include <netinet/ip6.h> // lines 27-27
- #include <rte_mbuf.h> // lines 31-31
- #include <sys/socket.h> // lines 23-23

Ok, I will hold off changing this for now. Btw, rte_mbuf *is* actually used in rte_ip6.h. Maybe iwyu has some troubles identifying things :)

Quoted 7 lines

- bonus 2:
Would it be possible to provide a cocci script or some shellscript for an application to convert to the updated APIs (especially the impact on rte_flow and other structures)?
We did something similar for the prefixing of dpdk structures with RTE_.

Idem, not necessary for rc1.

I never used coccinelle and it may be complicated to come up with something reliable. It is not a simple renaming of symbols. It is a change of signature for a lot of functions. This would require extensive changes in the application code.

Cheers.

#88 lore raw

v4 cover IPv6 APIs overhaul

In reply to Robin Jarry

Hi everyone,

As discussed recently [1], here is a first draft of the IPv6 APIs rework. The API change was announced before the 24.07 release [2]. This series is intended for 24.11.

[1] http://inbox.dpdk.org/dev/[email protected]/
[2] https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc1b5764

I tried to keep the patches as small as possible; unfortunately some of them are quite big and cannot be broken down if we want to preserve a bisectable tree.

Thanks!

Cc Bruce Richardson <[email protected]>
Cc Ferruh Yigit <[email protected]>
Cc Konstantin Ananyev <[email protected]>
Cc Morten Brørup <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Vladimir Medvedkin <[email protected]>

Changelog:

v4:

- rebase on f0d9e787747d ("net/gve/base: fix build with Fedora Rawhide")
- split rte_ip.h into rte_ip4.h and rte_ip6.h
(keep rte_ip.h as combination of the two)
- fix doxygen index
- rephrase changelog
- split lpm6, rib6 and fib6 into separate commits
- split security, pipeline and ipsec into separate commits

Robin Jarry (17):
net: split raw checksum functions in separate header
net: split IPv4 and IPv6 symbols in separate headers
net: add IPv6 address structure and utils
net: use IPv6 structure for packet headers
lpm6: use IPv6 address structure and utils
fib6: use IPv6 address structure and utils
rib6: use IPv6 address structure and utils
cmdline: use IPv6 address structure
node: use IPv6 address structure and utils
pipeline: use IPv6 structures
ipsec: use IPv6 address structure
security: use IPv6 address structure
hash: use IPv6 address structure
gro: use IPv6 address structure
flow: use IPv6 address structure
net: add utilities for well known IPv6 address types
net: add function to check IPv6 version

 MAINTAINERS                              |    1 +
 app/graph/ethdev.c                       |   44 +-
 app/graph/ethdev.h                       |    9 +-
 app/graph/ip6_route.c                    |   51 +-
 app/graph/meson.build                    |    2 +-
 app/graph/neigh.c                        |   21 +-
 app/graph/neigh_priv.h                   |    4 +-
 app/graph/route.h                        |    8 +-
 app/test-fib/main.c                      |   74 +-
 app/test-flow-perf/actions_gen.c         |    4 +-
 app/test-flow-perf/items_gen.c           |    4 +-
 app/test-pipeline/pipeline_hash.c        |    4 +-
 app/test-pipeline/pipeline_lpm_ipv6.c    |   11 +-
 app/test-pmd/cmdline.c                   |    4 +-
 app/test-pmd/cmdline_flow.c              |   14 +-
 app/test-pmd/testpmd.h                   |   16 +-
 app/test-sad/main.c                      |   24 +-
 app/test/meson.build                     |    1 +
 app/test/packet_burst_generator.c        |    4 +-
 app/test/test_cmdline_ipaddr.c           |   49 +-
 app/test/test_fib6.c                     |   92 +-
 app/test/test_fib6_perf.c                |    8 +-
 app/test/test_ipfrag.c                   |    4 +-
 app/test/test_ipsec_sad.c                |   46 +-
 app/test/test_lpm6.c                     |  490 +++---
 app/test/test_lpm6_data.h                | 2025 +++++++++++-----------
 app/test/test_lpm6_perf.c                |   10 +-
 app/test/test_net_ip6.c                  |  195 +++
 app/test/test_reassembly_perf.c          |   23 +-
 app/test/test_rib6.c                     |   55 +-
 app/test/test_table_combined.c           |    2 +-
 app/test/test_table_tables.c             |    8 +-
 app/test/test_thash.c                    |   46 +-
 doc/api/doxy-api-index.md                |    4 +-
 doc/guides/prog_guide/ipsec_lib.rst      |    4 +-
 doc/guides/rel_notes/deprecation.rst     |   42 -
 doc/guides/rel_notes/release_24_11.rst   |   56 +
 drivers/common/cnxk/cnxk_security.c      |   14 +-
 drivers/net/bnxt/bnxt_flow.c             |   12 +-
 drivers/net/bonding/rte_eth_bond_pmd.c   |    6 +-
 drivers/net/cxgbe/cxgbe_flow.c           |   18 +-
 drivers/net/dpaa2/dpaa2_flow.c           |   22 +-
 drivers/net/hinic/hinic_pmd_flow.c       |    6 +-
 drivers/net/hinic/hinic_pmd_tx.c         |    2 +-
 drivers/net/hns3/hns3_flow.c             |    8 +-
 drivers/net/i40e/i40e_flow.c             |   12 +-
 drivers/net/iavf/iavf_fdir.c             |    8 +-
 drivers/net/iavf/iavf_fsub.c             |    8 +-
 drivers/net/iavf/iavf_ipsec_crypto.c     |    9 +-
 drivers/net/ice/ice_fdir_filter.c        |   12 +-
 drivers/net/ice/ice_switch_filter.c      |   16 +-
 drivers/net/igc/igc_flow.c               |    4 +-
 drivers/net/ixgbe/ixgbe_flow.c           |   12 +-
 drivers/net/ixgbe/ixgbe_ipsec.c          |    4 +-
 drivers/net/mlx5/hws/mlx5dr_definer.c    |   36 +-
 drivers/net/mlx5/mlx5_flow.c             |    6 +-
 drivers/net/mlx5/mlx5_flow_dv.c          |   16 +-
 drivers/net/mlx5/mlx5_flow_hw.c          |   10 +-
 drivers/net/mlx5/mlx5_flow_verbs.c       |    8 +-
 drivers/net/mvpp2/mrvl_flow.c            |   16 +-
 drivers/net/nfp/flower/nfp_flower_flow.c |   34 +-
 drivers/net/nfp/nfp_ipsec.c              |    4 +-
 drivers/net/nfp/nfp_net_flow.c           |   38 +-
 drivers/net/qede/qede_filter.c           |    4 +-
 drivers/net/sfc/sfc_flow.c               |   22 +-
 drivers/net/tap/tap_flow.c               |   10 +-
 drivers/net/txgbe/txgbe_flow.c           |   12 +-
 drivers/net/txgbe/txgbe_ipsec.c          |    4 +-
 examples/cmdline/commands.c              |   30 +-
 examples/ip_fragmentation/main.c         |   23 +-
 examples/ip_pipeline/cli.c               |   61 +-
 examples/ip_pipeline/parser.c            |    2 +-
 examples/ip_pipeline/parser.h            |    3 +-
 examples/ip_pipeline/pipeline.c          |   16 +-
 examples/ip_pipeline/pipeline.h          |    6 +-
 examples/ip_pipeline/thread.c            |   15 +-
 examples/ip_reassembly/main.c            |   23 +-
 examples/ipsec-secgw/flow.c              |   45 +-
 examples/ipsec-secgw/ipsec.c             |   33 +-
 examples/ipsec-secgw/ipsec.h             |    5 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h    |    7 +-
 examples/ipsec-secgw/ipsec_worker.c      |   11 +-
 examples/ipsec-secgw/ipsec_worker.h      |    4 +-
 examples/ipsec-secgw/parser.c            |    2 +-
 examples/ipsec-secgw/parser.h            |    4 +-
 examples/ipsec-secgw/rt.c                |   24 +-
 examples/ipsec-secgw/sa.c                |   37 +-
 examples/ipsec-secgw/sad.h               |   14 +-
 examples/ipsec-secgw/sp6.c               |  154 +-
 examples/l3fwd-graph/main.c              |   33 +-
 examples/l3fwd/l3fwd_fib.c               |   39 +-
 examples/l3fwd/l3fwd_lpm.c               |    8 +-
 examples/l3fwd/l3fwd_route.h             |    9 +-
 examples/l3fwd/lpm_route_parse.c         |    9 +-
 examples/l3fwd/main.c                    |   32 +-
 lib/cmdline/cmdline_parse_ipaddr.h       |    3 +-
 lib/ethdev/rte_flow.h                    |   22 +-
 lib/fib/meson.build                      |    3 +-
 lib/fib/rte_fib6.c                       |   19 +-
 lib/fib/rte_fib6.h                       |   16 +-
 lib/fib/trie.c                           |  117 +-
 lib/fib/trie.h                           |   19 +-
 lib/fib/trie_avx512.c                    |   38 +-
 lib/fib/trie_avx512.h                    |   10 +-
 lib/gro/gro_tcp6.c                       |    8 +-
 lib/gro/gro_tcp6.h                       |    6 +-
 lib/hash/rte_thash.h                     |   28 +-
 lib/ip_frag/rte_ipv6_reassembly.c        |    4 +-
 lib/ipsec/rte_ipsec_sad.h                |    5 +-
 lib/lpm/meson.build                      |    1 +
 lib/lpm/rte_lpm6.c                       |  148 +-
 lib/lpm/rte_lpm6.h                       |   19 +-
 lib/net/meson.build                      |    3 +
 lib/net/rte_cksum.h                      |  180 ++
 lib/net/rte_ip.h                         |  840 +--------
 lib/net/rte_ip4.h                        |  381 ++++
 lib/net/rte_ip6.h                        |  691 ++++++++
 lib/node/ip6_lookup.c                    |   21 +-
 lib/node/rte_node_ip6_api.h              |    3 +-
 lib/pipeline/rte_swx_ipsec.c             |   10 +-
 lib/pipeline/rte_swx_ipsec.h             |    5 +-
 lib/pipeline/rte_table_action.c          |   44 +-
 lib/pipeline/rte_table_action.h          |    7 +-
 lib/rib/meson.build                      |    2 +-
 lib/rib/rte_rib6.c                       |  112 +-
 lib/rib/rte_rib6.h                       |   27 +-
 lib/security/rte_security.h              |    5 +-
 lib/table/rte_table_lpm_ipv6.c           |   12 +-
 lib/table/rte_table_lpm_ipv6.h           |    7 +-
 129 files changed, 3817 insertions(+), 3500 deletions(-)
 create mode 100644 app/test/test_net_ip6.c
 create mode 100644 lib/net/rte_cksum.h
 create mode 100644 lib/net/rte_ip4.h
 create mode 100644 lib/net/rte_ip6.h
Signature · 1 line
2.47.0
#89 lore raw

PATCH v4 1/17 net: split raw checksum functions in separate header

The checksum functions are used by both ipv4 and ipv6 functions. In preparation of moving ipv6 symbols to a new header, move the checksum related symbols to another dedicated header.

Update doxygen index accordingly.

---
 doc/api/doxy-api-index.md |   1 +
 lib/net/meson.build       |   1 +
 lib/net/rte_cksum.h       | 180 ++++++++++++++++++++++++++++++++++++++
 lib/net/rte_ip.h          | 148 +------------------------------
 4 files changed, 183 insertions(+), 147 deletions(-)
 create mode 100644 lib/net/rte_cksum.h
doc/api/doxy-api-index.md +1 -0
index 27e66d1406c8..8b83af53a863 100644
@@ -221,6 +221,7 @@ The public API headers are grouped by topics:
   [bitops](@ref rte_bitops.h),
   [approx fraction](@ref rte_approx.h),
   [random](@ref rte_random.h),
+  [checksum](@ref rte_cksum.h),
   [config file](@ref rte_cfgfile.h),
   [key/value args](@ref rte_kvargs.h),
   [argument parsing](@ref rte_argparse.h),
lib/net/meson.build +1 -0
index 06da7338ba97..63d2fabbaf6c 100644
@@ -3,6 +3,7 @@
 
 headers = files(
         'rte_ip.h',
+        'rte_cksum.h',
         'rte_tcp.h',
         'rte_udp.h',
         'rte_tls.h',
lib/net/rte_cksum.h new file +180 -0

180 lines not on this page · raw message

lib/net/rte_ip.h +1 -147

160 lines not on this page · raw message

Signature · 1 line
2.47.0
#90 lore raw

PATCH v4 2/17 net: split IPv4 and IPv6 symbols in separate headers

In reply to Robin Jarry

Split IPv4 and IPv6 symbols in two separate headers. rte_ip4.h and rte_ip6.h, respectively.

Update doxygen index accordingly.

Include rte_ip4.h and rte_ip6.h in rte_ip.h for backward compatibility in applications.

---
 doc/api/doxy-api-index.md       |   3 +-
 lib/net/meson.build             |   2 +
 lib/net/rte_ip.h                | 694 +-------------------------------
 lib/net/{rte_ip.h => rte_ip4.h} | 325 +--------------
 lib/net/{rte_ip.h => rte_ip6.h} | 352 +---------------
 5 files changed, 16 insertions(+), 1360 deletions(-)
 copy lib/net/{rte_ip.h => rte_ip4.h} (52%)
 copy lib/net/{rte_ip.h => rte_ip6.h} (50%)
doc/api/doxy-api-index.md +2 -1
index 8b83af53a863..266c8b90dcfb 100644
@@ -117,7 +117,8 @@ The public API headers are grouped by topics:
   [IPsec group](@ref rte_ipsec_group.h),
   [IPsec SA](@ref rte_ipsec_sa.h),
   [IPsec SAD](@ref rte_ipsec_sad.h),
-  [IP](@ref rte_ip.h),
+  [IPv4](@ref rte_ip4.h),
+  [IPv6](@ref rte_ip6.h),
   [frag/reass](@ref rte_ip_frag.h),
   [UDP](@ref rte_udp.h),
   [SCTP](@ref rte_sctp.h),
lib/net/meson.build +2 -0
index 63d2fabbaf6c..3406cb6ca543 100644
@@ -3,6 +3,8 @@
 
 headers = files(
         'rte_ip.h',
+        'rte_ip4.h',
+        'rte_ip6.h',
         'rte_cksum.h',
         'rte_tcp.h',
         'rte_udp.h',
lib/net/rte_ip.h +3 -691

703 lines not on this page · raw message

lib/net/rte_ip4.h renamed from lib/net/rte_ip.h +3 -322

341 lines not on this page · raw message

lib/net/rte_ip6.h renamed from lib/net/rte_ip.h +6 -346

385 lines not on this page · raw message

Signature · 1 line
2.47.0
#91 lore raw

PATCH v4 3/17 net: add IPv6 address structure and utils

In reply to Robin Jarry

There is currently no structure defined for IPv6 addresses. Introduce one that is simply a uint8_t array of 16 elements. The idea is to ensure this structure alignment is 1 so that it can be mapped directly on unaligned packet memory.

Add utility functions and macros that use the newly added rte_ipv6_addr structure. Add basic unit tests to ensure everything works as expected.

These functions will be used in the next commits to replace private and/or duplicated functions.

---
 MAINTAINERS                            |   1 +
 app/test/meson.build                   |   1 +
 app/test/test_net_ip6.c                | 111 ++++++++++++++++
 doc/guides/rel_notes/release_24_11.rst |   5 +
 lib/net/rte_ip6.h                      | 174 +++++++++++++++++++++++++
 5 files changed, 292 insertions(+)
 create mode 100644 app/test/test_net_ip6.c
MAINTAINERS +1 -0
index f09cda04c87d..b94bf57a2034 100644
@@ -1526,6 +1526,7 @@ F: lib/net/
 F: app/test/test_cksum.c
 F: app/test/test_cksum_perf.c
 F: app/test/test_net_ether.c
+F: app/test/test_net_ip6.c
 
 Packet CRC
 M: Jasvinder Singh <[email protected]>
app/test/meson.build +1 -0
index fe248b786c8e..0f7e11969a44 100644
@@ -131,6 +131,7 @@ source_file_deps = {
     'test_metrics.c': ['metrics'],
     'test_mp_secondary.c': ['hash'],
     'test_net_ether.c': ['net'],
+    'test_net_ip6.c': ['net'],
     'test_pcapng.c': ['ethdev', 'net', 'pcapng', 'bus_vdev'],
     'test_pdcp.c': ['eventdev', 'pdcp', 'net', 'timer', 'security'],
     'test_pdump.c': ['pdump'] + sample_packet_forward_deps,
app/test/test_net_ip6.c new file +111 -0

111 lines not on this page · raw message

doc/guides/rel_notes/release_24_11.rst +5 -0
index d2301461ce35..e68676caf029 100644
@@ -238,6 +238,11 @@ New Features
   Added ability for node to advertise and update multiple xstat counters,
   that can be retrieved using ``rte_graph_cluster_stats_get``.
 
+* **Added IPv6 address structure and related utilities.**
+
+  A new IPv6 address structure is now available in ``rte_ip6.h``.
+  It comes with a set of helper functions and macros.
+
 
 Removed Items
 -------------
lib/net/rte_ip6.h +174 -0

186 lines not on this page · raw message

Signature · 1 line
2.47.0
#92 lore raw

PATCH v4 4/17 net: use IPv6 structure for packet headers

In reply to Robin Jarry

The rte_ipv6_hdr uses ad-hoc uint8_t[16] arrays to represent addresses. Replace these arrays with the newly added rte_ipv6_addr structure. Adapt all code accordingly.

---
 app/test-flow-perf/items_gen.c           |  4 +--
 app/test-pipeline/pipeline_hash.c        |  4 +--
 app/test/packet_burst_generator.c        |  4 +--
 app/test/test_ipfrag.c                   |  4 +--
 app/test/test_reassembly_perf.c          | 23 +++++++-------
 app/test/test_thash.c                    |  8 ++---
 doc/guides/rel_notes/deprecation.rst     |  2 --
 doc/guides/rel_notes/release_24_11.rst   |  6 ++++
 drivers/net/bnxt/bnxt_flow.c             | 12 ++++----
 drivers/net/bonding/rte_eth_bond_pmd.c   |  6 ++--
 drivers/net/cxgbe/cxgbe_flow.c           | 14 ++++-----
 drivers/net/dpaa2/dpaa2_flow.c           | 22 +++++++-------
 drivers/net/hinic/hinic_pmd_flow.c       |  6 ++--
 drivers/net/hinic/hinic_pmd_tx.c         |  2 +-
 drivers/net/hns3/hns3_flow.c             |  8 ++---
 drivers/net/i40e/i40e_flow.c             | 12 ++++----
 drivers/net/iavf/iavf_fdir.c             |  8 ++---
 drivers/net/iavf/iavf_fsub.c             |  8 ++---
 drivers/net/iavf/iavf_ipsec_crypto.c     |  6 ++--
 drivers/net/ice/ice_fdir_filter.c        | 12 ++++----
 drivers/net/ice/ice_switch_filter.c      | 16 +++++-----
 drivers/net/igc/igc_flow.c               |  4 +--
 drivers/net/ixgbe/ixgbe_flow.c           | 12 ++++----
 drivers/net/ixgbe/ixgbe_ipsec.c          |  4 +--
 drivers/net/mlx5/hws/mlx5dr_definer.c    | 36 +++++++++++-----------
 drivers/net/mlx5/mlx5_flow.c             |  6 ++--
 drivers/net/mlx5/mlx5_flow_dv.c          | 16 ++++------
 drivers/net/mlx5/mlx5_flow_hw.c          | 10 +++----
 drivers/net/mlx5/mlx5_flow_verbs.c       |  8 ++---
 drivers/net/mvpp2/mrvl_flow.c            | 16 ++++------
 drivers/net/nfp/flower/nfp_flower_flow.c | 32 ++++++++++----------
 drivers/net/nfp/nfp_net_flow.c           | 38 +++++++++++-------------
 drivers/net/qede/qede_filter.c           |  4 +--
 drivers/net/sfc/sfc_flow.c               | 22 +++++---------
 drivers/net/tap/tap_flow.c               | 10 +++----
 drivers/net/txgbe/txgbe_flow.c           | 12 ++++----
 drivers/net/txgbe/txgbe_ipsec.c          |  4 +--
 examples/ip_fragmentation/main.c         |  2 +-
 examples/ip_pipeline/pipeline.c          | 16 +++++-----
 examples/ip_reassembly/main.c            |  2 +-
 examples/ipsec-secgw/flow.c              | 33 ++++----------------
 examples/ipsec-secgw/ipsec.c             |  8 ++---
 examples/ipsec-secgw/sa.c                |  4 +--
 examples/ipsec-secgw/sad.h               | 10 ++++---
 examples/l3fwd/l3fwd_fib.c               |  2 +-
 examples/l3fwd/l3fwd_lpm.c               |  4 +--
 lib/ethdev/rte_flow.h                    |  6 ++--
 lib/hash/rte_thash.h                     | 12 ++++----
 lib/ip_frag/rte_ipv6_reassembly.c        |  4 +--
 lib/net/rte_ip6.h                        |  6 ++--
 lib/node/ip6_lookup.c                    | 10 +++----
 lib/pipeline/rte_swx_ipsec.c             |  6 ++--
 lib/pipeline/rte_table_action.c          | 24 +++++++--------
 53 files changed, 260 insertions(+), 310 deletions(-)
app/test-flow-perf/items_gen.c +2 -2
index 4ae72509d445..c740e1838ffb 100644
@@ -78,8 +78,8 @@ add_ipv6(struct rte_flow_item *items,
 	for (i = 0; i < 16; i++) {
 		/* Currently src_ip is limited to 32 bit */
 		if (i < 4)
-			ipv6_specs[ti].hdr.src_addr[15 - i] = para.src_ip >> (i * 8);
-		ipv6_masks[ti].hdr.src_addr[15 - i] = 0xff;
+			ipv6_specs[ti].hdr.src_addr.a[15 - i] = para.src_ip >> (i * 8);
+		ipv6_masks[ti].hdr.src_addr.a[15 - i] = 0xff;
 	}
 
 	items[items_counter].type = RTE_FLOW_ITEM_TYPE_IPV6;
app/test-pipeline/pipeline_hash.c +1 -3
index cab9c2098014..194e5c5dcc53 100644
@@ -432,7 +432,6 @@ app_main_loop_rx_metadata(void) {
 				struct rte_ipv4_hdr *ip_hdr;
 				struct rte_ipv6_hdr *ipv6_hdr;
 				uint32_t ip_dst;
-				uint8_t *ipv6_dst;
 				uint32_t *signature, *k32;
 
 				m = app.mbuf_rx.array[j];
@@ -452,9 +451,8 @@ app_main_loop_rx_metadata(void) {
 				} else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
 					ipv6_hdr = (struct rte_ipv6_hdr *)
 						&m_data[sizeof(struct rte_ether_hdr)];
-					ipv6_dst = ipv6_hdr->dst_addr;
 
-					memcpy(key, ipv6_dst, 16);
+					memcpy(key, &ipv6_hdr->dst_addr, 16);
 				} else
 					continue;
 
app/test/packet_burst_generator.c +2 -2
index 867a88da0055..c9ff5257f070 100644
@@ -148,8 +148,8 @@ initialize_ipv6_header(struct rte_ipv6_hdr *ip_hdr, uint8_t *src_addr,
 	ip_hdr->proto = IPPROTO_UDP;
 	ip_hdr->hop_limits = IP_DEFTTL;
 
-	rte_memcpy(ip_hdr->src_addr, src_addr, sizeof(ip_hdr->src_addr));
-	rte_memcpy(ip_hdr->dst_addr, dst_addr, sizeof(ip_hdr->dst_addr));
+	rte_memcpy(&ip_hdr->src_addr, src_addr, sizeof(ip_hdr->src_addr));
+	rte_memcpy(&ip_hdr->dst_addr, dst_addr, sizeof(ip_hdr->dst_addr));
 
 	return (uint16_t) (pkt_data_len + sizeof(struct rte_ipv6_hdr));
 }
app/test/test_ipfrag.c +2 -2
index 8e4df220a214..18d672715729 100644
@@ -238,8 +238,8 @@ v6_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s, uint8_t ttl,
 	hdr->proto = proto;
 	hdr->hop_limits = ttl;
 
-	memset(hdr->src_addr, 0x08, sizeof(hdr->src_addr));
-	memset(hdr->dst_addr, 0x04, sizeof(hdr->src_addr));
+	memset(&hdr->src_addr, 0x08, sizeof(hdr->src_addr));
+	memset(&hdr->dst_addr, 0x04, sizeof(hdr->src_addr));
 }
 
 static inline void
app/test/test_reassembly_perf.c +12 -11
index 3912179022fc..15db19add917 100644
@@ -8,6 +8,7 @@
 #include <rte_ether.h>
 #include <rte_hexdump.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_ip_frag.h>
 #include <rte_mbuf.h>
 #include <rte_mbuf_pool_ops.h>
@@ -36,7 +37,7 @@
 #define IP_DST_ADDR(x) ((198U << 24) | (18 << 16) | (1 << 15) | (x))
 
 /* 2001:0200::/48 is IANA reserved range for IPv6 benchmarking (RFC5180) */
-static uint8_t ip6_addr[16] = {32, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+static struct rte_ipv6_addr ip6_addr = RTE_IPV6(0x2001, 0x0200, 0, 0, 0, 0, 0, 0);
 #define IP6_VERSION 6
 
 #define IP_DEFTTL 64 /* from RFC 1340. */
@@ -340,17 +341,17 @@ ipv6_frag_fill_data(struct rte_mbuf **mbuf, uint8_t nb_frags, uint32_t flow_id,
 			rte_cpu_to_be_16(pkt_len - sizeof(struct rte_ipv6_hdr));
 		ip_hdr->proto = IPPROTO_FRAGMENT;
 		ip_hdr->hop_limits = IP_DEFTTL;
-		memcpy(ip_hdr->src_addr, ip6_addr, sizeof(ip_hdr->src_addr));
-		memcpy(ip_hdr->dst_addr, ip6_addr, sizeof(ip_hdr->dst_addr));
-		ip_hdr->src_addr[7] = (flow_id >> 16) & 0xf;
-		ip_hdr->src_addr[7] |= 0x10;
-		ip_hdr->src_addr[8] = (flow_id >> 8) & 0xff;
-		ip_hdr->src_addr[9] = flow_id & 0xff;
+		ip_hdr->src_addr = ip6_addr;
+		ip_hdr->dst_addr = ip6_addr;
+		ip_hdr->src_addr.a[7] = (flow_id >> 16) & 0xf;
+		ip_hdr->src_addr.a[7] |= 0x10;
+		ip_hdr->src_addr.a[8] = (flow_id >> 8) & 0xff;
+		ip_hdr->src_addr.a[9] = flow_id & 0xff;
 
-		ip_hdr->dst_addr[7] = (flow_id >> 16) & 0xf;
-		ip_hdr->dst_addr[7] |= 0x20;
-		ip_hdr->dst_addr[8] = (flow_id >> 8) & 0xff;
-		ip_hdr->dst_addr[9] = flow_id & 0xff;
+		ip_hdr->dst_addr.a[7] = (flow_id >> 16) & 0xf;
+		ip_hdr->dst_addr.a[7] |= 0x20;
+		ip_hdr->dst_addr.a[8] = (flow_id >> 8) & 0xff;
+		ip_hdr->dst_addr.a[9] = flow_id & 0xff;
 
 		frag_hdr->next_header = IPPROTO_UDP;
 		frag_hdr->reserved = 0;
app/test/test_thash.c +4 -4
index 65d42fd90085..952da6a52954 100644
@@ -145,10 +145,10 @@ test_toeplitz_hash_calc(void)
 	}
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
 		/*Fill ipv6 hdr*/
-		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr); j++)
-			ipv6_hdr.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr); j++)
-			ipv6_hdr.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr.a); j++)
+			ipv6_hdr.src_addr.a[j] = v6_tbl[i].src_ip[j];
+		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr.a); j++)
+			ipv6_hdr.dst_addr.a[j] = v6_tbl[i].dst_ip[j];
 		/*Load and convert ipv6 address into tuple*/
 		rte_thash_load_v6_addrs(&ipv6_hdr, &tuple);
 		tuple.v6.sport = v6_tbl[i].src_port;
doc/guides/rel_notes/deprecation.rst +0 -2
index 20fcfedb7b89..830904203c38 100644
@@ -87,8 +87,6 @@ Deprecation Notices
     - ``rte_lpm6_delete_bulk_func()``
     - ``rte_lpm6_lookup()``
     - ``rte_lpm6_lookup_bulk_func()``
-  net
-    - ``struct rte_ipv6_hdr``
   node
     - ``rte_node_ip6_route_add()``
   pipeline
doc/guides/rel_notes/release_24_11.rst +6 -0
index e68676caf029..de24705ef662 100644
@@ -286,6 +286,12 @@ API Changes
 * drivers/net/ena: Removed ``enable_llq``, ``normal_llq_hdr`` and ``large_llq_hdr`` devargs
   and replaced it with a new shared devarg ``llq_policy`` that keeps the same logic.
 
+* net: A new IPv6 address structure was introduced to replace ad-hoc ``uint8_t[16]`` arrays.
+  The following libraries and symbols were modified:
+
+  net
+    - ``struct rte_ipv6_hdr``
+
 
 ABI Changes
 -----------
drivers/net/bnxt/bnxt_flow.c +6 -6
index 03413e912149..c41403c753cf 100644
@@ -424,22 +424,22 @@ bnxt_validate_and_parse_flow_type(const struct rte_flow_attr *attr,
 					EM_FLOW_ALLOC_INPUT_EN_DST_IPADDR;
 
 			rte_memcpy(filter->src_ipaddr,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(filter->dst_ipaddr,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 
-			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.src_addr,
+			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.src_addr.a,
 						   16)) {
 				rte_memcpy(filter->src_ipaddr_mask,
-					   ipv6_mask->hdr.src_addr, 16);
+					   &ipv6_mask->hdr.src_addr, 16);
 				en |= !use_ntuple ? 0 :
 				    NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_IPADDR_MASK;
 			}
 
-			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.dst_addr,
+			if (!bnxt_check_zero_bytes(ipv6_mask->hdr.dst_addr.a,
 						   16)) {
 				rte_memcpy(filter->dst_ipaddr_mask,
-					   ipv6_mask->hdr.dst_addr, 16);
+					   &ipv6_mask->hdr.dst_addr, 16);
 				en |= !use_ntuple ? 0 :
 				     NTUPLE_FLTR_ALLOC_INPUT_EN_DST_IPADDR_MASK;
 			}
drivers/net/bonding/rte_eth_bond_pmd.c +2 -4
index 34131f0e35f6..cda1c37124f4 100644
@@ -689,10 +689,8 @@ ipv4_hash(struct rte_ipv4_hdr *ipv4_hdr)
 static inline uint32_t
 ipv6_hash(struct rte_ipv6_hdr *ipv6_hdr)
 {
-	unaligned_uint32_t *word_src_addr =
-		(unaligned_uint32_t *)&(ipv6_hdr->src_addr[0]);
-	unaligned_uint32_t *word_dst_addr =
-		(unaligned_uint32_t *)&(ipv6_hdr->dst_addr[0]);
+	unaligned_uint32_t *word_src_addr = (unaligned_uint32_t *)&ipv6_hdr->src_addr;
+	unaligned_uint32_t *word_dst_addr = (unaligned_uint32_t *)&ipv6_hdr->dst_addr;
 
 	return (word_src_addr[0] ^ word_dst_addr[0]) ^
 			(word_src_addr[1] ^ word_dst_addr[1]) ^
drivers/net/cxgbe/cxgbe_flow.c +6 -8
index 40d21e694409..b6d169097c1a 100644
@@ -411,15 +411,15 @@ ch_rte_parsetype_ipv6(const void *dmask, const struct rte_flow_item *item,
 			      RTE_IPV6_HDR_TC_SHIFT,
 			      tos);
 
-	if (memcmp(val->hdr.dst_addr, z, sizeof(val->hdr.dst_addr)) ||
+	if (memcmp(&val->hdr.dst_addr, z, sizeof(val->hdr.dst_addr)) ||
 	    (umask &&
-	     memcmp(umask->hdr.dst_addr, z, sizeof(umask->hdr.dst_addr))))
+	     memcmp(&umask->hdr.dst_addr, z, sizeof(umask->hdr.dst_addr))))
 		CXGBE_FILL_FS_MEMCPY(val->hdr.dst_addr, mask->hdr.dst_addr,
 				     lip);
 
-	if (memcmp(val->hdr.src_addr, z, sizeof(val->hdr.src_addr)) ||
+	if (memcmp(&val->hdr.src_addr, z, sizeof(val->hdr.src_addr)) ||
 	    (umask &&
-	     memcmp(umask->hdr.src_addr, z, sizeof(umask->hdr.src_addr))))
+	     memcmp(&umask->hdr.src_addr, z, sizeof(umask->hdr.src_addr))))
 		CXGBE_FILL_FS_MEMCPY(val->hdr.src_addr, mask->hdr.src_addr,
 				     fip);
 
@@ -918,10 +918,8 @@ static struct chrte_fparse parseitem[] = {
 		.fptr  = ch_rte_parsetype_ipv6,
 		.dmask = &(const struct rte_flow_item_ipv6) {
 			.hdr = {
-				.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-					      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-				.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-					      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+				.src_addr = RTE_IPV6_MASK_FULL,
+				.dst_addr = RTE_IPV6_MASK_FULL,
 				.vtc_flow = RTE_BE32(0xff000000),
 			},
 		},
drivers/net/dpaa2/dpaa2_flow.c +10 -12
index 1b55d8dd173b..54b17e97c031 100644
@@ -117,10 +117,8 @@ static const struct rte_flow_item_ipv4 dpaa2_flow_item_ipv4_mask = {
 
 static const struct rte_flow_item_ipv6 dpaa2_flow_item_ipv6_mask = {
 	.hdr = {
-		.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-			      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-		.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-			      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+		.src_addr = RTE_IPV6_MASK_FULL,
+		.dst_addr = RTE_IPV6_MASK_FULL,
 		.proto = 0xff
 	},
 };
@@ -1478,16 +1476,16 @@ dpaa2_configure_flow_generic_ip(
 		mask_ipv4->hdr.dst_addr)) {
 		flow->ipaddr_rule.ipaddr_type = FLOW_IPV4_ADDR;
 	} else if (mask_ipv6 &&
-		(memcmp((const char *)mask_ipv6->hdr.src_addr,
+		(memcmp(&mask_ipv6->hdr.src_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE) ||
-		memcmp((const char *)mask_ipv6->hdr.dst_addr,
+		memcmp(&mask_ipv6->hdr.dst_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		flow->ipaddr_rule.ipaddr_type = FLOW_IPV6_ADDR;
 	}
 
 	if ((mask_ipv4 && mask_ipv4->hdr.src_addr) ||
 		(mask_ipv6 &&
-			memcmp((const char *)mask_ipv6->hdr.src_addr,
+			memcmp(&mask_ipv6->hdr.src_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		index = dpaa2_flow_extract_search(
 				&priv->extract.qos_key_extract.dpkg,
@@ -1526,13 +1524,13 @@ dpaa2_configure_flow_generic_ip(
 		if (spec_ipv4)
 			key = &spec_ipv4->hdr.src_addr;
 		else
-			key = &spec_ipv6->hdr.src_addr[0];
+			key = &spec_ipv6->hdr.src_addr;
 		if (mask_ipv4) {
 			mask = &mask_ipv4->hdr.src_addr;
 			size = NH_FLD_IPV4_ADDR_SIZE;
 			prot = NET_PROT_IPV4;
 		} else {
-			mask = &mask_ipv6->hdr.src_addr[0];
+			mask = &mask_ipv6->hdr.src_addr;
 			size = NH_FLD_IPV6_ADDR_SIZE;
 			prot = NET_PROT_IPV6;
 		}
@@ -1569,7 +1567,7 @@ dpaa2_configure_flow_generic_ip(
 
 	if ((mask_ipv4 && mask_ipv4->hdr.dst_addr) ||
 		(mask_ipv6 &&
-			memcmp((const char *)mask_ipv6->hdr.dst_addr,
+			memcmp(&mask_ipv6->hdr.dst_addr,
 				zero_cmp, NH_FLD_IPV6_ADDR_SIZE))) {
 		index = dpaa2_flow_extract_search(
 				&priv->extract.qos_key_extract.dpkg,
@@ -1616,13 +1614,13 @@ dpaa2_configure_flow_generic_ip(
 		if (spec_ipv4)
 			key = &spec_ipv4->hdr.dst_addr;
 		else
-			key = spec_ipv6->hdr.dst_addr;
+			key = &spec_ipv6->hdr.dst_addr;
 		if (mask_ipv4) {
 			mask = &mask_ipv4->hdr.dst_addr;
 			size = NH_FLD_IPV4_ADDR_SIZE;
 			prot = NET_PROT_IPV4;
 		} else {
-			mask = &mask_ipv6->hdr.dst_addr[0];
+			mask = &mask_ipv6->hdr.dst_addr;
 			size = NH_FLD_IPV6_ADDR_SIZE;
 			prot = NET_PROT_IPV6;
 		}
drivers/net/hinic/hinic_pmd_flow.c +3 -3
index d1a564a16303..8fdd5a35be9f 100644
@@ -962,7 +962,7 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item,
 
 		/* check ipv6 src addr mask, ipv6 src addr is 16 bytes */
 		for (i = 0; i < 16; i++) {
-			if (ipv6_mask->hdr.src_addr[i] == UINT8_MAX) {
+			if (ipv6_mask->hdr.src_addr.a[i] == UINT8_MAX) {
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM, item,
 					"Not supported by fdir filter, do not support src ipv6");
@@ -978,13 +978,13 @@ static int hinic_normal_item_check_ip(const struct rte_flow_item **in_out_item,
 		}
 
 		for (i = 0; i < 16; i++) {
-			if (ipv6_mask->hdr.dst_addr[i] == UINT8_MAX)
+			if (ipv6_mask->hdr.dst_addr.a[i] == UINT8_MAX)
 				rule->mask.dst_ipv6_mask |= 1 << i;
 		}
 
 		ipv6_spec = (const struct rte_flow_item_ipv6 *)item->spec;
 		rte_memcpy(rule->hinic_fdir.dst_ipv6,
-			   ipv6_spec->hdr.dst_addr, 16);
+			   &ipv6_spec->hdr.dst_addr, 16);
 
 		/*
 		 * Check if the next not void item is TCP or UDP or ICMP.
drivers/net/hinic/hinic_pmd_tx.c +1 -1
index f09b1a6e1ea6..22fb0bffafcc 100644
@@ -743,7 +743,7 @@ hinic_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 	else
 		psd_hdr.len = ipv6_hdr->payload_len;
 
-	sum = __rte_raw_cksum(ipv6_hdr->src_addr,
+	sum = __rte_raw_cksum(&ipv6_hdr->src_addr,
 		sizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr), 0);
 	sum = __rte_raw_cksum(&psd_hdr, sizeof(psd_hdr), sum);
 	return __rte_raw_cksum_reduce(sum);
drivers/net/hns3/hns3_flow.c +4 -4
index 37eb2b4c3807..bf1eee506dde 100644
@@ -822,10 +822,10 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 						  "Only support src & dst ip,proto in IPV6");
 		}
 		net_addr_to_host(rule->key_conf.mask.src_ip,
-				 (const rte_be32_t *)ipv6_mask->hdr.src_addr,
+				 (const rte_be32_t *)&ipv6_mask->hdr.src_addr,
 				 IP_ADDR_LEN);
 		net_addr_to_host(rule->key_conf.mask.dst_ip,
-				 (const rte_be32_t *)ipv6_mask->hdr.dst_addr,
+				 (const rte_be32_t *)&ipv6_mask->hdr.dst_addr,
 				 IP_ADDR_LEN);
 		rule->key_conf.mask.ip_proto = ipv6_mask->hdr.proto;
 		if (rule->key_conf.mask.src_ip[IP_ADDR_KEY_ID])
@@ -838,10 +838,10 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule,
 
 	ipv6_spec = item->spec;
 	net_addr_to_host(rule->key_conf.spec.src_ip,
-			 (const rte_be32_t *)ipv6_spec->hdr.src_addr,
+			 (const rte_be32_t *)&ipv6_spec->hdr.src_addr,
 			 IP_ADDR_LEN);
 	net_addr_to_host(rule->key_conf.spec.dst_ip,
-			 (const rte_be32_t *)ipv6_spec->hdr.dst_addr,
+			 (const rte_be32_t *)&ipv6_spec->hdr.dst_addr,
 			 IP_ADDR_LEN);
 	rule->key_conf.spec.ip_proto = ipv6_spec->hdr.proto;
 
drivers/net/i40e/i40e_flow.c +6 -6
index 92165c8422d5..c6857727e8be 100644
@@ -1953,13 +1953,13 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 					return -rte_errno;
 				}
 
-				if (!memcmp(ipv6_mask->hdr.src_addr,
+				if (!memcmp(&ipv6_mask->hdr.src_addr,
 					    ipv6_addr_mask,
-					    RTE_DIM(ipv6_mask->hdr.src_addr)))
+					    sizeof(ipv6_mask->hdr.src_addr)))
 					input_set |= I40E_INSET_IPV6_SRC;
-				if (!memcmp(ipv6_mask->hdr.dst_addr,
+				if (!memcmp(&ipv6_mask->hdr.dst_addr,
 					    ipv6_addr_mask,
-					    RTE_DIM(ipv6_mask->hdr.dst_addr)))
+					    sizeof(ipv6_mask->hdr.dst_addr)))
 					input_set |= I40E_INSET_IPV6_DST;
 
 				if ((ipv6_mask->hdr.vtc_flow &
@@ -1987,9 +1987,9 @@ i40e_flow_parse_fdir_pattern(struct rte_eth_dev *dev,
 					I40E_FDIR_IPTYPE_IPV6;
 
 				rte_memcpy(filter->input.flow.ipv6_flow.src_ip,
-					   ipv6_spec->hdr.src_addr, 16);
+					   &ipv6_spec->hdr.src_addr, 16);
 				rte_memcpy(filter->input.flow.ipv6_flow.dst_ip,
-					   ipv6_spec->hdr.dst_addr, 16);
+					   &ipv6_spec->hdr.dst_addr, 16);
 
 				/* Check if it is fragment. */
 				if (ipv6_spec->hdr.proto ==
drivers/net/iavf/iavf_fdir.c +4 -4
index 811a10287b70..321346425465 100644
@@ -1048,14 +1048,14 @@ iavf_fdir_parse_pattern(__rte_unused struct iavf_adapter *ad,
 								 HOP_LIMIT);
 			}
 
-			if (!memcmp(ipv6_mask->hdr.src_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.src_addr))) {
+			if (!memcmp(&ipv6_mask->hdr.src_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.src_addr))) {
 				input_set |= IAVF_INSET_IPV6_SRC;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6,
 								 SRC);
 			}
-			if (!memcmp(ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.dst_addr))) {
+			if (!memcmp(&ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.dst_addr))) {
 				input_set |= IAVF_INSET_IPV6_DST;
 				VIRTCHNL_ADD_PROTO_HDR_FIELD_BIT(hdr, IPV6,
 								 DST);
drivers/net/iavf/iavf_fsub.c +4 -4
index 74e1e7099b8c..eb5a3feab189 100644
@@ -354,23 +354,23 @@ iavf_fsub_parse_pattern(const struct rte_flow_item pattern[],
 				}
 
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						*input |= IAVF_INSET_IPV6_SRC;
 						break;
 					}
 				}
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						*input |= IAVF_INSET_IPV6_DST;
 						break;
 					}
 				}
 
 				for (j = 0; j < IAVF_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j])
+					if (ipv6_mask->hdr.src_addr.a[j])
 						input_set_byte++;
 
-					if (ipv6_mask->hdr.dst_addr[j])
+					if (ipv6_mask->hdr.dst_addr.a[j])
 						input_set_byte++;
 				}
 
drivers/net/iavf/iavf_ipsec_crypto.c +3 -3
index 6fd45ff45f3d..89dd5af5500f 100644
@@ -1738,8 +1738,8 @@ static void
 parse_ipv6_item(const struct rte_flow_item_ipv6 *item,
 		struct rte_ipv6_hdr *ipv6)
 {
-	memcpy(ipv6->src_addr, item->hdr.src_addr, 16);
-	memcpy(ipv6->dst_addr, item->hdr.dst_addr, 16);
+	ipv6->src_addr = item->hdr.src_addr;
+	ipv6->dst_addr = item->hdr.dst_addr;
 }
 
 static void
@@ -1904,7 +1904,7 @@ iavf_ipsec_flow_create(struct iavf_adapter *ad,
 			ipsec_flow->spi,
 			0,
 			0,
-			ipsec_flow->ipv6_hdr.dst_addr,
+			ipsec_flow->ipv6_hdr.dst_addr.a,
 			0,
 			ipsec_flow->is_udp,
 			ipsec_flow->udp_hdr.dst_port);
drivers/net/ice/ice_fdir_filter.c +6 -6
index 741107f93939..406918fed547 100644
@@ -2097,11 +2097,11 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 				return -rte_errno;
 			}
 
-			if (!memcmp(ipv6_mask->hdr.src_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.src_addr)))
+			if (!memcmp(&ipv6_mask->hdr.src_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.src_addr)))
 				*input_set |= ICE_INSET_IPV6_SRC;
-			if (!memcmp(ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
-				    RTE_DIM(ipv6_mask->hdr.dst_addr)))
+			if (!memcmp(&ipv6_mask->hdr.dst_addr, ipv6_addr_mask,
+				    sizeof(ipv6_mask->hdr.dst_addr)))
 				*input_set |= ICE_INSET_IPV6_DST;
 
 			if ((ipv6_mask->hdr.vtc_flow &
@@ -2113,8 +2113,8 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
 			if (ipv6_mask->hdr.hop_limits == UINT8_MAX)
 				*input_set |= ICE_INSET_IPV6_HOP_LIMIT;
 
-			rte_memcpy(&p_v6->dst_ip, ipv6_spec->hdr.dst_addr, 16);
-			rte_memcpy(&p_v6->src_ip, ipv6_spec->hdr.src_addr, 16);
+			rte_memcpy(&p_v6->dst_ip, &ipv6_spec->hdr.dst_addr, 16);
+			rte_memcpy(&p_v6->src_ip, &ipv6_spec->hdr.src_addr, 16);
 			vtc_flow_cpu = rte_be_to_cpu_32(ipv6_spec->hdr.vtc_flow);
 			p_v6->tc = (uint8_t)(vtc_flow_cpu >> ICE_FDIR_IPV6_TC_OFFSET);
 			p_v6->proto = ipv6_spec->hdr.proto;
drivers/net/ice/ice_switch_filter.c +8 -8
index 122b87f625a7..28bc775a2c34 100644
@@ -665,13 +665,13 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 				}
 
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						*input |= ICE_INSET_IPV6_SRC;
 						break;
 					}
 				}
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						*input |= ICE_INSET_IPV6_DST;
 						break;
 					}
@@ -691,18 +691,18 @@ ice_switch_parse_pattern(const struct rte_flow_item pattern[],
 				f = &list[t].h_u.ipv6_hdr;
 				s = &list[t].m_u.ipv6_hdr;
 				for (j = 0; j < ICE_IPV6_ADDR_LENGTH; j++) {
-					if (ipv6_mask->hdr.src_addr[j]) {
+					if (ipv6_mask->hdr.src_addr.a[j]) {
 						f->src_addr[j] =
-						ipv6_spec->hdr.src_addr[j];
+						ipv6_spec->hdr.src_addr.a[j];
 						s->src_addr[j] =
-						ipv6_mask->hdr.src_addr[j];
+						ipv6_mask->hdr.src_addr.a[j];
 						input_set_byte++;
 					}
-					if (ipv6_mask->hdr.dst_addr[j]) {
+					if (ipv6_mask->hdr.dst_addr.a[j]) {
 						f->dst_addr[j] =
-						ipv6_spec->hdr.dst_addr[j];
+						ipv6_spec->hdr.dst_addr.a[j];
 						s->dst_addr[j] =
-						ipv6_mask->hdr.dst_addr[j];
+						ipv6_mask->hdr.dst_addr.a[j];
 						input_set_byte++;
 					}
 				}
drivers/net/igc/igc_flow.c +2 -2
index b677a0d61340..b778ac26135a 100644
@@ -435,8 +435,8 @@ igc_parse_pattern_ipv6(const struct rte_flow_item *item,
 	if (mask->hdr.vtc_flow ||
 		mask->hdr.payload_len ||
 		mask->hdr.hop_limits ||
-		!igc_is_zero_ipv6_addr(mask->hdr.src_addr) ||
-		!igc_is_zero_ipv6_addr(mask->hdr.dst_addr))
+		!igc_is_zero_ipv6_addr(&mask->hdr.src_addr) ||
+		!igc_is_zero_ipv6_addr(&mask->hdr.dst_addr))
 		return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ITEM, item,
 				"IPv6 only support protocol");
drivers/net/ixgbe/ixgbe_flow.c +6 -6
index 687341c6b8d3..1b35ed5faabe 100644
@@ -1917,9 +1917,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 
 		/* check src addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.src_addr[j] == 0) {
+			if (ipv6_mask->hdr.src_addr.a[j] == 0) {
 				rule->mask.src_ipv6_mask &= ~(1 << j);
-			} else if (ipv6_mask->hdr.src_addr[j] != UINT8_MAX) {
+			} else if (ipv6_mask->hdr.src_addr.a[j] != UINT8_MAX) {
 				memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1930,9 +1930,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 
 		/* check dst addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.dst_addr[j] == 0) {
+			if (ipv6_mask->hdr.dst_addr.a[j] == 0) {
 				rule->mask.dst_ipv6_mask &= ~(1 << j);
-			} else if (ipv6_mask->hdr.dst_addr[j] != UINT8_MAX) {
+			} else if (ipv6_mask->hdr.dst_addr.a[j] != UINT8_MAX) {
 				memset(rule, 0, sizeof(struct ixgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1945,9 +1945,9 @@ ixgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev,
 			rule->b_spec = TRUE;
 			ipv6_spec = item->spec;
 			rte_memcpy(rule->ixgbe_fdir.formatted.src_ip,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(rule->ixgbe_fdir.formatted.dst_ip,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 		}
 
 		/**
drivers/net/ixgbe/ixgbe_ipsec.c +2 -2
index 3a666ba15f59..778004cbe4d2 100644
@@ -681,9 +681,9 @@ ixgbe_crypto_add_ingress_sa_from_flow(const void *sess,
 			ic_session->src_ip.type = IPv6;
 			ic_session->dst_ip.type = IPv6;
 			rte_memcpy(ic_session->src_ip.ipv6,
-				   ipv6->hdr.src_addr, 16);
+				   &ipv6->hdr.src_addr, 16);
 			rte_memcpy(ic_session->dst_ip.ipv6,
-				   ipv6->hdr.dst_addr, 16);
+				   &ipv6->hdr.dst_addr, 16);
 		} else {
 			const struct rte_flow_item_ipv4 *ipv4 = ip_spec;
 			ic_session->src_ip.type = IPv4;
drivers/net/mlx5/hws/mlx5dr_definer.c +18 -18
index 10b986d66bd7..a9fa5d06edcc 100644
@@ -176,14 +176,14 @@ struct mlx5dr_definer_conv_data {
 	X(SET,		ipv6_proto,		v->hdr.proto,		rte_flow_item_ipv6) \
 	X(SET,		ipv6_routing_hdr,	IPPROTO_ROUTING,	rte_flow_item_ipv6) \
 	X(SET,		ipv6_hop_limits,	v->hdr.hop_limits,	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_127_96,	&v->hdr.src_addr[0],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_95_64,	&v->hdr.src_addr[4],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_63_32,	&v->hdr.src_addr[8],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_src_addr_31_0,	&v->hdr.src_addr[12],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_127_96,	&v->hdr.dst_addr[0],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_95_64,	&v->hdr.dst_addr[4],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_63_32,	&v->hdr.dst_addr[8],	rte_flow_item_ipv6) \
-	X(SET_BE32P,	ipv6_dst_addr_31_0,	&v->hdr.dst_addr[12],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_127_96,	&v->hdr.src_addr.a[0],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_95_64,	&v->hdr.src_addr.a[4],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_63_32,	&v->hdr.src_addr.a[8],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_src_addr_31_0,	&v->hdr.src_addr.a[12],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_127_96,	&v->hdr.dst_addr.a[0],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_95_64,	&v->hdr.dst_addr.a[4],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_63_32,	&v->hdr.dst_addr.a[8],	rte_flow_item_ipv6) \
+	X(SET_BE32P,	ipv6_dst_addr_31_0,	&v->hdr.dst_addr.a[12],	rte_flow_item_ipv6) \
 	X(SET,		ipv6_version,		STE_IPV6,		rte_flow_item_ipv6) \
 	X(SET,		ipv6_frag,		v->has_frag_ext,	rte_flow_item_ipv6) \
 	X(SET,		icmp_protocol,		STE_ICMP,		rte_flow_item_icmp) \
@@ -1161,8 +1161,8 @@ mlx5dr_definer_conv_item_ipv6(struct mlx5dr_definer_conv_data *cd,
 	    m->has_esp_ext || m->has_dest_ext || m->has_mobil_ext ||
 	    m->has_hip_ext || m->has_shim6_ext ||
 	    (l && (l->has_frag_ext || l->hdr.vtc_flow || l->hdr.proto ||
-		   !is_mem_zero(l->hdr.src_addr, 16) ||
-		   !is_mem_zero(l->hdr.dst_addr, 16)))) {
+		   !is_mem_zero(l->hdr.src_addr.a, 16) ||
+		   !is_mem_zero(l->hdr.dst_addr.a, 16)))) {
 		rte_errno = ENOTSUP;
 		return rte_errno;
 	}
@@ -1219,56 +1219,56 @@ mlx5dr_definer_conv_item_ipv6(struct mlx5dr_definer_conv_data *cd,
 		DR_CALC_SET(fc, eth_l3, time_to_live_hop_limit, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_127_96, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_127_96_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_127_96, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 4, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 4, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_95_64, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_95_64_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_95_64, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 8, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 8, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_63_32, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_63_32_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_63_32, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.src_addr + 12, 4)) {
+	if (!is_mem_zero(m->hdr.src_addr.a + 12, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_SRC_31_0, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_src_addr_31_0_set;
 		DR_CALC_SET(fc, ipv6_src, ipv6_address_31_0, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_127_96, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_127_96_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_127_96, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 4, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 4, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_95_64, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_95_64_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_95_64, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 8, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 8, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_63_32, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_63_32_set;
 		DR_CALC_SET(fc, ipv6_dst, ipv6_address_63_32, inner);
 	}
 
-	if (!is_mem_zero(m->hdr.dst_addr + 12, 4)) {
+	if (!is_mem_zero(m->hdr.dst_addr.a + 12, 4)) {
 		fc = &cd->fc[DR_CALC_FNAME(IPV6_DST_31_0, inner)];
 		fc->item_idx = item_idx;
 		fc->tag_set = &mlx5dr_definer_ipv6_dst_addr_31_0_set;
drivers/net/mlx5/mlx5_flow.c +2 -4
index effc61cdc9da..7f8640b488b8 100644
@@ -2933,10 +2933,8 @@ mlx5_flow_validate_item_ipv6(const struct rte_eth_dev *dev,
 	const struct rte_flow_item_ipv6 *spec = item->spec;
 	const struct rte_flow_item_ipv6 nic_mask = {
 		.hdr = {
-			.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-			.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+			.src_addr = RTE_IPV6_MASK_FULL,
+			.dst_addr = RTE_IPV6_MASK_FULL,
 			.vtc_flow = RTE_BE32(0xffffffff),
 			.proto = 0xff,
 		},
drivers/net/mlx5/mlx5_flow_dv.c +6 -10
index 5f71573a86d6..201e215e4bad 100644
@@ -7696,10 +7696,8 @@ const struct rte_flow_item_ipv4 nic_ipv4_mask = {
 
 const struct rte_flow_item_ipv6 nic_ipv6_mask = {
 	.hdr = {
-		.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-			      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-		.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-			      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+		.src_addr = RTE_IPV6_MASK_FULL,
+		.dst_addr = RTE_IPV6_MASK_FULL,
 		.vtc_flow = RTE_BE32(0xffffffff),
 		.proto = 0xff,
 		.hop_limits = 0xff,
@@ -9548,10 +9546,8 @@ flow_dv_translate_item_ipv6(void *key, const struct rte_flow_item *item,
 	const struct rte_flow_item_ipv6 *ipv6_v;
 	const struct rte_flow_item_ipv6 nic_mask = {
 		.hdr = {
-			.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-			.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+			.src_addr = RTE_IPV6_MASK_FULL,
+			.dst_addr = RTE_IPV6_MASK_FULL,
 			.vtc_flow = RTE_BE32(0xffffffff),
 			.proto = 0xff,
 			.hop_limits = 0xff,
@@ -9574,11 +9570,11 @@ flow_dv_translate_item_ipv6(void *key, const struct rte_flow_item *item,
 	l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
 			     dst_ipv4_dst_ipv6.ipv6_layout.ipv6);
 	for (i = 0; i < size; ++i)
-		l24_v[i] = ipv6_m->hdr.dst_addr[i] & ipv6_v->hdr.dst_addr[i];
+		l24_v[i] = ipv6_m->hdr.dst_addr.a[i] & ipv6_v->hdr.dst_addr.a[i];
 	l24_v = MLX5_ADDR_OF(fte_match_set_lyr_2_4, headers_v,
 			     src_ipv4_src_ipv6.ipv6_layout.ipv6);
 	for (i = 0; i < size; ++i)
-		l24_v[i] = ipv6_m->hdr.src_addr[i] & ipv6_v->hdr.src_addr[i];
+		l24_v[i] = ipv6_m->hdr.src_addr.a[i] & ipv6_v->hdr.src_addr.a[i];
 	/* TOS. */
 	vtc_v = rte_be_to_cpu_32(ipv6_m->hdr.vtc_flow & ipv6_v->hdr.vtc_flow);
 	MLX5_SET(fte_match_set_lyr_2_4, headers_v, ip_ecn, vtc_v >> 20);
drivers/net/mlx5/mlx5_flow_hw.c +4 -6
index c5ddd1d40433..0084f819804f 100644
@@ -8301,10 +8301,8 @@ const struct rte_flow_item_ipv6 hws_nic_ipv6_mask = {
 		.payload_len = RTE_BE16(0xffff),
 		.proto = 0xff,
 		.hop_limits = 0xff,
-		.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-			      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-		.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-			      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+		.src_addr = RTE_IPV6_MASK_FULL,
+		.dst_addr = RTE_IPV6_MASK_FULL,
 	},
 	.has_frag_ext = 1,
 };
@@ -14741,10 +14739,10 @@ flow_hw_calc_encap_hash(struct rte_eth_dev *dev,
 			break;
 		case RTE_FLOW_ITEM_TYPE_IPV6:
 			memcpy(data.dst.ipv6_addr,
-			       ((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.dst_addr,
+			       &((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.dst_addr,
 			       sizeof(data.dst.ipv6_addr));
 			memcpy(data.src.ipv6_addr,
-			       ((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.src_addr,
+			       &((const struct rte_flow_item_ipv6 *)(pattern->spec))->hdr.src_addr,
 			       sizeof(data.src.ipv6_addr));
 			break;
 		case RTE_FLOW_ITEM_TYPE_UDP:
drivers/net/mlx5/mlx5_flow_verbs.c +4 -4
index 3a4356c0f650..5b4a4eda3bbc 100644
@@ -600,13 +600,13 @@ flow_verbs_translate_item_ipv6(struct mlx5_flow *dev_flow,
 		uint32_t vtc_flow_val;
 		uint32_t vtc_flow_mask;
 
-		memcpy(&ipv6.val.src_ip, spec->hdr.src_addr,
+		memcpy(&ipv6.val.src_ip, &spec->hdr.src_addr,
 		       RTE_DIM(ipv6.val.src_ip));
-		memcpy(&ipv6.val.dst_ip, spec->hdr.dst_addr,
+		memcpy(&ipv6.val.dst_ip, &spec->hdr.dst_addr,
 		       RTE_DIM(ipv6.val.dst_ip));
-		memcpy(&ipv6.mask.src_ip, mask->hdr.src_addr,
+		memcpy(&ipv6.mask.src_ip, &mask->hdr.src_addr,
 		       RTE_DIM(ipv6.mask.src_ip));
-		memcpy(&ipv6.mask.dst_ip, mask->hdr.dst_addr,
+		memcpy(&ipv6.mask.dst_ip, &mask->hdr.dst_addr,
 		       RTE_DIM(ipv6.mask.dst_ip));
 		vtc_flow_val = rte_be_to_cpu_32(spec->hdr.vtc_flow);
 		vtc_flow_mask = rte_be_to_cpu_32(mask->hdr.vtc_flow);
drivers/net/mvpp2/mrvl_flow.c +6 -10
index e74a5f83f55b..098523ada653 100644
@@ -536,27 +536,23 @@ mrvl_parse_ip6_addr(const struct rte_flow_item_ipv6 *spec,
 	       int parse_dst, struct rte_flow *flow)
 {
 	struct pp2_cls_rule_key_field *key_field;
-	int size = sizeof(spec->hdr.dst_addr);
-	struct in6_addr k, m;
+	struct rte_ipv6_addr k, m;
 
-	memset(&k, 0, sizeof(k));
 	if (parse_dst) {
-		memcpy(k.s6_addr, spec->hdr.dst_addr, size);
-		memcpy(m.s6_addr, mask->hdr.dst_addr, size);
-
+		k = spec->hdr.dst_addr;
+		m = mask->hdr.dst_addr;
 		flow->table_key.proto_field[flow->rule.num_fields].field.ipv6 =
 			MV_NET_IP6_F_DA;
 	} else {
-		memcpy(k.s6_addr, spec->hdr.src_addr, size);
-		memcpy(m.s6_addr, mask->hdr.src_addr, size);
-
+		k = spec->hdr.src_addr;
+		m = mask->hdr.src_addr;
 		flow->table_key.proto_field[flow->rule.num_fields].field.ipv6 =
 			MV_NET_IP6_F_SA;
 	}
 
 	key_field = &flow->rule.fields[flow->rule.num_fields];
 	mrvl_alloc_key_mask(key_field);
-	key_field->size = 16;
+	key_field->size = RTE_IPV6_ADDR_SIZE;
 
 	inet_ntop(AF_INET6, &k, (char *)key_field->key, MRVL_CLS_STR_SIZE_MAX);
 	inet_ntop(AF_INET6, &m, (char *)key_field->mask, MRVL_CLS_STR_SIZE_MAX);
drivers/net/nfp/flower/nfp_flower_flow.c +15 -17
index e94c7e22e371..43574afea8ac 100644
@@ -2066,18 +2066,18 @@ nfp_flow_merge_ipv6(struct nfp_flow_merge_param *param)
 
 			ipv6_gre_tun->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 			ipv6_gre_tun->ip_ext.ttl = hdr->hop_limits;
-			memcpy(ipv6_gre_tun->ipv6.ipv6_src, hdr->src_addr,
+			memcpy(ipv6_gre_tun->ipv6.ipv6_src, &hdr->src_addr,
 					sizeof(ipv6_gre_tun->ipv6.ipv6_src));
-			memcpy(ipv6_gre_tun->ipv6.ipv6_dst, hdr->dst_addr,
+			memcpy(ipv6_gre_tun->ipv6.ipv6_dst, &hdr->dst_addr,
 					sizeof(ipv6_gre_tun->ipv6.ipv6_dst));
 		} else {
 			ipv6_udp_tun = (struct nfp_flower_ipv6_udp_tun *)(*param->mbuf_off);
 
 			ipv6_udp_tun->ip_ext.tos = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 			ipv6_udp_tun->ip_ext.ttl = hdr->hop_limits;
-			memcpy(ipv6_udp_tun->ipv6.ipv6_src, hdr->src_addr,
+			memcpy(ipv6_udp_tun->ipv6.ipv6_src, &hdr->src_addr,
 					sizeof(ipv6_udp_tun->ipv6.ipv6_src));
-			memcpy(ipv6_udp_tun->ipv6.ipv6_dst, hdr->dst_addr,
+			memcpy(ipv6_udp_tun->ipv6.ipv6_dst, &hdr->dst_addr,
 					sizeof(ipv6_udp_tun->ipv6.ipv6_dst));
 		}
 	} else {
@@ -2100,8 +2100,8 @@ nfp_flow_merge_ipv6(struct nfp_flow_merge_param *param)
 		ipv6->ip_ext.tos   = vtc_flow >> RTE_IPV6_HDR_TC_SHIFT;
 		ipv6->ip_ext.proto = hdr->proto;
 		ipv6->ip_ext.ttl   = hdr->hop_limits;
-		memcpy(ipv6->ipv6_src, hdr->src_addr, sizeof(ipv6->ipv6_src));
-		memcpy(ipv6->ipv6_dst, hdr->dst_addr, sizeof(ipv6->ipv6_dst));
+		memcpy(ipv6->ipv6_src, &hdr->src_addr, sizeof(ipv6->ipv6_src));
+		memcpy(ipv6->ipv6_dst, &hdr->dst_addr, sizeof(ipv6->ipv6_dst));
 
 ipv6_end:
 		*param->mbuf_off += sizeof(struct nfp_flower_ipv6);
@@ -2557,10 +2557,8 @@ static const struct nfp_flow_item_proc nfp_flow_item_proc_list[] = {
 				.vtc_flow   = RTE_BE32(0x0ff00000),
 				.proto      = 0xff,
 				.hop_limits = 0xff,
-				.src_addr   = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-						0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-				.dst_addr   = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-						0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+				.src_addr   = RTE_IPV6_MASK_FULL,
+				.dst_addr   = RTE_IPV6_MASK_FULL,
 			},
 			.has_frag_ext = 1,
 		},
@@ -3363,8 +3361,8 @@ nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower,
 	struct nfp_flower_cmsg_tun_neigh_v6 payload;
 
 	tun->payload.v6_flag = 1;
-	memcpy(tun->payload.dst.dst_ipv6, ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6));
-	memcpy(tun->payload.src.src_ipv6, ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6));
+	memcpy(tun->payload.dst.dst_ipv6, &ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6));
+	memcpy(tun->payload.src.src_ipv6, &ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6));
 	memcpy(tun->payload.dst_addr, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	memcpy(tun->payload.src_addr, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 
@@ -3384,8 +3382,8 @@ nfp_flower_add_tun_neigh_v6_encap(struct nfp_app_fw_flower *app_fw_flower,
 			sizeof(struct nfp_flower_meta_tci));
 
 	memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6));
-	memcpy(payload.dst_ipv6, ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6));
-	memcpy(payload.src_ipv6, ipv6->hdr.src_addr, sizeof(payload.src_ipv6));
+	memcpy(payload.dst_ipv6, &ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6));
+	memcpy(payload.src_ipv6, &ipv6->hdr.src_addr, sizeof(payload.src_ipv6));
 	memcpy(payload.common.dst_mac, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	memcpy(payload.common.src_mac, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN);
 	payload.common.port_id = port->in_port;
@@ -3612,7 +3610,7 @@ nfp_flow_action_vxlan_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
@@ -3982,7 +3980,7 @@ nfp_flow_action_geneve_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
@@ -4059,7 +4057,7 @@ nfp_flow_action_nvgre_encap_v6(struct nfp_app_fw_flower *app_fw_flower,
 
 	pre_tun = (struct nfp_fl_act_pre_tun *)actions;
 	memset(pre_tun, 0, act_pre_size);
-	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr);
+	nfp_flow_pre_tun_v6_process(pre_tun, ipv6->hdr.dst_addr.a);
 
 	set_tun = (struct nfp_fl_act_set_tun *)(act_data + act_pre_size);
 	memset(set_tun, 0, act_set_size);
drivers/net/nfp/nfp_net_flow.c +18 -20
index e9f0ce37109a..d72f6ce84c44 100644
@@ -297,28 +297,28 @@ nfp_net_flow_merge_ipv6(struct rte_flow *nfp_flow,
 
 	ipv6->l4_protocol_mask = mask->hdr.proto;
 	for (i = 0; i < sizeof(ipv6->src_ipv6); i += 4) {
-		ipv6->src_ipv6_mask[i] = mask->hdr.src_addr[i + 3];
-		ipv6->src_ipv6_mask[i + 1] = mask->hdr.src_addr[i + 2];
-		ipv6->src_ipv6_mask[i + 2] = mask->hdr.src_addr[i + 1];
-		ipv6->src_ipv6_mask[i + 3] = mask->hdr.src_addr[i];
+		ipv6->src_ipv6_mask[i] = mask->hdr.src_addr.a[i + 3];
+		ipv6->src_ipv6_mask[i + 1] = mask->hdr.src_addr.a[i + 2];
+		ipv6->src_ipv6_mask[i + 2] = mask->hdr.src_addr.a[i + 1];
+		ipv6->src_ipv6_mask[i + 3] = mask->hdr.src_addr.a[i];
 
-		ipv6->dst_ipv6_mask[i] = mask->hdr.dst_addr[i + 3];
-		ipv6->dst_ipv6_mask[i + 1] = mask->hdr.dst_addr[i + 2];
-		ipv6->dst_ipv6_mask[i + 2] = mask->hdr.dst_addr[i + 1];
-		ipv6->dst_ipv6_mask[i + 3] = mask->hdr.dst_addr[i];
+		ipv6->dst_ipv6_mask[i] = mask->hdr.dst_addr.a[i + 3];
+		ipv6->dst_ipv6_mask[i + 1] = mask->hdr.dst_addr.a[i + 2];
+		ipv6->dst_ipv6_mask[i + 2] = mask->hdr.dst_addr.a[i + 1];
+		ipv6->dst_ipv6_mask[i + 3] = mask->hdr.dst_addr.a[i];
 	}
 
 	ipv6->l4_protocol = spec->hdr.proto;
 	for (i = 0; i < sizeof(ipv6->src_ipv6); i += 4) {
-		ipv6->src_ipv6[i] = spec->hdr.src_addr[i + 3];
-		ipv6->src_ipv6[i + 1] = spec->hdr.src_addr[i + 2];
-		ipv6->src_ipv6[i + 2] = spec->hdr.src_addr[i + 1];
-		ipv6->src_ipv6[i + 3] = spec->hdr.src_addr[i];
+		ipv6->src_ipv6[i] = spec->hdr.src_addr.a[i + 3];
+		ipv6->src_ipv6[i + 1] = spec->hdr.src_addr.a[i + 2];
+		ipv6->src_ipv6[i + 2] = spec->hdr.src_addr.a[i + 1];
+		ipv6->src_ipv6[i + 3] = spec->hdr.src_addr.a[i];
 
-		ipv6->dst_ipv6[i] = spec->hdr.dst_addr[i + 3];
-		ipv6->dst_ipv6[i + 1] = spec->hdr.dst_addr[i + 2];
-		ipv6->dst_ipv6[i + 2] = spec->hdr.dst_addr[i + 1];
-		ipv6->dst_ipv6[i + 3] = spec->hdr.dst_addr[i];
+		ipv6->dst_ipv6[i] = spec->hdr.dst_addr.a[i + 3];
+		ipv6->dst_ipv6[i + 1] = spec->hdr.dst_addr.a[i + 2];
+		ipv6->dst_ipv6[i + 2] = spec->hdr.dst_addr.a[i + 1];
+		ipv6->dst_ipv6[i + 3] = spec->hdr.dst_addr.a[i];
 	}
 
 	return 0;
@@ -406,10 +406,8 @@ static const struct nfp_net_flow_item_proc nfp_net_flow_item_proc_list[] = {
 		.mask_support = &(const struct rte_flow_item_ipv6){
 			.hdr = {
 				.proto    = 0xff,
-				.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-					      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-				.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-					      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+				.src_addr = RTE_IPV6_MASK_FULL,
+				.dst_addr = RTE_IPV6_MASK_FULL,
 			},
 		},
 		.mask_default = &rte_flow_item_ipv6_mask,
drivers/net/qede/qede_filter.c +2 -2
index d98266eac55c..14fb4338e9c7 100644
@@ -794,9 +794,9 @@ qede_flow_parse_pattern(__rte_unused struct rte_eth_dev *dev,
 
 				spec = pattern->spec;
 				memcpy(flow->entry.tuple.src_ipv6,
-				       spec->hdr.src_addr, IPV6_ADDR_LEN);
+				       &spec->hdr.src_addr, IPV6_ADDR_LEN);
 				memcpy(flow->entry.tuple.dst_ipv6,
-				       spec->hdr.dst_addr, IPV6_ADDR_LEN);
+				       &spec->hdr.dst_addr, IPV6_ADDR_LEN);
 				flow->entry.tuple.eth_proto =
 					RTE_ETHER_TYPE_IPV6;
 			}
drivers/net/sfc/sfc_flow.c +8 -14
index 1b50aefe5c48..1006243539b5 100644
@@ -575,14 +575,8 @@ sfc_flow_parse_ipv6(const struct rte_flow_item *item,
 	const uint16_t ether_type_ipv6 = rte_cpu_to_le_16(EFX_ETHER_TYPE_IPV6);
 	const struct rte_flow_item_ipv6 supp_mask = {
 		.hdr = {
-			.src_addr = { 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff },
-			.dst_addr = { 0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff,
-				      0xff, 0xff, 0xff, 0xff },
+			.src_addr = RTE_IPV6_MASK_FULL,
+			.dst_addr = RTE_IPV6_MASK_FULL,
 			.proto = 0xff,
 		}
 	};
@@ -618,28 +612,28 @@ sfc_flow_parse_ipv6(const struct rte_flow_item *item,
 	 * IPv6 addresses are in big-endian byte order in item and in
 	 * efx_spec
 	 */
-	if (memcmp(mask->hdr.src_addr, supp_mask.hdr.src_addr,
+	if (memcmp(&mask->hdr.src_addr, &supp_mask.hdr.src_addr,
 		   sizeof(mask->hdr.src_addr)) == 0) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_REM_HOST;
 
 		RTE_BUILD_BUG_ON(sizeof(efx_spec->efs_rem_host) !=
 				 sizeof(spec->hdr.src_addr));
-		rte_memcpy(&efx_spec->efs_rem_host, spec->hdr.src_addr,
+		rte_memcpy(&efx_spec->efs_rem_host, &spec->hdr.src_addr,
 			   sizeof(efx_spec->efs_rem_host));
-	} else if (!sfc_flow_is_zero(mask->hdr.src_addr,
+	} else if (!sfc_flow_is_zero(mask->hdr.src_addr.a,
 				     sizeof(mask->hdr.src_addr))) {
 		goto fail_bad_mask;
 	}
 
-	if (memcmp(mask->hdr.dst_addr, supp_mask.hdr.dst_addr,
+	if (memcmp(&mask->hdr.dst_addr, &supp_mask.hdr.dst_addr,
 		   sizeof(mask->hdr.dst_addr)) == 0) {
 		efx_spec->efs_match_flags |= EFX_FILTER_MATCH_LOC_HOST;
 
 		RTE_BUILD_BUG_ON(sizeof(efx_spec->efs_loc_host) !=
 				 sizeof(spec->hdr.dst_addr));
-		rte_memcpy(&efx_spec->efs_loc_host, spec->hdr.dst_addr,
+		rte_memcpy(&efx_spec->efs_loc_host, &spec->hdr.dst_addr,
 			   sizeof(efx_spec->efs_loc_host));
-	} else if (!sfc_flow_is_zero(mask->hdr.dst_addr,
+	} else if (!sfc_flow_is_zero(mask->hdr.dst_addr.a,
 				     sizeof(mask->hdr.dst_addr))) {
 		goto fail_bad_mask;
 	}
drivers/net/tap/tap_flow.c +4 -6
index 5ae1faf9165d..51ec07eb5acd 100644
@@ -209,10 +209,8 @@ static const struct tap_flow_items tap_flow_items[] = {
 			       RTE_FLOW_ITEM_TYPE_TCP),
 		.mask = &(const struct rte_flow_item_ipv6){
 			.hdr = {
-				.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-					      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-				.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-					      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+				.src_addr = RTE_IPV6_MASK_FULL,
+				.dst_addr = RTE_IPV6_MASK_FULL,
 				.proto = -1,
 			},
 		},
@@ -613,13 +611,13 @@ tap_flow_create_ipv6(const struct rte_flow_item *item, void *data)
 		info->eth_type = htons(ETH_P_IPV6);
 	if (!spec)
 		return 0;
-	if (memcmp(mask->hdr.dst_addr, empty_addr, 16)) {
+	if (memcmp(&mask->hdr.dst_addr, empty_addr, 16)) {
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST,
 			   sizeof(spec->hdr.dst_addr), &spec->hdr.dst_addr);
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_DST_MASK,
 			   sizeof(mask->hdr.dst_addr), &mask->hdr.dst_addr);
 	}
-	if (memcmp(mask->hdr.src_addr, empty_addr, 16)) {
+	if (memcmp(&mask->hdr.src_addr, empty_addr, 16)) {
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC,
 			   sizeof(spec->hdr.src_addr), &spec->hdr.src_addr);
 		tap_nlattr_add(&msg->nh, TCA_FLOWER_KEY_IPV6_SRC_MASK,
drivers/net/txgbe/txgbe_flow.c +6 -6
index 7ef52d0b0fcd..5d2dd453687c 100644
@@ -1807,9 +1807,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 
 		/* check src addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.src_addr[j] == UINT8_MAX) {
+			if (ipv6_mask->hdr.src_addr.a[j] == UINT8_MAX) {
 				rule->mask.src_ipv6_mask |= 1 << j;
-			} else if (ipv6_mask->hdr.src_addr[j] != 0) {
+			} else if (ipv6_mask->hdr.src_addr.a[j] != 0) {
 				memset(rule, 0, sizeof(struct txgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1820,9 +1820,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 
 		/* check dst addr mask */
 		for (j = 0; j < 16; j++) {
-			if (ipv6_mask->hdr.dst_addr[j] == UINT8_MAX) {
+			if (ipv6_mask->hdr.dst_addr.a[j] == UINT8_MAX) {
 				rule->mask.dst_ipv6_mask |= 1 << j;
-			} else if (ipv6_mask->hdr.dst_addr[j] != 0) {
+			} else if (ipv6_mask->hdr.dst_addr.a[j] != 0) {
 				memset(rule, 0, sizeof(struct txgbe_fdir_rule));
 				rte_flow_error_set(error, EINVAL,
 					RTE_FLOW_ERROR_TYPE_ITEM,
@@ -1835,9 +1835,9 @@ txgbe_parse_fdir_filter_normal(struct rte_eth_dev *dev __rte_unused,
 			rule->b_spec = TRUE;
 			ipv6_spec = item->spec;
 			rte_memcpy(rule->input.src_ip,
-				   ipv6_spec->hdr.src_addr, 16);
+				   &ipv6_spec->hdr.src_addr, 16);
 			rte_memcpy(rule->input.dst_ip,
-				   ipv6_spec->hdr.dst_addr, 16);
+				   &ipv6_spec->hdr.dst_addr, 16);
 		}
 
 		/**
drivers/net/txgbe/txgbe_ipsec.c +2 -2
index 4af49dd802d0..65b6c251c684 100644
@@ -659,9 +659,9 @@ txgbe_crypto_add_ingress_sa_from_flow(const void *sess,
 			ic_session->src_ip.type = IPv6;
 			ic_session->dst_ip.type = IPv6;
 			rte_memcpy(ic_session->src_ip.ipv6,
-				   ipv6->hdr.src_addr, 16);
+				   &ipv6->hdr.src_addr, 16);
 			rte_memcpy(ic_session->dst_ip.ipv6,
-				   ipv6->hdr.dst_addr, 16);
+				   &ipv6->hdr.dst_addr, 16);
 		} else {
 			const struct rte_flow_item_ipv4 *ipv4 = ip_spec;
 			ic_session->src_ip.type = IPv4;
examples/ip_fragmentation/main.c +1 -1
index 736eae6f05ee..4c0fa5054a2e 100644
@@ -311,7 +311,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lcore_queue_conf *qconf,
 		ip_hdr = rte_pktmbuf_mtod(m, struct rte_ipv6_hdr *);
 
 		/* Find destination port */
-		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr,
+		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr.a,
 						&next_hop) == 0 &&
 				(enabled_port_mask & 1 << next_hop) != 0) {
 			port_out = next_hop;
examples/ip_pipeline/pipeline.c +8 -8
index 63352257c6e9..792aab0059e9 100644
@@ -637,7 +637,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 1,
 		.input_index = 1,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[0]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[0]),
 	},
 
 	[2] = {
@@ -645,7 +645,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 2,
 		.input_index = 2,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[4]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[4]),
 	},
 
 	[3] = {
@@ -653,7 +653,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 3,
 		.input_index = 3,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[8]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[8]),
 	},
 
 	[4] = {
@@ -661,7 +661,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 4,
 		.input_index = 4,
-		.offset = offsetof(struct rte_ipv6_hdr, src_addr[12]),
+		.offset = offsetof(struct rte_ipv6_hdr, src_addr.a[12]),
 	},
 
 	/* Destination IP address (IPv6) */
@@ -670,7 +670,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 5,
 		.input_index = 5,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[0]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[0]),
 	},
 
 	[6] = {
@@ -678,7 +678,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 6,
 		.input_index = 6,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[4]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[4]),
 	},
 
 	[7] = {
@@ -686,7 +686,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 7,
 		.input_index = 7,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[8]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[8]),
 	},
 
 	[8] = {
@@ -694,7 +694,7 @@ static const struct rte_acl_field_def table_acl_field_format_ipv6[] = {
 		.size = sizeof(uint32_t),
 		.field_index = 8,
 		.input_index = 8,
-		.offset = offsetof(struct rte_ipv6_hdr, dst_addr[12]),
+		.offset = offsetof(struct rte_ipv6_hdr, dst_addr.a[12]),
 	},
 
 	/* Source Port */
examples/ip_reassembly/main.c +1 -1
index c7019078f7b4..4da692eb23e6 100644
@@ -400,7 +400,7 @@ reassemble(struct rte_mbuf *m, uint16_t portid, uint32_t queue,
 		}
 
 		/* Find destination port */
-		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr,
+		if (rte_lpm6_lookup(rxq->lpm6, ip_hdr->dst_addr.a,
 						&next_hop) == 0 &&
 				(enabled_port_mask & 1 << next_hop) != 0) {
 			dst_port = next_hop;
examples/ipsec-secgw/flow.c +6 -27
index 05a62c3020fa..3f7630f5fd53 100644
@@ -83,29 +83,8 @@ ipv4_addr_cpy(rte_be32_t *spec, rte_be32_t *mask, char *token,
 static void
 ipv6_hdr_print(struct rte_ipv6_hdr *hdr)
 {
-	uint8_t *addr;
-
-	addr = hdr->src_addr;
-	printf("src: %4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx \t",
-	       (uint16_t)((addr[0] << 8) | addr[1]),
-	       (uint16_t)((addr[2] << 8) | addr[3]),
-	       (uint16_t)((addr[4] << 8) | addr[5]),
-	       (uint16_t)((addr[6] << 8) | addr[7]),
-	       (uint16_t)((addr[8] << 8) | addr[9]),
-	       (uint16_t)((addr[10] << 8) | addr[11]),
-	       (uint16_t)((addr[12] << 8) | addr[13]),
-	       (uint16_t)((addr[14] << 8) | addr[15]));
-
-	addr = hdr->dst_addr;
-	printf("dst: %4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx:%4hx",
-	       (uint16_t)((addr[0] << 8) | addr[1]),
-	       (uint16_t)((addr[2] << 8) | addr[3]),
-	       (uint16_t)((addr[4] << 8) | addr[5]),
-	       (uint16_t)((addr[6] << 8) | addr[7]),
-	       (uint16_t)((addr[8] << 8) | addr[9]),
-	       (uint16_t)((addr[10] << 8) | addr[11]),
-	       (uint16_t)((addr[12] << 8) | addr[13]),
-	       (uint16_t)((addr[14] << 8) | addr[15]));
+	printf("src: " RTE_IPV6_ADDR_FMT " \t", RTE_IPV6_ADDR_SPLIT(&hdr->src_addr));
+	printf("dst: " RTE_IPV6_ADDR_FMT, RTE_IPV6_ADDR_SPLIT(&hdr->dst_addr));
 }
 
 static int
@@ -196,8 +175,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.src_addr,
-						  rule->ipv6.mask.hdr.src_addr,
+				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.src_addr.a,
+						  rule->ipv6.mask.hdr.src_addr.a,
 						  tokens[ti], status))
 					return;
 			}
@@ -205,8 +184,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.dst_addr,
-						  rule->ipv6.mask.hdr.dst_addr,
+				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.dst_addr.a,
+						  rule->ipv6.mask.hdr.dst_addr.a,
 						  tokens[ti], status))
 					return;
 			}
examples/ipsec-secgw/ipsec.c +4 -4
index b52b0ffc3d22..ebde28639c12 100644
@@ -529,9 +529,9 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 			sa->pattern[1].spec = &sa->ipv6_spec;
 
-			memcpy(sa->ipv6_spec.hdr.dst_addr,
+			memcpy(&sa->ipv6_spec.hdr.dst_addr,
 				sa->dst.ip.ip6.ip6_b, 16);
-			memcpy(sa->ipv6_spec.hdr.src_addr,
+			memcpy(&sa->ipv6_spec.hdr.src_addr,
 			       sa->src.ip.ip6.ip6_b, 16);
 		} else if (IS_IP4(sa->flags)) {
 			sa->pattern[1].mask = &rte_flow_item_ipv4_mask;
@@ -735,9 +735,9 @@ create_ipsec_esp_flow(struct ipsec_sa *sa)
 		sa->pattern[1].mask = &rte_flow_item_ipv6_mask;
 		sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 		sa->pattern[1].spec = &sa->ipv6_spec;
-		memcpy(sa->ipv6_spec.hdr.dst_addr,
+		memcpy(&sa->ipv6_spec.hdr.dst_addr,
 			sa->dst.ip.ip6.ip6_b, sizeof(sa->dst.ip.ip6.ip6_b));
-		memcpy(sa->ipv6_spec.hdr.src_addr,
+		memcpy(&sa->ipv6_spec.hdr.src_addr,
 			sa->src.ip.ip6.ip6_b, sizeof(sa->src.ip.ip6.ip6_b));
 		sa->pattern[2].type = RTE_FLOW_ITEM_TYPE_ESP;
 		sa->pattern[2].spec = &sa->esp_spec;
examples/ipsec-secgw/sa.c +2 -2
index c4bac17cd77c..1a0afd2ed2e8 100644
@@ -1571,8 +1571,8 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size,
 	};
 
 	if (IS_IP6_TUNNEL(lsa->flags)) {
-		memcpy(v6.src_addr, lsa->src.ip.ip6.ip6_b, sizeof(v6.src_addr));
-		memcpy(v6.dst_addr, lsa->dst.ip.ip6.ip6_b, sizeof(v6.dst_addr));
+		memcpy(&v6.src_addr, lsa->src.ip.ip6.ip6_b, sizeof(v6.src_addr));
+		memcpy(&v6.dst_addr, lsa->dst.ip.ip6.ip6_b, sizeof(v6.dst_addr));
 	}
 
 	rc = fill_ipsec_sa_prm(&prm, lsa, &v4, &v6);
examples/ipsec-secgw/sad.h +6 -4
index 3224b6252c8d..fdb1d2ef1790 100644
@@ -5,6 +5,8 @@
 #ifndef __SAD_H__
 #define __SAD_H__
 
+#include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_ipsec_sad.h>
 
 #define SA_CACHE_SZ	128
@@ -37,8 +39,8 @@ cmp_sa_key(struct ipsec_sa *sa, int is_v4, struct rte_ipv4_hdr *ipv4,
 			(sa->dst.ip.ip4 == ipv4->dst_addr)) ||
 			/* IPv6 check */
 			(!is_v4 && (sa_type == IP6_TUNNEL) &&
-			(!memcmp(sa->src.ip.ip6.ip6, ipv6->src_addr, 16)) &&
-			(!memcmp(sa->dst.ip.ip6.ip6, ipv6->dst_addr, 16))))
+			(!memcmp(sa->src.ip.ip6.ip6, &ipv6->src_addr, 16)) &&
+			(!memcmp(sa->dst.ip.ip6.ip6, &ipv6->dst_addr, 16))))
 		return 1;
 
 	return 0;
@@ -128,9 +130,9 @@ sad_lookup(struct ipsec_sad *sad, struct rte_mbuf *pkts[],
 				}
 			}
 			v6[nb_v6].spi = esp->spi;
-			memcpy(v6[nb_v6].dip, ipv6->dst_addr,
+			memcpy(v6[nb_v6].dip, &ipv6->dst_addr,
 					sizeof(ipv6->dst_addr));
-			memcpy(v6[nb_v6].sip, ipv6->src_addr,
+			memcpy(v6[nb_v6].sip, &ipv6->src_addr,
 					sizeof(ipv6->src_addr));
 			keys_v6[nb_v6] = (const union rte_ipsec_sad_key *)
 						&v6[nb_v6];
examples/l3fwd/l3fwd_fib.c +1 -1
index 993e36cec235..85f862dd5b40 100644
@@ -65,7 +65,7 @@ fib_parse_packet(struct rte_mbuf *mbuf,
 	/* IPv6 */
 	else {
 		ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
-		rte_mov16(ipv6, (const uint8_t *)ipv6_hdr->dst_addr);
+		rte_mov16(ipv6, ipv6_hdr->dst_addr.a);
 		*ip_type = 0;
 		(*ipv6_cnt)++;
 	}
examples/l3fwd/l3fwd_lpm.c +2 -2
index e8fd95aae9ce..422fdb70054d 100644
@@ -62,7 +62,7 @@ lpm_get_ipv6_dst_port(const struct rte_ipv6_hdr *ipv6_hdr,
 		      uint16_t portid,
 		      struct rte_lpm6 *ipv6_l3fwd_lookup_struct)
 {
-	const uint8_t *dst_ip = ipv6_hdr->dst_addr;
+	const uint8_t *dst_ip = ipv6_hdr->dst_addr.a;
 	uint32_t next_hop;
 
 	if (rte_lpm6_lookup(ipv6_l3fwd_lookup_struct, dst_ip, &next_hop) == 0)
@@ -122,7 +122,7 @@ lpm_get_dst_port_with_ipv4(const struct lcore_conf *qconf, struct rte_mbuf *pkt,
 		ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
 
 		return (uint16_t) ((rte_lpm6_lookup(qconf->ipv6_lookup_struct,
-				ipv6_hdr->dst_addr, &next_hop) == 0)
+				ipv6_hdr->dst_addr.a, &next_hop) == 0)
 				? next_hop : portid);
 
 	}
lib/ethdev/rte_flow.h +2 -4
index 22c5c147d0ea..e8baedcc79d8 100644
@@ -1005,10 +1005,8 @@ struct rte_flow_item_ipv6 {
 #ifndef __cplusplus
 static const struct rte_flow_item_ipv6 rte_flow_item_ipv6_mask = {
 	.hdr = {
-		.src_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-			      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-		.dst_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-			      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+		.src_addr = RTE_IPV6_MASK_FULL,
+		.dst_addr = RTE_IPV6_MASK_FULL,
 	},
 };
 #endif
lib/hash/rte_thash.h +6 -6
index ec0c029402fc..eab753a06f3d 100644
@@ -139,24 +139,24 @@ rte_thash_load_v6_addrs(const struct rte_ipv6_hdr *orig,
 			union rte_thash_tuple *targ)
 {
 #ifdef RTE_ARCH_X86
-	__m128i ipv6 = _mm_loadu_si128((const __m128i *)orig->src_addr);
+	__m128i ipv6 = _mm_loadu_si128((const __m128i *)&orig->src_addr);
 	*(__m128i *)targ->v6.src_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
-	ipv6 = _mm_loadu_si128((const __m128i *)orig->dst_addr);
+	ipv6 = _mm_loadu_si128((const __m128i *)&orig->dst_addr);
 	*(__m128i *)targ->v6.dst_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 #elif defined(__ARM_NEON)
-	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)orig->src_addr);
+	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)&orig->src_addr);
 	vst1q_u8((uint8_t *)targ->v6.src_addr, vrev32q_u8(ipv6));
-	ipv6 = vld1q_u8((uint8_t const *)orig->dst_addr);
+	ipv6 = vld1q_u8((uint8_t const *)&orig->dst_addr);
 	vst1q_u8((uint8_t *)targ->v6.dst_addr, vrev32q_u8(ipv6));
 #else
 	int i;
 	for (i = 0; i < 4; i++) {
 		*((uint32_t *)targ->v6.src_addr + i) =
-			rte_be_to_cpu_32(*((const uint32_t *)orig->src_addr + i));
+			rte_be_to_cpu_32(*((const uint32_t *)&orig->src_addr + i));
 		*((uint32_t *)targ->v6.dst_addr + i) =
-			rte_be_to_cpu_32(*((const uint32_t *)orig->dst_addr + i));
+			rte_be_to_cpu_32(*((const uint32_t *)&orig->dst_addr + i));
 	}
 #endif
 }
lib/ip_frag/rte_ipv6_reassembly.c +2 -2
index 88863a98d1fe..9471ce5333d7 100644
@@ -143,8 +143,8 @@ rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
 	int32_t ip_len;
 	int32_t trim;
 
-	rte_memcpy(&key.src_dst[0], ip_hdr->src_addr, 16);
-	rte_memcpy(&key.src_dst[2], ip_hdr->dst_addr, 16);
+	rte_memcpy(&key.src_dst[0], &ip_hdr->src_addr, 16);
+	rte_memcpy(&key.src_dst[2], &ip_hdr->dst_addr, 16);
 
 	key.id = frag_hdr->id;
 	key.key_len = IPV6_KEYLEN;
lib/net/rte_ip6.h +3 -3
index 725402e6d08e..d364295b11d2 100644
@@ -217,8 +217,8 @@ struct rte_ipv6_hdr {
 	rte_be16_t payload_len;	/**< IP payload size, including ext. headers */
 	uint8_t  proto;		/**< Protocol, next header. */
 	uint8_t  hop_limits;	/**< Hop limits. */
-	uint8_t  src_addr[16];	/**< IP address of source host. */
-	uint8_t  dst_addr[16];	/**< IP address of destination host(s). */
+	struct rte_ipv6_addr src_addr;	/**< IP address of source host. */
+	struct rte_ipv6_addr dst_addr;	/**< IP address of destination host(s). */
 } __rte_packed;
 
 /* IPv6 routing extension type definition. */
@@ -286,7 +286,7 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 	else
 		psd_hdr.len = ipv6_hdr->payload_len;
 
-	sum = __rte_raw_cksum(ipv6_hdr->src_addr,
+	sum = __rte_raw_cksum(&ipv6_hdr->src_addr,
 		sizeof(ipv6_hdr->src_addr) + sizeof(ipv6_hdr->dst_addr),
 		0);
 	sum = __rte_raw_cksum(&psd_hdr, sizeof(psd_hdr), sum);
lib/node/ip6_lookup.c +5 -5
index 309964f60fd6..6bbcf14e2aa8 100644
@@ -112,28 +112,28 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf0, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(ip_batch[0], ipv6_hdr->dst_addr, 16);
+		rte_memcpy(ip_batch[0], &ipv6_hdr->dst_addr, 16);
 
 		/* Extract DIP of mbuf1 */
 		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf1, struct rte_ipv6_hdr *,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf1, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(ip_batch[1], ipv6_hdr->dst_addr, 16);
+		rte_memcpy(ip_batch[1], &ipv6_hdr->dst_addr, 16);
 
 		/* Extract DIP of mbuf2 */
 		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf2, struct rte_ipv6_hdr *,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf2, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(ip_batch[2], ipv6_hdr->dst_addr, 16);
+		rte_memcpy(ip_batch[2], &ipv6_hdr->dst_addr, 16);
 
 		/* Extract DIP of mbuf3 */
 		ipv6_hdr = rte_pktmbuf_mtod_offset(mbuf3, struct rte_ipv6_hdr *,
 				sizeof(struct rte_ether_hdr));
 		/* Extract hop_limits as ipv6 hdr is in cache */
 		node_mbuf_priv1(mbuf3, dyn)->ttl = ipv6_hdr->hop_limits;
-		rte_memcpy(ip_batch[3], ipv6_hdr->dst_addr, 16);
+		rte_memcpy(ip_batch[3], &ipv6_hdr->dst_addr, 16);
 
 		rte_lpm6_lookup_bulk_func(lpm6, ip_batch, next_hop, 4);
 
@@ -223,7 +223,7 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 		/* Extract TTL as IPv6 hdr is in cache */
 		node_mbuf_priv1(mbuf0, dyn)->ttl = ipv6_hdr->hop_limits;
 
-		rc = rte_lpm6_lookup(lpm6, ipv6_hdr->dst_addr, &next_hop);
+		rc = rte_lpm6_lookup(lpm6, ipv6_hdr->dst_addr.a, &next_hop);
 		next_hop = (rc == 0) ? next_hop : drop_nh;
 
 		node_mbuf_priv1(mbuf0, dyn)->nh = (uint16_t)next_hop;
lib/pipeline/rte_swx_ipsec.c +2 -4
index 73e8211b2818..0ed0ecd134c8 100644
@@ -1386,13 +1386,11 @@ tunnel_ipv6_header_set(struct rte_ipv6_hdr *h, struct rte_swx_ipsec_sa_params *p
 		.payload_len = 0, /* Cannot be pre-computed. */
 		.proto = IPPROTO_ESP,
 		.hop_limits = 64,
-		.src_addr = {0},
-		.dst_addr = {0},
 	};
 
 	memcpy(h, &ipv6_hdr, sizeof(ipv6_hdr));
-	memcpy(h->src_addr, p->encap.tunnel.ipv6.src_addr.s6_addr, 16);
-	memcpy(h->dst_addr, p->encap.tunnel.ipv6.dst_addr.s6_addr, 16);
+	memcpy(&h->src_addr, p->encap.tunnel.ipv6.src_addr.s6_addr, 16);
+	memcpy(&h->dst_addr, p->encap.tunnel.ipv6.dst_addr.s6_addr, 16);
 }
 
 /* IPsec library SA parameters. */
lib/pipeline/rte_table_action.c +12 -12
index 87c3e0e2c935..c0be656536eb 100644
@@ -871,10 +871,10 @@ 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,
+			memcpy(&d->ipv6.src_addr,
 				p->vxlan.ipv6.sa,
 				sizeof(p->vxlan.ipv6.sa));
-			memcpy(d->ipv6.dst_addr,
+			memcpy(&d->ipv6.dst_addr,
 				p->vxlan.ipv6.da,
 				sizeof(p->vxlan.ipv6.da));
 
@@ -906,10 +906,10 @@ 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,
+			memcpy(&d->ipv6.src_addr,
 				p->vxlan.ipv6.sa,
 				sizeof(p->vxlan.ipv6.sa));
-			memcpy(d->ipv6.dst_addr,
+			memcpy(&d->ipv6.dst_addr,
 				p->vxlan.ipv6.da,
 				sizeof(p->vxlan.ipv6.da));
 
@@ -1436,12 +1436,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t tcp_cksum;
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
-				(uint16_t *)ip->src_addr,
+				(uint16_t *)&ip->src_addr,
 				(uint16_t *)data->addr,
 				tcp->src_port,
 				data->port);
 
-			rte_memcpy(ip->src_addr, data->addr, 16);
+			rte_memcpy(&ip->src_addr, data->addr, 16);
 			tcp->src_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1449,12 +1449,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t udp_cksum;
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
-				(uint16_t *)ip->src_addr,
+				(uint16_t *)&ip->src_addr,
 				(uint16_t *)data->addr,
 				udp->src_port,
 				data->port);
 
-			rte_memcpy(ip->src_addr, data->addr, 16);
+			rte_memcpy(&ip->src_addr, data->addr, 16);
 			udp->src_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
@@ -1464,12 +1464,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t tcp_cksum;
 
 			tcp_cksum = nat_ipv6_tcp_udp_checksum_update(tcp->cksum,
-				(uint16_t *)ip->dst_addr,
+				(uint16_t *)&ip->dst_addr,
 				(uint16_t *)data->addr,
 				tcp->dst_port,
 				data->port);
 
-			rte_memcpy(ip->dst_addr, data->addr, 16);
+			rte_memcpy(&ip->dst_addr, data->addr, 16);
 			tcp->dst_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1477,12 +1477,12 @@ pkt_ipv6_work_nat(struct rte_ipv6_hdr *ip,
 			uint16_t udp_cksum;
 
 			udp_cksum = nat_ipv6_tcp_udp_checksum_update(udp->dgram_cksum,
-				(uint16_t *)ip->dst_addr,
+				(uint16_t *)&ip->dst_addr,
 				(uint16_t *)data->addr,
 				udp->dst_port,
 				data->port);
 
-			rte_memcpy(ip->dst_addr, data->addr, 16);
+			rte_memcpy(&ip->dst_addr, data->addr, 16);
 			udp->dst_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
Signature · 1 line
2.47.0
#93 lore raw

PATCH v4 5/17 lpm6: use IPv6 address structure and utils

In reply to Robin Jarry

Replace ad-hoc uint8_t[16] array types in the API of rte_lpm6 with rte_ipv6_addr structures. Replace duplicate functions and macros with common ones from rte_ip6.h. Update all code accordingly.

NB: the conversion between 16 bytes arrays and RTE_IPV6() literals was done automatically with the following python script and adjusted manually afterwards:

import argparse
import re
import struct

ip = re.compile(

    r"""
    \{
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*,
    [\s\t\r\n]*([\da-fA-Fx]+)[\s\t\r\n]*
    \}
    """,
    re.VERBOSE,

)

def repl(match):

    u8 = bytes(int(g, 0) for g in match.groups("0"))
    nums = []
    for u16 in struct.unpack("!HHHHHHHH", u8):
        if u16:
            nums.append(f"0x{u16:04x}")
        else:
            nums.append("0")
    return f"RTE_IPV6({', '.join(nums)})"

p = argparse.ArgumentParser()
p.add_argument("args", nargs="+")
args = p.parse_args()

for a in args.args:

with open(a) as f:
buf = f.read()

buf = ip.sub(repl, buf)
with open(a, "w") as f:
f.write(buf)

---
 app/test-fib/main.c                    |   74 +-
 app/test-pipeline/pipeline_lpm_ipv6.c  |   11 +-
 app/test/test_fib6_perf.c              |    6 +-
 app/test/test_lpm6.c                   |  490 +++---
 app/test/test_lpm6_data.h              | 2025 ++++++++++++------------
 app/test/test_lpm6_perf.c              |   10 +-
 app/test/test_table_combined.c         |    2 +-
 app/test/test_table_tables.c           |    8 +-
 doc/guides/rel_notes/deprecation.rst   |    9 -
 doc/guides/rel_notes/release_24_11.rst |    9 +
 examples/ip_fragmentation/main.c       |   23 +-
 examples/ip_pipeline/thread.c          |    2 +-
 examples/ip_reassembly/main.c          |   23 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h  |    7 +-
 examples/ipsec-secgw/ipsec_worker.c    |   11 +-
 examples/ipsec-secgw/ipsec_worker.h    |    4 +-
 examples/ipsec-secgw/rt.c              |   22 +-
 examples/l3fwd-graph/main.c            |    4 +-
 examples/l3fwd/l3fwd_fib.c             |    4 +-
 examples/l3fwd/l3fwd_lpm.c             |    8 +-
 examples/l3fwd/l3fwd_route.h           |    9 +-
 examples/l3fwd/lpm_route_parse.c       |    9 +-
 examples/l3fwd/main.c                  |   32 +-
 lib/lpm/meson.build                    |    1 +
 lib/lpm/rte_lpm6.c                     |  148 +-
 lib/lpm/rte_lpm6.h                     |   19 +-
 lib/node/ip6_lookup.c                  |   18 +-
 lib/table/rte_table_lpm_ipv6.c         |   12 +-
 lib/table/rte_table_lpm_ipv6.h         |    7 +-
 29 files changed, 1463 insertions(+), 1544 deletions(-)
app/test-fib/main.c +27 -47
index c49bfe8bcec3..9f45d03d81fb 100644
@@ -62,25 +62,6 @@ enum {
 	(unsigned)((unsigned char *)&addr)[2],	\
 	(unsigned)((unsigned char *)&addr)[1],	\
 	(unsigned)((unsigned char *)&addr)[0]
-
-#define NIPQUAD6_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
-#define NIPQUAD6(addr)				\
-	((uint8_t *)addr)[0] << 8 |	\
-	((uint8_t *)addr)[1],		\
-	((uint8_t *)addr)[2] << 8 |	\
-	((uint8_t *)addr)[3],		\
-	((uint8_t *)addr)[4] << 8 |	\
-	((uint8_t *)addr)[5],		\
-	((uint8_t *)addr)[6] << 8 |	\
-	((uint8_t *)addr)[7],		\
-	((uint8_t *)addr)[8] << 8 |	\
-	((uint8_t *)addr)[9],		\
-	((uint8_t *)addr)[10] << 8 |	\
-	((uint8_t *)addr)[11],		\
-	((uint8_t *)addr)[12] << 8 |	\
-	((uint8_t *)addr)[13],		\
-	((uint8_t *)addr)[14] << 8 |	\
-	((uint8_t *)addr)[15]
 #endif
 
 static struct {
@@ -123,7 +104,7 @@ struct rt_rule_4 {
 };
 
 struct rt_rule_6 {
-	uint8_t		addr[16];
+	struct rte_ipv6_addr addr;
 	uint8_t		depth;
 	uint64_t	nh;
 };
@@ -306,15 +287,15 @@ shuffle_rt_6(struct rt_rule_6 *rt, int n)
 
 	for (i = 0; i < n; i++) {
 		j = rte_rand() % n;
-		memcpy(tmp.addr, rt[i].addr, 16);
+		tmp.addr = rt[i].addr;
 		tmp.depth = rt[i].depth;
 		tmp.nh = rt[i].nh;
 
-		memcpy(rt[i].addr, rt[j].addr, 16);
+		rt[i].addr = rt[j].addr;
 		rt[i].depth = rt[j].depth;
 		rt[i].nh = rt[j].nh;
 
-		memcpy(rt[j].addr, tmp.addr, 16);
+		rt[j].addr = tmp.addr;
 		rt[j].depth = tmp.depth;
 		rt[j].nh = tmp.nh;
 	}
@@ -364,7 +345,7 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 	uint32_t a, i, j, k = 0;
 
 	if (config.nb_routes_per_depth[0] != 0) {
-		memset(rt[k].addr, 0, 16);
+		memset(&rt[k].addr, 0, 16);
 		rt[k].depth = 0;
 		rt[k++].nh = rte_rand() & get_max_nh(nh_sz);
 	}
@@ -380,7 +361,7 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 				uint64_t rnd_val = get_rnd_rng((uint64_t)edge,
 					(uint64_t)(edge + step));
 				rnd = rte_cpu_to_be_32(rnd_val << (32 - i));
-				complete_v6_addr((uint32_t *)rt[k].addr,
+				complete_v6_addr((uint32_t *)&rt[k].addr,
 					rnd, a);
 				rt[k].depth = (a * 32) + i;
 				rt[k].nh = rte_rand() & get_max_nh(nh_sz);
@@ -390,19 +371,19 @@ gen_random_rt_6(struct rt_rule_6 *rt, int nh_sz)
 }
 
 static inline void
-set_rnd_ipv6(uint8_t *addr, uint8_t *route, int depth)
+set_rnd_ipv6(struct rte_ipv6_addr *addr, struct rte_ipv6_addr *route, int depth)
 {
 	int i;
 
 	for (i = 0; i < 16; i++)
-		addr[i] = rte_rand();
+		addr->a[i] = rte_rand();
 
 	for (i = 0; i < 16; i++) {
 		if (depth >= 8)
-			addr[i] = route[i];
+			addr->a[i] = route->a[i];
 		else if (depth > 0) {
-			addr[i] &= (uint16_t)UINT8_MAX >> depth;
-			addr[i] |= route[i] & UINT8_MAX << (8 - depth);
+			addr->a[i] &= (uint16_t)UINT8_MAX >> depth;
+			addr->a[i] |= route->a[i] & UINT8_MAX << (8 - depth);
 		} else
 			return;
 		depth -= 8;
@@ -413,7 +394,7 @@ static void
 gen_rnd_lookup_tbl(int af)
 {
 	uint32_t *tbl4 = config.lookup_tbl;
-	uint8_t *tbl6 = config.lookup_tbl;
+	struct rte_ipv6_addr *tbl6 = config.lookup_tbl;
 	struct rt_rule_4 *rt4 = (struct rt_rule_4 *)config.rt;
 	struct rt_rule_6 *rt6 = (struct rt_rule_6 *)config.rt;
 	uint32_t i, j;
@@ -432,11 +413,10 @@ gen_rnd_lookup_tbl(int af)
 		for (i = 0, j = 0; i < config.nb_lookup_ips;
 				i++, j = (j + 1) % config.nb_routes) {
 			if ((rte_rand() % 100) < config.rnd_lookup_ips_ratio) {
-				set_rnd_ipv6(&tbl6[i * 16], rt6[j].addr, 0);
+				set_rnd_ipv6(&tbl6[i], &rt6[j].addr, 0);
 				config.nb_lookup_ips_rnd++;
 			} else {
-				set_rnd_ipv6(&tbl6[i * 16], rt6[j].addr,
-					rt6[j].depth);
+				set_rnd_ipv6(&tbl6[i], &rt6[j].addr, rt6[j].depth);
 			}
 		}
 	}
@@ -522,7 +502,7 @@ parse_rt_6(FILE *f)
 			s = NULL;
 		}
 
-		ret = _inet_net_pton(AF_INET6, in[RT_PREFIX], rt[j].addr);
+		ret = _inet_net_pton(AF_INET6, in[RT_PREFIX], &rt[j].addr);
 		if (ret < 0)
 			return ret;
 
@@ -561,7 +541,7 @@ dump_lookup(int af)
 {
 	FILE *f;
 	uint32_t *tbl4 = config.lookup_tbl;
-	uint8_t *tbl6 = config.lookup_tbl;
+	struct rte_ipv6_addr *tbl6 = config.lookup_tbl;
 	uint32_t i;
 
 	f = fopen(config.lookup_ips_file_s, "w");
@@ -575,7 +555,7 @@ dump_lookup(int af)
 			fprintf(f, NIPQUAD_FMT"\n", NIPQUAD(tbl4[i]));
 	} else {
 		for (i = 0; i < config.nb_lookup_ips; i++)
-			fprintf(f, NIPQUAD6_FMT"\n", NIPQUAD6(&tbl6[i * 16]));
+			fprintf(f, RTE_IPV6_ADDR_FMT"\n", RTE_IPV6_ADDR_SPLIT(&tbl6[i * 16]));
 	}
 	fclose(f);
 	return 0;
@@ -1023,7 +1003,7 @@ dump_rt_6(struct rt_rule_6 *rt)
 	}
 
 	for (i = 0; i < config.nb_routes; i++) {
-		fprintf(f, NIPQUAD6_FMT"/%d %"PRIu64"\n", NIPQUAD6(rt[i].addr),
+		fprintf(f, RTE_IPV6_ADDR_FMT"/%d %"PRIu64"\n", RTE_IPV6_ADDR_SPLIT(&rt[i].addr),
 			rt[i].depth, rt[i].nh);
 
 	}
@@ -1043,7 +1023,7 @@ run_v6(void)
 	int ret = 0;
 	struct rte_lpm6	*lpm = NULL;
 	struct rte_lpm6_config lpm_conf;
-	uint8_t *tbl6;
+	struct rte_ipv6_addr *tbl6;
 	uint64_t fib_nh[BURST_SZ];
 	int32_t lpm_nh[BURST_SZ];
 
@@ -1094,7 +1074,7 @@ run_v6(void)
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++) {
-			ret = rte_fib6_add(fib, rt[i + j].addr,
+			ret = rte_fib6_add(fib, rt[i + j].addr.a,
 				rt[i + j].depth, rt[i + j].nh);
 			if (unlikely(ret != 0)) {
 				printf("Can not add a route to FIB, err %d\n",
@@ -1120,7 +1100,7 @@ run_v6(void)
 		for (k = config.print_fract, i = 0; k > 0; k--) {
 			start = rte_rdtsc_precise();
 			for (j = 0; j < (config.nb_routes - i) / k; j++) {
-				ret = rte_lpm6_add(lpm, rt[i + j].addr,
+				ret = rte_lpm6_add(lpm, &rt[i + j].addr,
 					rt[i + j].depth, rt[i + j].nh);
 				if (ret != 0) {
 					if (rt[i + j].depth == 0)
@@ -1139,7 +1119,7 @@ run_v6(void)
 	acc = 0;
 	for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 		start = rte_rdtsc_precise();
-		ret = rte_fib6_lookup_bulk(fib, (uint8_t (*)[16])(tbl6 + i*16),
+		ret = rte_fib6_lookup_bulk(fib, &tbl6[i].a,
 			fib_nh, BURST_SZ);
 		acc += rte_rdtsc_precise() - start;
 		if (ret != 0) {
@@ -1154,7 +1134,7 @@ run_v6(void)
 		for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 			start = rte_rdtsc_precise();
 			ret = rte_lpm6_lookup_bulk_func(lpm,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				lpm_nh, BURST_SZ);
 			acc += rte_rdtsc_precise() - start;
 			if (ret != 0) {
@@ -1166,10 +1146,10 @@ run_v6(void)
 
 		for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 			rte_fib6_lookup_bulk(fib,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i].a,
 				fib_nh, BURST_SZ);
 			rte_lpm6_lookup_bulk_func(lpm,
-				(uint8_t (*)[16])(tbl6 + i*16),
+				&tbl6[i],
 				lpm_nh, BURST_SZ);
 			for (j = 0; j < BURST_SZ; j++) {
 				if ((fib_nh[j] != (uint32_t)lpm_nh[j]) &&
@@ -1186,7 +1166,7 @@ run_v6(void)
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++)
-			rte_fib6_delete(fib, rt[i + j].addr, rt[i + j].depth);
+			rte_fib6_delete(fib, rt[i + j].addr.a, rt[i + j].depth);
 
 		printf("AVG FIB delete %"PRIu64"\n",
 			(rte_rdtsc_precise() - start) / j);
@@ -1197,7 +1177,7 @@ run_v6(void)
 		for (k = config.print_fract, i = 0; k > 0; k--) {
 			start = rte_rdtsc_precise();
 			for (j = 0; j < (config.nb_routes - i) / k; j++)
-				rte_lpm6_delete(lpm, rt[i + j].addr,
+				rte_lpm6_delete(lpm, &rt[i + j].addr,
 					rt[i + j].depth);
 
 			printf("AVG LPM delete %"PRIu64"\n",
app/test-pipeline/pipeline_lpm_ipv6.c +3 -8
index 207ffbeff00f..6558e887c859 100644
@@ -127,16 +127,11 @@ app_main_loop_worker_pipeline_lpm_ipv6(void) {
 
 		ip = rte_bswap32(i << (24 -
 			rte_popcount32(app.n_ports - 1)));
-		memcpy(key.ip, &ip, sizeof(uint32_t));
+		memcpy(&key.ip, &ip, sizeof(uint32_t));
 
 		printf("Adding rule to IPv6 LPM table (IPv6 destination = "
-			"%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:"
-			"%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x/%u => "
-			"port out = %u)\n",
-			key.ip[0], key.ip[1], key.ip[2], key.ip[3],
-			key.ip[4], key.ip[5], key.ip[6], key.ip[7],
-			key.ip[8], key.ip[9], key.ip[10], key.ip[11],
-			key.ip[12], key.ip[13], key.ip[14], key.ip[15],
+			RTE_IPV6_ADDR_FMT "/%u => port out = %u)\n",
+			RTE_IPV6_ADDR_SPLIT(&key.ip),
 			key.depth, i);
 
 		status = rte_pipeline_table_entry_add(p, table_id, &key, &entry,
app/test/test_fib6_perf.c +3 -3
index fe713e7094e5..f03cd084aa64 100644
@@ -101,7 +101,7 @@ test_fib6_perf(void)
 
 	for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
 		next_hop_add = (i & ((1 << 14) - 1)) + 1;
-		if (rte_fib6_add(fib, large_route_table[i].ip,
+		if (rte_fib6_add(fib, large_route_table[i].ip.a,
 				large_route_table[i].depth, next_hop_add) == 0)
 			status++;
 	}
@@ -117,7 +117,7 @@ test_fib6_perf(void)
 	count = 0;
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++)
-		memcpy(ip_batch[i], large_ips_table[i].ip, 16);
+		memcpy(ip_batch[i], &large_ips_table[i].ip, 16);
 
 	for (i = 0; i < ITERATIONS; i++) {
 
@@ -140,7 +140,7 @@ test_fib6_perf(void)
 
 	for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
 		/* rte_fib_delete(fib, ip, depth) */
-		status += rte_fib6_delete(fib, large_route_table[i].ip,
+		status += rte_fib6_delete(fib, large_route_table[i].ip.a,
 				large_route_table[i].depth);
 	}
 
app/test/test_lpm6.c +232 -258

1,258 lines not on this page · raw message

app/test/test_lpm6_data.h +1013 -1012

1,487 lines not on this page · raw message

app/test/test_lpm6_perf.c +5 -5
index c847dcb18375..1860a99ed6f1 100644

Lines of this file are not shown. View the raw message.

app/test/test_table_combined.c +1 -1
index 1c2efe649ded..04503baa5180 100644

Lines of this file are not shown. View the raw message.

app/test/test_table_tables.c +4 -4
index 26908e6112fc..920aa555cbd2 100644

Lines of this file are not shown. View the raw message.

doc/guides/rel_notes/deprecation.rst +0 -9
index 830904203c38..0b658fce37f7 100644

Lines of this file are not shown. View the raw message.

doc/guides/rel_notes/release_24_11.rst +9 -0
index de24705ef662..c61269a635d5 100644

Lines of this file are not shown. View the raw message.

examples/ip_fragmentation/main.c +11 -12
index 4c0fa5054a2e..1f841028442f 100644

Lines of this file are not shown. View the raw message.

examples/ip_pipeline/thread.c +1 -1
index 8a912dc1b392..9d8082b73080 100644

Lines of this file are not shown. View the raw message.

examples/ip_reassembly/main.c +11 -12
index 4da692eb23e6..17ae76d4badb 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_lpm_neon.h +4 -3
index 9573f53ae957..752401d9f27f 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_worker.c +3 -8
index dd14226e8140..e0690fc8d9bd 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/ipsec_worker.h +2 -2
index 8f6a1c06aa7f..8f9616129362 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/rt.c +11 -11
index ce854ccb6018..059fc0c8f28c 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd-graph/main.c +2 -2
index a13dc011380d..9bda0ab633e1 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_fib.c +2 -2
index 85f862dd5b40..339cd58116a4 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_lpm.c +4 -4
index 422fdb70054d..fc4f5878fcd8 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/l3fwd_route.h +4 -5
index 467c4d285915..62263c354054 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/lpm_route_parse.c +4 -5
index f2028d79e180..9c179dc065c0 100644

Lines of this file are not shown. View the raw message.

examples/l3fwd/main.c +16 -16
index 01b763e5ba11..6e2155e0052e 100644

Lines of this file are not shown. View the raw message.

lib/lpm/meson.build +1 -0
index ae30f80b69c8..fae4f79fb938 100644

Lines of this file are not shown. View the raw message.

lib/lpm/rte_lpm6.c +59 -89

148 lines not on this page · raw message

lib/lpm/rte_lpm6.h +11 -8
index c93683e6240c..d7ebe9245c8e 100644

Lines of this file are not shown. View the raw message.

lib/node/ip6_lookup.c +9 -9
index 6bbcf14e2aa8..faaea5085938 100644

Lines of this file are not shown. View the raw message.

lib/table/rte_table_lpm_ipv6.c +6 -6
index c1a7412f92cf..dea11130d3d5 100644

Lines of this file are not shown. View the raw message.

lib/table/rte_table_lpm_ipv6.h +5 -2
index 166a5ba9ee67..3ea888360635 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.47.0

Part of the diff is not shown here. View the raw message.

#94 lore raw

PATCH v4 6/17 fib6: use IPv6 address structure and utils

In reply to Robin Jarry

Replace ad-hoc uint8_t[16] array types in the API of rte_fib6 with rte_ipv6_addr structures. Replace duplicate functions and macros with common ones from rte_ip6.h. Update all code accordingly.

---
 app/test-fib/main.c                    |   8 +-
 app/test/test_fib6.c                   |  92 +++++++++---------
 app/test/test_fib6_perf.c              |   8 +-
 doc/guides/rel_notes/deprecation.rst   |   4 -
 doc/guides/rel_notes/release_24_11.rst |   4 +
 examples/l3fwd/l3fwd_fib.c             |  39 ++++----
 lib/fib/meson.build                    |   3 +-
 lib/fib/rte_fib6.c                     |  25 ++---
 lib/fib/rte_fib6.h                     |  16 ++--
 lib/fib/trie.c                         | 123 +++++++++++--------------
 lib/fib/trie.h                         |  19 ++--
 lib/fib/trie_avx512.c                  |  38 ++++----
 lib/fib/trie_avx512.h                  |  10 +-
 13 files changed, 194 insertions(+), 195 deletions(-)
app/test-fib/main.c +4 -4
index 9f45d03d81fb..6479f48cdf6c 100644
@@ -1074,7 +1074,7 @@ run_v6(void)
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++) {
-			ret = rte_fib6_add(fib, rt[i + j].addr.a,
+			ret = rte_fib6_add(fib, &rt[i + j].addr,
 				rt[i + j].depth, rt[i + j].nh);
 			if (unlikely(ret != 0)) {
 				printf("Can not add a route to FIB, err %d\n",
@@ -1119,7 +1119,7 @@ run_v6(void)
 	acc = 0;
 	for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 		start = rte_rdtsc_precise();
-		ret = rte_fib6_lookup_bulk(fib, &tbl6[i].a,
+		ret = rte_fib6_lookup_bulk(fib, &tbl6[i],
 			fib_nh, BURST_SZ);
 		acc += rte_rdtsc_precise() - start;
 		if (ret != 0) {
@@ -1146,7 +1146,7 @@ run_v6(void)
 
 		for (i = 0; i < config.nb_lookup_ips; i += BURST_SZ) {
 			rte_fib6_lookup_bulk(fib,
-				&tbl6[i].a,
+				&tbl6[i],
 				fib_nh, BURST_SZ);
 			rte_lpm6_lookup_bulk_func(lpm,
 				&tbl6[i],
@@ -1166,7 +1166,7 @@ run_v6(void)
 	for (k = config.print_fract, i = 0; k > 0; k--) {
 		start = rte_rdtsc_precise();
 		for (j = 0; j < (config.nb_routes - i) / k; j++)
-			rte_fib6_delete(fib, rt[i + j].addr.a, rt[i + j].depth);
+			rte_fib6_delete(fib, &rt[i + j].addr, rt[i + j].depth);
 
 		printf("AVG FIB delete %"PRIu64"\n",
 			(rte_rdtsc_precise() - start) / j);
app/test/test_fib6.c +47 -45

185 lines not on this page · raw message

app/test/test_fib6_perf.c +4 -4
index f03cd084aa64..a96a0d6b2cdc 100644
@@ -73,7 +73,7 @@ test_fib6_perf(void)
 	uint64_t next_hop_add;
 	int status = 0;
 	int64_t count = 0;
-	uint8_t ip_batch[NUM_IPS_ENTRIES][16];
+	struct rte_ipv6_addr ip_batch[NUM_IPS_ENTRIES];
 	uint64_t next_hops[NUM_IPS_ENTRIES];
 
 	conf.type = RTE_FIB6_TRIE;
@@ -101,7 +101,7 @@ test_fib6_perf(void)
 
 	for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
 		next_hop_add = (i & ((1 << 14) - 1)) + 1;
-		if (rte_fib6_add(fib, large_route_table[i].ip.a,
+		if (rte_fib6_add(fib, &large_route_table[i].ip,
 				large_route_table[i].depth, next_hop_add) == 0)
 			status++;
 	}
@@ -117,7 +117,7 @@ test_fib6_perf(void)
 	count = 0;
 
 	for (i = 0; i < NUM_IPS_ENTRIES; i++)
-		memcpy(ip_batch[i], &large_ips_table[i].ip, 16);
+		ip_batch[i] = large_ips_table[i].ip;
 
 	for (i = 0; i < ITERATIONS; i++) {
 
@@ -140,7 +140,7 @@ test_fib6_perf(void)
 
 	for (i = 0; i < NUM_ROUTE_ENTRIES; i++) {
 		/* rte_fib_delete(fib, ip, depth) */
-		status += rte_fib6_delete(fib, large_route_table[i].ip.a,
+		status += rte_fib6_delete(fib, &large_route_table[i].ip,
 				large_route_table[i].depth);
 	}
 
doc/guides/rel_notes/deprecation.rst +0 -4
index 0b658fce37f7..582d54aece2f 100644
@@ -70,10 +70,6 @@ Deprecation Notices
     - ``struct rte_flow_item_icmp6_nd_na``
     - ``struct rte_flow_action_set_ipv6``
     - ``struct rte_flow_tunnel``
-  fib
-    - ``rte_fib6_add()``
-    - ``rte_fib6_delete()``
-    - ``rte_fib6_lookup_bulk()``
   gro
     - ``struct tcp6_flow_key``
   hash
doc/guides/rel_notes/release_24_11.rst +4 -0
index c61269a635d5..aada0df483c8 100644
@@ -289,6 +289,10 @@ API Changes
 * net: A new IPv6 address structure was introduced to replace ad-hoc ``uint8_t[16]`` arrays.
   The following libraries and symbols were modified:
 
+  fib
+    - ``rte_fib6_add()``
+    - ``rte_fib6_delete()``
+    - ``rte_fib6_lookup_bulk()``
   lpm
     - ``rte_lpm6_add()``
     - ``rte_lpm6_delete()``
examples/l3fwd/l3fwd_fib.c +18 -21
index 339cd58116a4..a0eef05a5dd8 100644
@@ -46,7 +46,7 @@ static struct rte_fib6 *ipv6_l3fwd_fib_lookup_struct[NB_SOCKETS];
 static inline void
 fib_parse_packet(struct rte_mbuf *mbuf,
 		uint32_t *ipv4, uint32_t *ipv4_cnt,
-		uint8_t ipv6[RTE_FIB6_IPV6_ADDR_SIZE],
+		struct rte_ipv6_addr *ipv6,
 		uint32_t *ipv6_cnt, uint8_t *ip_type)
 {
 	struct rte_ether_hdr *eth_hdr;
@@ -65,7 +65,7 @@ fib_parse_packet(struct rte_mbuf *mbuf,
 	/* IPv6 */
 	else {
 		ipv6_hdr = (struct rte_ipv6_hdr *)(eth_hdr + 1);
-		rte_mov16(ipv6, ipv6_hdr->dst_addr.a);
+		*ipv6 = ipv6_hdr->dst_addr;
 		*ip_type = 0;
 		(*ipv6_cnt)++;
 	}
@@ -120,7 +120,7 @@ fib_send_packets(int nb_rx, struct rte_mbuf **pkts_burst,
 		uint16_t portid, struct lcore_conf *qconf)
 {
 	uint32_t ipv4_arr[nb_rx];
-	uint8_t ipv6_arr[nb_rx][RTE_FIB6_IPV6_ADDR_SIZE];
+	struct rte_ipv6_addr ipv6_arr[nb_rx];
 	uint16_t hops[nb_rx];
 	uint64_t hopsv4[nb_rx], hopsv6[nb_rx];
 	uint8_t type_arr[nb_rx];
@@ -140,7 +140,7 @@ fib_send_packets(int nb_rx, struct rte_mbuf **pkts_burst,
 				i + FIB_PREFETCH_OFFSET], void *));
 		fib_parse_packet(pkts_burst[i],
 				&ipv4_arr[ipv4_cnt], &ipv4_cnt,
-				ipv6_arr[ipv6_cnt], &ipv6_cnt,
+				&ipv6_arr[ipv6_cnt], &ipv6_cnt,
 				&type_arr[i]);
 	}
 
@@ -148,7 +148,7 @@ fib_send_packets(int nb_rx, struct rte_mbuf **pkts_burst,
 	for (; i < nb_rx; i++)
 		fib_parse_packet(pkts_burst[i],
 				&ipv4_arr[ipv4_cnt], &ipv4_cnt,
-				ipv6_arr[ipv6_cnt], &ipv6_cnt,
+				&ipv6_arr[ipv6_cnt], &ipv6_cnt,
 				&type_arr[i]);
 
 	/* Lookup IPv4 hops if IPv4 packets are present. */
@@ -270,7 +270,7 @@ fib_event_loop(struct l3fwd_event_resources *evt_rsrc,
 	unsigned int lcore_id;
 
 	uint32_t ipv4_arr[MAX_PKT_BURST];
-	uint8_t ipv6_arr[MAX_PKT_BURST][RTE_FIB6_IPV6_ADDR_SIZE];
+	struct rte_ipv6_addr ipv6_arr[MAX_PKT_BURST];
 	uint64_t hopsv4[MAX_PKT_BURST], hopsv6[MAX_PKT_BURST];
 	uint16_t nh, hops[MAX_PKT_BURST];
 	uint8_t type_arr[MAX_PKT_BURST];
@@ -323,7 +323,7 @@ fib_event_loop(struct l3fwd_event_resources *evt_rsrc,
 
 			fib_parse_packet(events[i].mbuf,
 					&ipv4_arr[ipv4_cnt], &ipv4_cnt,
-					ipv6_arr[ipv6_cnt], &ipv6_cnt,
+					&ipv6_arr[ipv6_cnt], &ipv6_cnt,
 					&type_arr[i]);
 		}
 
@@ -340,7 +340,7 @@ fib_event_loop(struct l3fwd_event_resources *evt_rsrc,
 
 			fib_parse_packet(events[i].mbuf,
 					&ipv4_arr[ipv4_cnt], &ipv4_cnt,
-					ipv6_arr[ipv6_cnt], &ipv6_cnt,
+					&ipv6_arr[ipv6_cnt], &ipv6_cnt,
 					&type_arr[i]);
 		}
 
@@ -436,7 +436,7 @@ fib_event_main_loop_tx_q_burst(__rte_unused void *dummy)
 
 static __rte_always_inline void
 fib_process_event_vector(struct rte_event_vector *vec, uint8_t *type_arr,
-			 uint8_t **ipv6_arr, uint64_t *hopsv4, uint64_t *hopsv6,
+			 struct rte_ipv6_addr *ipv6_arr, uint64_t *hopsv4, uint64_t *hopsv6,
 			 uint32_t *ipv4_arr, uint16_t *hops)
 {
 	uint32_t ipv4_arr_assem, ipv6_arr_assem;
@@ -463,13 +463,13 @@ fib_process_event_vector(struct rte_event_vector *vec, uint8_t *type_arr,
 		rte_prefetch0(rte_pktmbuf_mtod(mbufs[i + FIB_PREFETCH_OFFSET],
 					       void *));
 		fib_parse_packet(mbufs[i], &ipv4_arr[ipv4_cnt], &ipv4_cnt,
-				 ipv6_arr[ipv6_cnt], &ipv6_cnt, &type_arr[i]);
+				 &ipv6_arr[ipv6_cnt], &ipv6_cnt, &type_arr[i]);
 	}
 
 	/* Parse remaining packet info. */
 	for (; i < vec->nb_elem; i++)
 		fib_parse_packet(mbufs[i], &ipv4_arr[ipv4_cnt], &ipv4_cnt,
-				 ipv6_arr[ipv6_cnt], &ipv6_cnt, &type_arr[i]);
+				 &ipv6_arr[ipv6_cnt], &ipv6_cnt, &type_arr[i]);
 
 	/* Lookup IPv4 hops if IPv4 packets are present. */
 	if (likely(ipv4_cnt > 0))
@@ -480,7 +480,7 @@ fib_process_event_vector(struct rte_event_vector *vec, uint8_t *type_arr,
 	if (ipv6_cnt > 0)
 		rte_fib6_lookup_bulk(
 			lconf->ipv6_lookup_struct,
-			(uint8_t(*)[RTE_FIB6_IPV6_ADDR_SIZE])ipv6_arr, hopsv6,
+			ipv6_arr, hopsv6,
 			ipv6_cnt);
 
 	/* Assign ports looked up in fib depending on IPv4 or IPv6 */
@@ -522,7 +522,8 @@ fib_event_loop_vector(struct l3fwd_event_resources *evt_rsrc,
 	const uint8_t event_d_id = evt_rsrc->event_d_id;
 	const uint16_t deq_len = evt_rsrc->deq_depth;
 	struct rte_event events[MAX_PKT_BURST];
-	uint8_t *type_arr, **ipv6_arr, *ptr;
+	uint8_t *type_arr;
+	struct rte_ipv6_addr *ipv6_arr;
 	int nb_enq = 0, nb_deq = 0, i;
 	uint64_t *hopsv4, *hopsv6;
 	uint32_t *ipv4_arr;
@@ -533,7 +534,7 @@ fib_event_loop_vector(struct l3fwd_event_resources *evt_rsrc,
 		"vector_fib",
 		(sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint64_t) +
 		 sizeof(uint64_t) + sizeof(uint16_t) + sizeof(uint8_t *) +
-		 (sizeof(uint8_t) * RTE_FIB6_IPV6_ADDR_SIZE)) *
+		 sizeof(struct rte_ipv6_addr)) *
 			evt_rsrc->vector_size,
 		RTE_CACHE_LINE_SIZE);
 	if (mem == 0)
@@ -543,11 +544,7 @@ fib_event_loop_vector(struct l3fwd_event_resources *evt_rsrc,
 	hopsv4 = (uint64_t *)&type_arr[evt_rsrc->vector_size];
 	hopsv6 = (uint64_t *)&hopsv4[evt_rsrc->vector_size];
 	hops = (uint16_t *)&hopsv6[evt_rsrc->vector_size];
-	ipv6_arr = (uint8_t **)&hops[evt_rsrc->vector_size];
-
-	ptr = (uint8_t *)&ipv6_arr[evt_rsrc->vector_size];
-	for (i = 0; i < evt_rsrc->vector_size; i++)
-		ipv6_arr[i] = &ptr[RTE_FIB6_IPV6_ADDR_SIZE + i];
+	ipv6_arr = (struct rte_ipv6_addr *)&hops[evt_rsrc->vector_size];
 
 	if (event_p_id < 0) {
 		rte_free((void *)mem);
@@ -732,7 +729,7 @@ setup_fib(const int socketid)
 		rte_eth_dev_info_get(route_base_v6[i].if_out,
 				     &dev_info);
 		ret = rte_fib6_add(ipv6_l3fwd_fib_lookup_struct[socketid],
-			route_base_v6[i].ip6.a,
+			&route_base_v6[i].ip6,
 			route_base_v6[i].depth,
 			route_base_v6[i].if_out);
 
@@ -744,7 +741,7 @@ setup_fib(const int socketid)
 					i, socketid);
 		}
 
-		if (inet_ntop(AF_INET6, route_base_v6[i].ip6.a,
+		if (inet_ntop(AF_INET6, &route_base_v6[i].ip6,
 				abuf, sizeof(abuf)) != NULL) {
 			printf("FIB: Adding route %s / %d (%d) [%s]\n", abuf,
 			       route_base_v6[i].depth,
lib/fib/meson.build +2 -1
index 0004797dd5ac..0c19cc8201bf 100644
@@ -12,6 +12,7 @@ sources = files('rte_fib.c', 'rte_fib6.c', 'dir24_8.c', 'trie.c')
 headers = files('rte_fib.h', 'rte_fib6.h')
 deps += ['rib']
 deps += ['rcu']
+deps += ['net']
 
 if dpdk_conf.has('RTE_ARCH_X86_64')
     if target_has_avx512
@@ -27,7 +28,7 @@ if dpdk_conf.has('RTE_ARCH_X86_64')
         objs += dir24_8_avx512_tmp.extract_objects('dir24_8_avx512.c')
         trie_avx512_tmp = static_library('trie_avx512_tmp',
                 'trie_avx512.c',
-                dependencies: [static_rte_eal, static_rte_rcu],
+                dependencies: [static_rte_eal, static_rte_rcu, static_rte_net],
                 c_args: cflags + cc_avx512_flags)
         objs += trie_avx512_tmp.extract_objects('trie_avx512.c')
     endif
lib/fib/rte_fib6.c +13 -12
index 9ad990724a8b..ef334da67cc4 100644
@@ -14,6 +14,7 @@
 #include <rte_malloc.h>
 #include <rte_string_fns.h>
 
+#include <rte_ip6.h>
 #include <rte_rib6.h>
 #include <rte_fib6.h>
 
@@ -49,7 +50,7 @@ struct rte_fib6 {
 };
 
 static void
-dummy_lookup(void *fib_p, uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
+dummy_lookup(void *fib_p, const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, const unsigned int n)
 {
 	unsigned int i;
@@ -57,7 +58,7 @@ dummy_lookup(void *fib_p, uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
 	struct rte_rib6_node *node;
 
 	for (i = 0; i < n; i++) {
-		node = rte_rib6_lookup(fib->rib, ips[i]);
+		node = rte_rib6_lookup(fib->rib, ips[i].a);
 		if (node != NULL)
 			rte_rib6_get_nh(node, &next_hops[i]);
 		else
@@ -66,26 +67,26 @@ dummy_lookup(void *fib_p, uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
 }
 
 static int
-dummy_modify(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
+dummy_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth, uint64_t next_hop, int op)
 {
 	struct rte_rib6_node *node;
-	if ((fib == NULL) || (depth > RTE_FIB6_MAXDEPTH))
+	if ((fib == NULL) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
-	node = rte_rib6_lookup_exact(fib->rib, ip, depth);
+	node = rte_rib6_lookup_exact(fib->rib, ip->a, depth);
 
 	switch (op) {
 	case RTE_FIB6_ADD:
 		if (node == NULL)
-			node = rte_rib6_insert(fib->rib, ip, depth);
+			node = rte_rib6_insert(fib->rib, ip->a, depth);
 		if (node == NULL)
 			return -rte_errno;
 		return rte_rib6_set_nh(node, next_hop);
 	case RTE_FIB6_DEL:
 		if (node == NULL)
 			return -ENOENT;
-		rte_rib6_remove(fib->rib, ip, depth);
+		rte_rib6_remove(fib->rib, ip->a, depth);
 		return 0;
 	}
 	return -EINVAL;
@@ -118,28 +119,28 @@ init_dataplane(struct rte_fib6 *fib, __rte_unused int socket_id,
 }
 
 int
-rte_fib6_add(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
+rte_fib6_add(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth, uint64_t next_hop)
 {
 	if ((fib == NULL) || (ip == NULL) || (fib->modify == NULL) ||
-			(depth > RTE_FIB6_MAXDEPTH))
+			(depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 	return fib->modify(fib, ip, depth, next_hop, RTE_FIB6_ADD);
 }
 
 int
-rte_fib6_delete(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
+rte_fib6_delete(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth)
 {
 	if ((fib == NULL) || (ip == NULL) || (fib->modify == NULL) ||
-			(depth > RTE_FIB6_MAXDEPTH))
+			(depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 	return fib->modify(fib, ip, depth, 0, RTE_FIB6_DEL);
 }
 
 int
 rte_fib6_lookup_bulk(struct rte_fib6 *fib,
-	uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
+	const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, int n)
 {
 	FIB6_RETURN_IF_TRUE((fib == NULL) || (ips == NULL) ||
lib/fib/rte_fib6.h +9 -7
index 2eb8b8267647..21f0492374d9 100644
@@ -17,14 +17,16 @@
 
 #include <stdint.h>
 
+#include <rte_common.h>
+#include <rte_ip6.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define RTE_FIB6_IPV6_ADDR_SIZE		16
+#define RTE_FIB6_IPV6_ADDR_SIZE (RTE_DEPRECATED(RTE_FIB6_IPV6_ADDR_SIZE) RTE_IPV6_ADDR_SIZE)
 /** Maximum depth value possible for IPv6 FIB. */
-#define RTE_FIB6_MAXDEPTH       128
+#define RTE_FIB6_MAXDEPTH (RTE_DEPRECATED(RTE_FIB6_MAXDEPTH) RTE_IPV6_MAX_DEPTH)
 
 struct rte_fib6;
 struct rte_rib6;
@@ -37,11 +39,11 @@ enum rte_fib6_type {
 
 /** Modify FIB function */
 typedef int (*rte_fib6_modify_fn_t)(struct rte_fib6 *fib,
-	const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE], uint8_t depth,
+	const struct rte_ipv6_addr *ip, uint8_t depth,
 	uint64_t next_hop, int op);
 /** FIB bulk lookup function */
 typedef void (*rte_fib6_lookup_fn_t)(void *fib,
-	uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
+	const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, const unsigned int n);
 
 enum rte_fib6_op {
@@ -134,7 +136,7 @@ rte_fib6_free(struct rte_fib6 *fib);
  *   0 on success, negative value otherwise
  */
 int
-rte_fib6_add(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
+rte_fib6_add(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth, uint64_t next_hop);
 
 /**
@@ -151,7 +153,7 @@ rte_fib6_add(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
  */
 int
 rte_fib6_delete(struct rte_fib6 *fib,
-	const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE], uint8_t depth);
+	const struct rte_ipv6_addr *ip, uint8_t depth);
 
 /**
  * Lookup multiple IP addresses in the FIB.
@@ -172,7 +174,7 @@ rte_fib6_delete(struct rte_fib6 *fib,
  */
 int
 rte_fib6_lookup_bulk(struct rte_fib6 *fib,
-	uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
+	const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, int n);
 
 /**
lib/fib/trie.c +56 -67

302 lines not on this page · raw message

lib/fib/trie.h +11 -8
index 2c20184a26a3..6004ec49ce7c 100644
@@ -8,6 +8,9 @@
 
 #include <stdalign.h>
 
+#include <rte_common.h>
+#include <rte_fib6.h>
+
 /**
  * @file
  * RTE IPv6 Longest Prefix Match (LPM)
@@ -16,7 +19,7 @@
 /* @internal Total number of tbl24 entries. */
 #define TRIE_TBL24_NUM_ENT	(1 << 24)
 /* Maximum depth value possible for IPv6 LPM. */
-#define TRIE_MAX_DEPTH		128
+#define TRIE_MAX_DEPTH (RTE_DEPRECATED(TRIE_MAX_DEPTH) RTE_IPV6_MAX_DEPTH)
 /* @internal Number of entries in a tbl8 group. */
 #define TRIE_TBL8_GRP_NUM_ENT	256ULL
 /* @internal Total number of tbl8 groups in the tbl8. */
@@ -42,13 +45,13 @@ struct rte_trie_tbl {
 };
 
 static inline uint32_t
-get_tbl24_idx(const uint8_t *ip)
+get_tbl24_idx(const struct rte_ipv6_addr *ip)
 {
-	return ip[0] << 16|ip[1] << 8|ip[2];
+	return ip->a[0] << 16|ip->a[1] << 8|ip->a[2];
 }
 
 static inline void *
-get_tbl24_p(struct rte_trie_tbl *dp, const uint8_t *ip, uint8_t nh_sz)
+get_tbl24_p(struct rte_trie_tbl *dp, const struct rte_ipv6_addr *ip, uint8_t nh_sz)
 {
 	uint32_t tbl24_idx;
 
@@ -107,7 +110,7 @@ is_entry_extended(uint64_t ent)
 
 #define LOOKUP_FUNC(suffix, type, nh_sz)				\
 static inline void rte_trie_lookup_bulk_##suffix(void *p,		\
-	uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],				\
+	const struct rte_ipv6_addr *ips,				\
 	uint64_t *next_hops, const unsigned int n)			\
 {									\
 	struct rte_trie_tbl *dp = (struct rte_trie_tbl *)p;		\
@@ -115,10 +118,10 @@ static inline void rte_trie_lookup_bulk_##suffix(void *p,		\
 	uint32_t i, j;							\
 									\
 	for (i = 0; i < n; i++) {					\
-		tmp = ((type *)dp->tbl24)[get_tbl24_idx(&ips[i][0])];	\
+		tmp = ((type *)dp->tbl24)[get_tbl24_idx(&ips[i])];	\
 		j = 3;							\
 		while (is_entry_extended(tmp)) {			\
-			tmp = ((type *)dp->tbl8)[ips[i][j++] +		\
+			tmp = ((type *)dp->tbl8)[ips[i].a[j++] +	\
 				((tmp >> 1) * TRIE_TBL8_GRP_NUM_ENT)];	\
 		}							\
 		next_hops[i] = tmp >> 1;				\
@@ -138,7 +141,7 @@ rte_fib6_lookup_fn_t
 trie_get_lookup_fn(void *p, enum rte_fib6_lookup_type type);
 
 int
-trie_modify(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
+trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	uint8_t depth, uint64_t next_hop, int op);
 
 #endif /* _TRIE_H_ */
lib/fib/trie_avx512.c +19 -19
index d4d70d84bf60..f49482a95dfa 100644
@@ -9,7 +9,7 @@
 #include "trie_avx512.h"
 
 static __rte_always_inline void
-transpose_x16(uint8_t ips[16][RTE_FIB6_IPV6_ADDR_SIZE],
+transpose_x16(const struct rte_ipv6_addr *ips,
 	__m512i *first, __m512i *second, __m512i *third, __m512i *fourth)
 {
 	__m512i tmp1, tmp2, tmp3, tmp4;
@@ -21,10 +21,10 @@ transpose_x16(uint8_t ips[16][RTE_FIB6_IPV6_ADDR_SIZE],
 	};
 
 	/* load all ip addresses */
-	tmp1 = _mm512_loadu_si512(&ips[0][0]);
-	tmp2 = _mm512_loadu_si512(&ips[4][0]);
-	tmp3 = _mm512_loadu_si512(&ips[8][0]);
-	tmp4 = _mm512_loadu_si512(&ips[12][0]);
+	tmp1 = _mm512_loadu_si512(&ips[0]);
+	tmp2 = _mm512_loadu_si512(&ips[4]);
+	tmp3 = _mm512_loadu_si512(&ips[8]);
+	tmp4 = _mm512_loadu_si512(&ips[12]);
 
 	/* transpose 4 byte chunks of 16 ips */
 	tmp5 = _mm512_unpacklo_epi32(tmp1, tmp2);
@@ -48,7 +48,7 @@ transpose_x16(uint8_t ips[16][RTE_FIB6_IPV6_ADDR_SIZE],
 }
 
 static __rte_always_inline void
-transpose_x8(uint8_t ips[8][RTE_FIB6_IPV6_ADDR_SIZE],
+transpose_x8(const struct rte_ipv6_addr *ips,
 	__m512i *first, __m512i *second)
 {
 	__m512i tmp1, tmp2, tmp3, tmp4;
@@ -57,8 +57,8 @@ transpose_x8(uint8_t ips[8][RTE_FIB6_IPV6_ADDR_SIZE],
 		},
 	};
 
-	tmp1 = _mm512_loadu_si512(&ips[0][0]);
-	tmp2 = _mm512_loadu_si512(&ips[4][0]);
+	tmp1 = _mm512_loadu_si512(&ips[0]);
+	tmp2 = _mm512_loadu_si512(&ips[4]);
 
 	tmp3 = _mm512_unpacklo_epi64(tmp1, tmp2);
 	*first = _mm512_permutexvar_epi64(perm_idxes.z, tmp3);
@@ -67,7 +67,7 @@ transpose_x8(uint8_t ips[8][RTE_FIB6_IPV6_ADDR_SIZE],
 }
 
 static __rte_always_inline void
-trie_vec_lookup_x16x2(void *p, uint8_t ips[32][RTE_FIB6_IPV6_ADDR_SIZE],
+trie_vec_lookup_x16x2(void *p, const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, int size)
 {
 	struct rte_trie_tbl *dp = (struct rte_trie_tbl *)p;
@@ -213,7 +213,7 @@ trie_vec_lookup_x16x2(void *p, uint8_t ips[32][RTE_FIB6_IPV6_ADDR_SIZE],
 }
 
 static void
-trie_vec_lookup_x8x2_8b(void *p, uint8_t ips[16][RTE_FIB6_IPV6_ADDR_SIZE],
+trie_vec_lookup_x8x2_8b(void *p, const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops)
 {
 	struct rte_trie_tbl *dp = (struct rte_trie_tbl *)p;
@@ -306,40 +306,40 @@ trie_vec_lookup_x8x2_8b(void *p, uint8_t ips[16][RTE_FIB6_IPV6_ADDR_SIZE],
 }
 
 void
-rte_trie_vec_lookup_bulk_2b(void *p, uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
+rte_trie_vec_lookup_bulk_2b(void *p, const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, const unsigned int n)
 {
 	uint32_t i;
 	for (i = 0; i < (n / 32); i++) {
-		trie_vec_lookup_x16x2(p, (uint8_t (*)[16])&ips[i * 32][0],
+		trie_vec_lookup_x16x2(p, &ips[i * 32],
 				next_hops + i * 32, sizeof(uint16_t));
 	}
-	rte_trie_lookup_bulk_2b(p, (uint8_t (*)[16])&ips[i * 32][0],
+	rte_trie_lookup_bulk_2b(p, &ips[i * 32],
 			next_hops + i * 32, n - i * 32);
 }
 
 void
-rte_trie_vec_lookup_bulk_4b(void *p, uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
+rte_trie_vec_lookup_bulk_4b(void *p, const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, const unsigned int n)
 {
 	uint32_t i;
 	for (i = 0; i < (n / 32); i++) {
-		trie_vec_lookup_x16x2(p, (uint8_t (*)[16])&ips[i * 32][0],
+		trie_vec_lookup_x16x2(p, &ips[i * 32],
 				next_hops + i * 32, sizeof(uint32_t));
 	}
-	rte_trie_lookup_bulk_4b(p, (uint8_t (*)[16])&ips[i * 32][0],
+	rte_trie_lookup_bulk_4b(p, &ips[i * 32],
 			next_hops + i * 32, n - i * 32);
 }
 
 void
-rte_trie_vec_lookup_bulk_8b(void *p, uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
+rte_trie_vec_lookup_bulk_8b(void *p, const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, const unsigned int n)
 {
 	uint32_t i;
 	for (i = 0; i < (n / 16); i++) {
-		trie_vec_lookup_x8x2_8b(p, (uint8_t (*)[16])&ips[i * 16][0],
+		trie_vec_lookup_x8x2_8b(p, &ips[i * 16],
 				next_hops + i * 16);
 	}
-	rte_trie_lookup_bulk_8b(p, (uint8_t (*)[16])&ips[i * 16][0],
+	rte_trie_lookup_bulk_8b(p, &ips[i * 16],
 			next_hops + i * 16, n - i * 16);
 }
lib/fib/trie_avx512.h +7 -3
index ef8c7f0e3474..1028a4899fc7 100644
@@ -5,16 +5,20 @@
 #ifndef _TRIE_AVX512_H_
 #define _TRIE_AVX512_H_
 
+#include <stdint.h>
+
+struct rte_ipv6_addr;
+
 void
-rte_trie_vec_lookup_bulk_2b(void *p, uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
+rte_trie_vec_lookup_bulk_2b(void *p, const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, const unsigned int n);
 
 void
-rte_trie_vec_lookup_bulk_4b(void *p, uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
+rte_trie_vec_lookup_bulk_4b(void *p, const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, const unsigned int n);
 
 void
-rte_trie_vec_lookup_bulk_8b(void *p, uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
+rte_trie_vec_lookup_bulk_8b(void *p, const struct rte_ipv6_addr *ips,
 	uint64_t *next_hops, const unsigned int n);
 
 #endif /* _TRIE_AVX512_H_ */
Signature · 1 line
2.47.0
#95 lore raw

PATCH v4 7/17 rib6: use IPv6 address structure and utils

In reply to Robin Jarry

Replace ad-hoc uint8_t[16] array types in the API of rte_rib6 with rte_ipv6_addr structures. Replace duplicate functions and macros with common ones from rte_ip6.h. Update all code accordingly.

---
 app/test/test_rib6.c                   |  55 ++++++------
 doc/guides/rel_notes/deprecation.rst   |   7 --
 doc/guides/rel_notes/release_24_11.rst |  11 +++
 lib/fib/rte_fib6.c                     |   8 +-
 lib/fib/trie.c                         |  16 ++--
 lib/rib/meson.build                    |   2 +-
 lib/rib/rte_rib6.c                     | 112 ++++++++++---------------
 lib/rib/rte_rib6.h                     |  27 ++++--
 8 files changed, 113 insertions(+), 125 deletions(-)
app/test/test_rib6.c +25 -30
index 33596fddb4e5..ba54a3794ea7 100644
@@ -6,7 +6,7 @@
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_rib6.h>
 
 #include "test.h"
@@ -118,14 +118,14 @@ test_insert_invalid(void)
 	struct rte_rib6 *rib = NULL;
 	struct rte_rib6_node *node, *node1;
 	struct rte_rib6_conf config;
-	uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE] = {0};
+	struct rte_ipv6_addr ip = {0};
 	uint8_t depth = 24;
 
 	config.max_nodes = MAX_RULES;
 	config.ext_sz = 0;
 
 	/* rte_rib6_insert: rib == NULL */
-	node = rte_rib6_insert(NULL, ip, depth);
+	node = rte_rib6_insert(NULL, &ip, depth);
 	RTE_TEST_ASSERT(node == NULL,
 		"Call succeeded with invalid parameters\n");
 
@@ -134,14 +134,14 @@ test_insert_invalid(void)
 	RTE_TEST_ASSERT(rib != NULL, "Failed to create RIB\n");
 
 	/* rte_rib6_insert: depth > MAX_DEPTH */
-	node = rte_rib6_insert(rib, ip, MAX_DEPTH + 1);
+	node = rte_rib6_insert(rib, &ip, MAX_DEPTH + 1);
 	RTE_TEST_ASSERT(node == NULL,
 		"Call succeeded with invalid parameters\n");
 
 	/* insert the same ip/depth twice*/
-	node = rte_rib6_insert(rib, ip, depth);
+	node = rte_rib6_insert(rib, &ip, depth);
 	RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n");
-	node1 = rte_rib6_insert(rib, ip, depth);
+	node1 = rte_rib6_insert(rib, &ip, depth);
 	RTE_TEST_ASSERT(node1 == NULL,
 		"Call succeeded with invalid parameters\n");
 
@@ -162,9 +162,8 @@ test_get_fn(void)
 	struct rte_rib6_node *node;
 	struct rte_rib6_conf config;
 	void *ext;
-	uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE] = {192, 0, 2, 0, 0, 0, 0, 0,
-						0, 0, 0, 0, 0, 0, 0, 0};
-	uint8_t ip_ret[RTE_RIB6_IPV6_ADDR_SIZE];
+	struct rte_ipv6_addr ip = RTE_IPV6(0xc000, 0x0200, 0, 0, 0, 0, 0, 0);
+	struct rte_ipv6_addr ip_ret;
 	uint64_t nh_set = 10;
 	uint64_t nh_ret;
 	uint8_t depth = 24;
@@ -177,11 +176,11 @@ test_get_fn(void)
 	rib = rte_rib6_create(__func__, SOCKET_ID_ANY, &config);
 	RTE_TEST_ASSERT(rib != NULL, "Failed to create RIB\n");
 
-	node = rte_rib6_insert(rib, ip, depth);
+	node = rte_rib6_insert(rib, &ip, depth);
 	RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n");
 
 	/* test rte_rib6_get_ip() with incorrect args */
-	ret = rte_rib6_get_ip(NULL, ip_ret);
+	ret = rte_rib6_get_ip(NULL, &ip_ret);
 	RTE_TEST_ASSERT(ret < 0,
 		"Call succeeded with invalid parameters\n");
 	ret = rte_rib6_get_ip(node, NULL);
@@ -215,8 +214,8 @@ test_get_fn(void)
 		"Call succeeded with invalid parameters\n");
 
 	/* check the return values */
-	ret = rte_rib6_get_ip(node, ip_ret);
-	RTE_TEST_ASSERT((ret == 0) && (rte_rib6_is_equal(ip_ret, ip)),
+	ret = rte_rib6_get_ip(node, &ip_ret);
+	RTE_TEST_ASSERT((ret == 0) && (rte_ipv6_addr_eq(&ip_ret, &ip)),
 		"Failed to get proper node ip\n");
 	ret = rte_rib6_get_depth(node, &depth_ret);
 	RTE_TEST_ASSERT((ret == 0) && (depth_ret == depth),
@@ -243,8 +242,7 @@ test_basic(void)
 	struct rte_rib6_node *node;
 	struct rte_rib6_conf config;
 
-	uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE] = {192, 0, 2, 0, 0, 0, 0, 0,
-						0, 0, 0, 0, 0, 0, 0, 0};
+	struct rte_ipv6_addr ip = RTE_IPV6(0xc000, 0x0200, 0, 0, 0, 0, 0, 0);
 	uint64_t next_hop_add = 10;
 	uint64_t next_hop_return;
 	uint8_t depth = 24;
@@ -256,21 +254,21 @@ test_basic(void)
 	rib = rte_rib6_create(__func__, SOCKET_ID_ANY, &config);
 	RTE_TEST_ASSERT(rib != NULL, "Failed to create RIB\n");
 
-	node = rte_rib6_insert(rib, ip, depth);
+	node = rte_rib6_insert(rib, &ip, depth);
 	RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n");
 
 	status = rte_rib6_set_nh(node, next_hop_add);
 	RTE_TEST_ASSERT(status == 0,
 		"Failed to set rte_rib_node field\n");
 
-	node = rte_rib6_lookup(rib, ip);
+	node = rte_rib6_lookup(rib, &ip);
 	RTE_TEST_ASSERT(node != NULL, "Failed to lookup\n");
 
 	status = rte_rib6_get_nh(node, &next_hop_return);
 	RTE_TEST_ASSERT((status == 0) && (next_hop_add == next_hop_return),
 		"Failed to get proper nexthop\n");
 
-	node = rte_rib6_lookup_exact(rib, ip, depth);
+	node = rte_rib6_lookup_exact(rib, &ip, depth);
 	RTE_TEST_ASSERT(node != NULL,
 		"Failed to lookup\n");
 
@@ -278,12 +276,12 @@ test_basic(void)
 	RTE_TEST_ASSERT((status == 0) && (next_hop_add == next_hop_return),
 		"Failed to get proper nexthop\n");
 
-	rte_rib6_remove(rib, ip, depth);
+	rte_rib6_remove(rib, &ip, depth);
 
-	node = rte_rib6_lookup(rib, ip);
+	node = rte_rib6_lookup(rib, &ip);
 	RTE_TEST_ASSERT(node == NULL,
 		"Lookup returns non existent rule\n");
-	node = rte_rib6_lookup_exact(rib, ip, depth);
+	node = rte_rib6_lookup_exact(rib, &ip, depth);
 	RTE_TEST_ASSERT(node == NULL,
 		"Lookup returns non existent rule\n");
 
@@ -299,12 +297,9 @@ test_tree_traversal(void)
 	struct rte_rib6_node *node;
 	struct rte_rib6_conf config;
 
-	uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE] = {10, 0, 2, 130, 0, 0, 0, 0,
-						0, 0, 0, 0, 0, 0, 0, 0};
-	uint8_t ip1[RTE_RIB6_IPV6_ADDR_SIZE] = {10, 0, 2, 0, 0, 0, 0, 0,
-						0, 0, 0, 0, 0, 0, 0, 0};
-	uint8_t ip2[RTE_RIB6_IPV6_ADDR_SIZE] = {10, 0, 2, 130, 0, 0, 0, 0,
-						0, 0, 0, 0, 0, 0, 0, 80};
+	struct rte_ipv6_addr ip = RTE_IPV6(0x0a00, 0x0282, 0, 0, 0, 0, 0, 0);
+	struct rte_ipv6_addr ip1 = RTE_IPV6(0x0a00, 0x0200, 0, 0, 0, 0, 0, 0);
+	struct rte_ipv6_addr ip2 = RTE_IPV6(0x0a00, 0x0282, 0, 0, 0, 0, 0, 0x0050);
 	uint8_t depth = 126;
 
 	config.max_nodes = MAX_RULES;
@@ -313,13 +308,13 @@ test_tree_traversal(void)
 	rib = rte_rib6_create(__func__, SOCKET_ID_ANY, &config);
 	RTE_TEST_ASSERT(rib != NULL, "Failed to create RIB\n");
 
-	node = rte_rib6_insert(rib, ip1, depth);
+	node = rte_rib6_insert(rib, &ip1, depth);
 	RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n");
-	node = rte_rib6_insert(rib, ip2, depth);
+	node = rte_rib6_insert(rib, &ip2, depth);
 	RTE_TEST_ASSERT(node != NULL, "Failed to insert rule\n");
 
 	node = NULL;
-	node = rte_rib6_get_nxt(rib, ip, 32, node, RTE_RIB6_GET_NXT_ALL);
+	node = rte_rib6_get_nxt(rib, &ip, 32, node, RTE_RIB6_GET_NXT_ALL);
 	RTE_TEST_ASSERT(node != NULL, "Failed to get rib_node\n");
 
 	rte_rib6_free(rib);
doc/guides/rel_notes/deprecation.rst +0 -7
index 582d54aece2f..735542d7a1e2 100644
@@ -80,13 +80,6 @@ Deprecation Notices
     - ``rte_node_ip6_route_add()``
   pipeline
     - ``struct rte_table_action_ipv6_header``
-  rib
-    - ``rte_rib6_lookup()``
-    - ``rte_rib6_lookup_exact()``
-    - ``rte_rib6_get_nxt()``
-    - ``rte_rib6_insert()``
-    - ``rte_rib6_remove()``
-    - ``rte_rib6_get_ip()``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +11 -0
index aada0df483c8..40045b32ef08 100644
@@ -304,6 +304,17 @@ API Changes
     - ``struct rte_ipv6_hdr``
   table
     - ``struct rte_table_lpm_ipv6_key``
+  rib
+    - ``rte_rib6_get_ip()``
+    - ``rte_rib6_get_nxt()``
+    - ``rte_rib6_insert()``
+    - ``rte_rib6_lookup()``
+    - ``rte_rib6_lookup_exact()``
+    - ``rte_rib6_remove()``
+    - ``RTE_RIB6_IPV6_ADDR_SIZE`` (deprecated, replace with ``RTE_IPV6_ADDR_SIZE``)
+    - ``get_msk_part()`` (deprecated)
+    - ``rte_rib6_copy_addr()`` (deprecated, replaced with direct structure assignments)
+    - ``rte_rib6_is_equal()`` (deprecated, replaced with ``rte_ipv6_addr_eq()``)
 
 
 ABI Changes
lib/fib/rte_fib6.c +4 -4
index ef334da67cc4..9c7d4fde433a 100644
@@ -58,7 +58,7 @@ dummy_lookup(void *fib_p, const struct rte_ipv6_addr *ips,
 	struct rte_rib6_node *node;
 
 	for (i = 0; i < n; i++) {
-		node = rte_rib6_lookup(fib->rib, ips[i].a);
+		node = rte_rib6_lookup(fib->rib, &ips[i]);
 		if (node != NULL)
 			rte_rib6_get_nh(node, &next_hops[i]);
 		else
@@ -74,19 +74,19 @@ dummy_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	if ((fib == NULL) || (depth > RTE_IPV6_MAX_DEPTH))
 		return -EINVAL;
 
-	node = rte_rib6_lookup_exact(fib->rib, ip->a, depth);
+	node = rte_rib6_lookup_exact(fib->rib, ip, depth);
 
 	switch (op) {
 	case RTE_FIB6_ADD:
 		if (node == NULL)
-			node = rte_rib6_insert(fib->rib, ip->a, depth);
+			node = rte_rib6_insert(fib->rib, ip, depth);
 		if (node == NULL)
 			return -rte_errno;
 		return rte_rib6_set_nh(node, next_hop);
 	case RTE_FIB6_DEL:
 		if (node == NULL)
 			return -ENOENT;
-		rte_rib6_remove(fib->rib, ip->a, depth);
+		rte_rib6_remove(fib->rib, ip, depth);
 		return 0;
 	}
 	return -EINVAL;
lib/fib/trie.c +8 -8
index 6bb46541feee..4893f6c63615 100644
@@ -468,13 +468,13 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 
 	ledge = *ip;
 	do {
-		tmp = rte_rib6_get_nxt(rib, ip->a, depth, tmp,
+		tmp = rte_rib6_get_nxt(rib, ip, depth, tmp,
 			RTE_RIB6_GET_NXT_COVER);
 		if (tmp != NULL) {
 			rte_rib6_get_depth(tmp, &tmp_depth);
 			if (tmp_depth == depth)
 				continue;
-			rte_rib6_get_ip(tmp, redge.a);
+			rte_rib6_get_ip(tmp, &redge);
 			if (rte_ipv6_addr_eq(&ledge, &redge)) {
 				get_nxt_net(&ledge, tmp_depth);
 				continue;
@@ -532,11 +532,11 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 	rte_ipv6_addr_mask(&ip_masked, depth);
 
 	if (depth > 24) {
-		tmp = rte_rib6_get_nxt(rib, ip_masked.a,
+		tmp = rte_rib6_get_nxt(rib, &ip_masked,
 			RTE_ALIGN_FLOOR(depth, 8), NULL,
 			RTE_RIB6_GET_NXT_COVER);
 		if (tmp == NULL) {
-			tmp = rte_rib6_lookup(rib, ip->a);
+			tmp = rte_rib6_lookup(rib, ip);
 			if (tmp != NULL) {
 				rte_rib6_get_depth(tmp, &tmp_depth);
 				parent_depth = RTE_MAX(tmp_depth, 24);
@@ -546,7 +546,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 			depth_diff = depth_diff >> 3;
 		}
 	}
-	node = rte_rib6_lookup_exact(rib, ip_masked.a, depth);
+	node = rte_rib6_lookup_exact(rib, &ip_masked, depth);
 	switch (op) {
 	case RTE_FIB6_ADD:
 		if (node != NULL) {
@@ -563,7 +563,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 				dp->number_tbl8s - depth_diff))
 			return -ENOSPC;
 
-		node = rte_rib6_insert(rib, ip_masked.a, depth);
+		node = rte_rib6_insert(rib, &ip_masked, depth);
 		if (node == NULL)
 			return -rte_errno;
 		rte_rib6_set_nh(node, next_hop);
@@ -575,7 +575,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 		}
 		ret = modify_dp(dp, rib, &ip_masked, depth, next_hop);
 		if (ret != 0) {
-			rte_rib6_remove(rib, ip_masked.a, depth);
+			rte_rib6_remove(rib, &ip_masked, depth);
 			return ret;
 		}
 
@@ -597,7 +597,7 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 
 		if (ret != 0)
 			return ret;
-		rte_rib6_remove(rib, ip->a, depth);
+		rte_rib6_remove(rib, ip, depth);
 
 		dp->rsvd_tbl8s -= depth_diff;
 		return 0;
lib/rib/meson.build +1 -1
index 7bacbb453592..e98f70848189 100644
@@ -4,4 +4,4 @@
 
 sources = files('rte_rib.c', 'rte_rib6.c')
 headers = files('rte_rib.h', 'rte_rib6.h')
-deps += ['mempool']
+deps += ['net', 'mempool']
lib/rib/rte_rib6.c +46 -66

299 lines not on this page · raw message

lib/rib/rte_rib6.h +18 -9
index 775286f965f2..a60756f798d8 100644
@@ -16,12 +16,13 @@
 
 #include <rte_memcpy.h>
 #include <rte_common.h>
+#include <rte_ip6.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define RTE_RIB6_IPV6_ADDR_SIZE	16
+#define RTE_RIB6_IPV6_ADDR_SIZE (RTE_DEPRECATED(RTE_RIB6_IPV6_ADDR_SIZE) RTE_IPV6_ADDR_SIZE)
 
 /**
  * rte_rib6_get_nxt() flags
@@ -56,12 +57,15 @@ struct rte_rib6_conf {
  * @param src
  *  pointer from where to copy
  */
+static inline void rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
+	__rte_deprecated_msg("use direct struct assignment");
+
 static inline void
 rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
 {
 	if ((dst == NULL) || (src == NULL))
 		return;
-	rte_memcpy(dst, src, RTE_RIB6_IPV6_ADDR_SIZE);
+	rte_memcpy(dst, src, RTE_IPV6_ADDR_SIZE);
 }
 
 /**
@@ -76,13 +80,16 @@ rte_rib6_copy_addr(uint8_t *dst, const uint8_t *src)
  *  1 if equal
  *  0 otherwise
  */
+static inline int rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2)
+	__rte_deprecated_msg("use rte_ipv6_addr_eq");
+
 static inline int
 rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
 	int i;
 
 	if ((ip1 == NULL) || (ip2 == NULL))
 		return 0;
-	for (i = 0; i < RTE_RIB6_IPV6_ADDR_SIZE; i++) {
+	for (i = 0; i < RTE_IPV6_ADDR_SIZE; i++) {
 		if (ip1[i] != ip2[i])
 			return 0;
 	}
@@ -100,6 +107,8 @@ rte_rib6_is_equal(const uint8_t *ip1, const uint8_t *ip2) {
  * @return
  *  8-bit chunk of the 128-bit IPv6 mask
  */
+static inline uint8_t get_msk_part(uint8_t depth, int byte) __rte_deprecated;
+
 static inline uint8_t
 get_msk_part(uint8_t depth, int byte) {
 	uint8_t part;
@@ -124,7 +133,7 @@ get_msk_part(uint8_t depth, int byte) {
  */
 struct rte_rib6_node *
 rte_rib6_lookup(struct rte_rib6 *rib,
-	const uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE]);
+	const struct rte_ipv6_addr *ip);
 
 /**
  * Lookup less specific route into the RIB structure
@@ -154,7 +163,7 @@ rte_rib6_lookup_parent(struct rte_rib6_node *ent);
  */
 struct rte_rib6_node *
 rte_rib6_lookup_exact(struct rte_rib6 *rib,
-	const uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE], uint8_t depth);
+	const struct rte_ipv6_addr *ip, uint8_t depth);
 
 /**
  * Retrieve next more specific prefix from the RIB
@@ -181,7 +190,7 @@ rte_rib6_lookup_exact(struct rte_rib6 *rib,
  */
 struct rte_rib6_node *
 rte_rib6_get_nxt(struct rte_rib6 *rib,
-	const uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE],
+	const struct rte_ipv6_addr *ip,
 	uint8_t depth, struct rte_rib6_node *last, int flag);
 
 /**
@@ -196,7 +205,7 @@ rte_rib6_get_nxt(struct rte_rib6 *rib,
  */
 void
 rte_rib6_remove(struct rte_rib6 *rib,
-	const uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE], uint8_t depth);
+	const struct rte_ipv6_addr *ip, uint8_t depth);
 
 /**
  * Insert prefix into the RIB
@@ -213,7 +222,7 @@ rte_rib6_remove(struct rte_rib6 *rib,
  */
 struct rte_rib6_node *
 rte_rib6_insert(struct rte_rib6 *rib,
-	const uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE], uint8_t depth);
+	const struct rte_ipv6_addr *ip, uint8_t depth);
 
 /**
  * Get an ip from rte_rib6_node
@@ -228,7 +237,7 @@ rte_rib6_insert(struct rte_rib6 *rib,
  */
 int
 rte_rib6_get_ip(const struct rte_rib6_node *node,
-		uint8_t ip[RTE_RIB6_IPV6_ADDR_SIZE]);
+		struct rte_ipv6_addr *ip);
 
 /**
  * Get a depth from rte_rib6_node
Signature · 1 line
2.47.0
#96 lore raw

PATCH v4 8/17 cmdline: use IPv6 address structure

In reply to Robin Jarry

The previous commits introduced a new rte_ipv6_addr structure without any alignment requirements. It is not compatible with the in6_addr POSIX type available in netinet/in.h.

The main issue is that in6_addr is not uniform on all platforms which causes unaligned access warnings when compiling without -Wno-address-of-packed-member (set in dpdk by default).

In order to have a consistent code base, replace in6_addr with rte_ipv6_addr in the cmdline library. Update all code accordingly.

---
 app/graph/ethdev.c                     |  4 +--
 app/graph/ip6_route.c                  |  6 ++--
 app/graph/neigh.c                      |  2 +-
 app/test-pmd/cmdline.c                 |  4 +--
 app/test-pmd/cmdline_flow.c            | 14 +++-----
 app/test-pmd/testpmd.h                 | 16 ++++-----
 app/test/test_cmdline_ipaddr.c         | 49 ++++----------------------
 doc/guides/rel_notes/release_24_11.rst |  2 ++
 examples/cmdline/commands.c            | 30 +++-------------
 lib/cmdline/cmdline_parse_ipaddr.h     |  3 +-
 10 files changed, 34 insertions(+), 96 deletions(-)
app/graph/ethdev.c +2 -2
index cfc1b1856910..13ed791412e1 100644
@@ -627,10 +627,10 @@ cmd_ethdev_dev_ip6_addr_add_parsed(void *parsed_result, __rte_unused struct cmdl
 	int rc = -EINVAL, i;
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.ip[i] = res->ip.addr.ipv6.s6_addr[i];
+		config.ip[i] = res->ip.addr.ipv6.a[i];
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.mask[i] = res->mask.addr.ipv6.s6_addr[i];
+		config.mask[i] = res->mask.addr.ipv6.a[i];
 
 	rc = ethdev_ip6_addr_add(res->dev, &config);
 	if (rc < 0)
app/graph/ip6_route.c +3 -3
index 834719ecaeb4..d91466cd78d6 100644
@@ -157,13 +157,13 @@ cmd_ipv6_lookup_route_add_ipv6_parsed(void *parsed_result, __rte_unused struct c
 	int rc = -EINVAL, i;
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.ip[i] = res->ip.addr.ipv6.s6_addr[i];
+		config.ip[i] = res->ip.addr.ipv6.a[i];
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.mask[i] = res->mask.addr.ipv6.s6_addr[i];
+		config.mask[i] = res->mask.addr.ipv6.a[i];
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.gateway[i] = res->via_ip.addr.ipv6.s6_addr[i];
+		config.gateway[i] = res->via_ip.addr.ipv6.a[i];
 
 	rc = route_ip6_add(&config);
 	if (rc)
app/graph/neigh.c +1 -1
index 79fd542c8948..eb7a09f1f145 100644
@@ -266,7 +266,7 @@ cmd_neigh_add_ipv6_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
 	uint64_t mac;
 
 	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		ip[i] = res->ip.addr.ipv6.s6_addr[i];
+		ip[i] = res->ip.addr.ipv6.a[i];
 
 	if (parser_mac_read(&mac, res->mac)) {
 		printf(MSG_ARG_INVALID, "mac");
app/test-pmd/cmdline.c +1 -3
index 76d906ee5a27..7e0666e9f634 100644
@@ -8977,9 +8977,7 @@ do { \
 #define IPV6_ADDR_TO_ARRAY(ip_addr, ip) \
 do { \
 	if ((ip_addr).family == AF_INET6) \
-		rte_memcpy(&(ip), \
-				 &((ip_addr).addr.ipv6), \
-				 sizeof(struct in6_addr)); \
+		ip = ip_addr.addr.ipv6; \
 	else { \
 		fprintf(stderr, "invalid parameter.\n"); \
 		return; \
app/test-pmd/cmdline_flow.c +5 -9
index 5f71e5ba4440..1e4f2ebc556f 100644
@@ -902,10 +902,8 @@ struct vxlan_encap_conf vxlan_encap_conf = {
 	.udp_dst = RTE_BE16(RTE_VXLAN_DEFAULT_PORT),
 	.ipv4_src = RTE_IPV4(127, 0, 0, 1),
 	.ipv4_dst = RTE_IPV4(255, 255, 255, 255),
-	.ipv6_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
-	.ipv6_dst = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11 },
+	.ipv6_src = RTE_IPV6_ADDR_LOOPBACK,
+	.ipv6_dst = RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0x1111),
 	.vlan_tci = 0,
 	.ip_tos = 0,
 	.ip_ttl = 255,
@@ -936,10 +934,8 @@ struct nvgre_encap_conf nvgre_encap_conf = {
 	.tni = { 0x00, 0x00, 0x00 },
 	.ipv4_src = RTE_IPV4(127, 0, 0, 1),
 	.ipv4_dst = RTE_IPV4(255, 255, 255, 255),
-	.ipv6_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
-	.ipv6_dst = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-		      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11 },
+	.ipv6_src = RTE_IPV6_ADDR_LOOPBACK,
+	.ipv6_dst = RTE_IPV6(0, 0, 0, 0, 0, 0, 0, 0x1111),
 	.vlan_tci = 0,
 	.eth_src = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
 	.eth_dst = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
@@ -11919,7 +11915,7 @@ parse_ipv6_addr(struct context *ctx, const struct token *token,
 {
 	const struct arg *arg = pop_args(ctx);
 	char str2[len + 1];
-	struct in6_addr tmp;
+	struct rte_ipv6_addr tmp;
 	int ret;
 
 	(void)token;
app/test-pmd/testpmd.h +8 -8
index 84517b0be78a..131ea53f84af 100644
@@ -712,8 +712,8 @@ struct vxlan_encap_conf {
 	rte_be16_t udp_dst;
 	rte_be32_t ipv4_src;
 	rte_be32_t ipv4_dst;
-	uint8_t ipv6_src[16];
-	uint8_t ipv6_dst[16];
+	struct rte_ipv6_addr ipv6_src;
+	struct rte_ipv6_addr ipv6_dst;
 	rte_be16_t vlan_tci;
 	uint8_t ip_tos;
 	uint8_t ip_ttl;
@@ -730,8 +730,8 @@ struct nvgre_encap_conf {
 	uint8_t tni[3];
 	rte_be32_t ipv4_src;
 	rte_be32_t ipv4_dst;
-	uint8_t ipv6_src[16];
-	uint8_t ipv6_dst[16];
+	struct rte_ipv6_addr ipv6_src;
+	struct rte_ipv6_addr ipv6_dst;
 	rte_be16_t vlan_tci;
 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
@@ -762,8 +762,8 @@ struct mplsogre_encap_conf {
 	uint8_t label[3];
 	rte_be32_t ipv4_src;
 	rte_be32_t ipv4_dst;
-	uint8_t ipv6_src[16];
-	uint8_t ipv6_dst[16];
+	struct rte_ipv6_addr ipv6_src;
+	struct rte_ipv6_addr ipv6_dst;
 	rte_be16_t vlan_tci;
 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
@@ -786,8 +786,8 @@ struct mplsoudp_encap_conf {
 	rte_be16_t udp_dst;
 	rte_be32_t ipv4_src;
 	rte_be32_t ipv4_dst;
-	uint8_t ipv6_src[16];
-	uint8_t ipv6_dst[16];
+	struct rte_ipv6_addr ipv6_src;
+	struct rte_ipv6_addr ipv6_dst;
 	rte_be16_t vlan_tci;
 	uint8_t eth_src[RTE_ETHER_ADDR_LEN];
 	uint8_t eth_dst[RTE_ETHER_ADDR_LEN];
app/test/test_cmdline_ipaddr.c +6 -43

87 lines not on this page · raw message

doc/guides/rel_notes/release_24_11.rst +2 -0
index 40045b32ef08..ae34f19df543 100644
@@ -289,6 +289,8 @@ API Changes
 * net: A new IPv6 address structure was introduced to replace ad-hoc ``uint8_t[16]`` arrays.
   The following libraries and symbols were modified:
 
+  cmdline
+    - ``cmdline_ipaddr_t``
   fib
     - ``rte_fib6_add()``
     - ``rte_fib6_delete()``
examples/cmdline/commands.c +4 -26
index aec151d08987..09a42a9917cb 100644
@@ -33,28 +33,6 @@ struct object_list global_obj_list;
 	(unsigned)((unsigned char *)&addr)[3]
 #endif
 
-#ifndef NIP6
-#define NIP6_FMT "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x"
-#define NIP6(addr)					\
-	(unsigned)((addr).s6_addr[0]),			\
-	(unsigned)((addr).s6_addr[1]),			\
-	(unsigned)((addr).s6_addr[2]),			\
-	(unsigned)((addr).s6_addr[3]),			\
-	(unsigned)((addr).s6_addr[4]),			\
-	(unsigned)((addr).s6_addr[5]),			\
-	(unsigned)((addr).s6_addr[6]),			\
-	(unsigned)((addr).s6_addr[7]),			\
-	(unsigned)((addr).s6_addr[8]),			\
-	(unsigned)((addr).s6_addr[9]),			\
-	(unsigned)((addr).s6_addr[10]),			\
-	(unsigned)((addr).s6_addr[11]),			\
-	(unsigned)((addr).s6_addr[12]),			\
-	(unsigned)((addr).s6_addr[13]),			\
-	(unsigned)((addr).s6_addr[14]),			\
-	(unsigned)((addr).s6_addr[15])
-#endif
-
-
 /**********************************************************/
 
 /* Show or delete tokens. 8< */
@@ -74,8 +52,8 @@ static void cmd_obj_del_show_parsed(void *parsed_result,
 		snprintf(ip_str, sizeof(ip_str), NIPQUAD_FMT,
 			 NIPQUAD(res->obj->ip.addr.ipv4));
 	else
-		snprintf(ip_str, sizeof(ip_str), NIP6_FMT,
-			 NIP6(res->obj->ip.addr.ipv6));
+		snprintf(ip_str, sizeof(ip_str), RTE_IPV6_ADDR_FMT,
+			 RTE_IPV6_ADDR_SPLIT(&res->obj->ip.addr.ipv6));
 
 	if (strcmp(res->action, "del") == 0) {
 		SLIST_REMOVE(&global_obj_list, res->obj, object, next);
@@ -145,8 +123,8 @@ static void cmd_obj_add_parsed(void *parsed_result,
 		snprintf(ip_str, sizeof(ip_str), NIPQUAD_FMT,
 			 NIPQUAD(o->ip.addr.ipv4));
 	else
-		snprintf(ip_str, sizeof(ip_str), NIP6_FMT,
-			 NIP6(o->ip.addr.ipv6));
+		snprintf(ip_str, sizeof(ip_str), RTE_IPV6_ADDR_FMT,
+			 RTE_IPV6_ADDR_SPLIT(&o->ip.addr.ipv6));
 
 	cmdline_printf(cl, "Object %s added, ip=%s\n",
 		       o->name, ip_str);
lib/cmdline/cmdline_parse_ipaddr.h +2 -1
index 0118c31d4484..8653de8237fc 100644
@@ -9,6 +9,7 @@
 
 #include <cmdline_parse.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -22,7 +23,7 @@ struct cmdline_ipaddr {
 	uint8_t family;
 	union {
 		struct in_addr ipv4;
-		struct in6_addr ipv6;
+		struct rte_ipv6_addr ipv6;
 	} addr;
 	unsigned int prefixlen; /* in case of network only */
 };
Signature · 1 line
2.47.0
#97 lore raw

PATCH v4 9/17 node: use IPv6 address structure and utils

In reply to Robin Jarry

Replace ad-hoc uint8_t[16] arrays with rte_ipv6_addr structures. Replace duplicated code with utils from rte_ip6.h.

---
 app/graph/ethdev.c                     | 44 +++++++---------------
 app/graph/ethdev.h                     |  9 ++---
 app/graph/ip6_route.c                  | 51 +++++++-------------------
 app/graph/meson.build                  |  2 +-
 app/graph/neigh.c                      | 21 ++++-------
 app/graph/neigh_priv.h                 |  4 +-
 app/graph/route.h                      |  8 ++--
 doc/guides/rel_notes/deprecation.rst   |  2 -
 doc/guides/rel_notes/release_24_11.rst |  2 +
 examples/l3fwd-graph/main.c            | 33 ++++++-----------
 lib/node/ip6_lookup.c                  |  9 ++---
 lib/node/rte_node_ip6_api.h            |  3 +-
 12 files changed, 66 insertions(+), 122 deletions(-)
app/graph/ethdev.c +14 -30
index 13ed791412e1..b890efecb52a 100644
@@ -124,30 +124,19 @@ ethdev_portid_by_ip4(uint32_t ip, uint32_t mask)
 }
 
 int16_t
-ethdev_portid_by_ip6(uint8_t *ip, uint8_t *mask)
+ethdev_portid_by_ip6(struct rte_ipv6_addr *ip, struct rte_ipv6_addr *mask)
 {
-	int portid = -EINVAL;
 	struct ethdev *port;
-	int j;
 
 	TAILQ_FOREACH(port, &eth_node, next) {
-		for (j = 0; j < ETHDEV_IPV6_ADDR_LEN; j++) {
-			if (mask == NULL) {
-				if ((port->ip6_addr.ip[j] & port->ip6_addr.mask[j]) !=
-				    (ip[j] & port->ip6_addr.mask[j]))
-					break;
-
-			} else {
-				if ((port->ip6_addr.ip[j] & port->ip6_addr.mask[j]) !=
-				    (ip[j] & mask[j]))
-					break;
-			}
-		}
-		if (j == ETHDEV_IPV6_ADDR_LEN)
+		uint8_t depth = rte_ipv6_mask_depth(&port->ip6_addr.mask);
+		if (mask != NULL)
+			depth = RTE_MAX(depth, rte_ipv6_mask_depth(mask));
+		if (rte_ipv6_addr_eq_prefix(&port->ip6_addr.ip, ip, depth))
 			return port->config.port_id;
 	}
 
-	return portid;
+	return -EINVAL;
 }
 
 void
@@ -285,7 +274,7 @@ ethdev_ip6_addr_add(const char *name, struct ipv6_addr_config *config)
 {
 	struct ethdev *eth_hdl;
 	uint16_t portid = 0;
-	int rc, i;
+	int rc;
 
 	rc = rte_eth_dev_get_port_by_name(name, &portid);
 	if (rc < 0)
@@ -294,10 +283,8 @@ ethdev_ip6_addr_add(const char *name, struct ipv6_addr_config *config)
 	eth_hdl = ethdev_port_by_id(portid);
 
 	if (eth_hdl) {
-		for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) {
-			eth_hdl->ip6_addr.ip[i] = config->ip[i];
-			eth_hdl->ip6_addr.mask[i] = config->mask[i];
-		}
+		eth_hdl->ip6_addr.ip = config->ip;
+		eth_hdl->ip6_addr.mask = config->mask;
 		return 0;
 	}
 	rc = -EINVAL;
@@ -623,14 +610,11 @@ cmd_ethdev_dev_ip6_addr_add_parsed(void *parsed_result, __rte_unused struct cmdl
 				   void *data __rte_unused)
 {
 	struct cmd_ethdev_dev_ip6_addr_add_result *res = parsed_result;
-	struct ipv6_addr_config config;
-	int rc = -EINVAL, i;
-
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.ip[i] = res->ip.addr.ipv6.a[i];
-
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		config.mask[i] = res->mask.addr.ipv6.a[i];
+	struct ipv6_addr_config config = {
+		.ip = res->ip.addr.ipv6,
+		.mask = res->mask.addr.ipv6,
+	};
+	int rc;
 
 	rc = ethdev_ip6_addr_add(res->dev, &config);
 	if (rc < 0)
app/graph/ethdev.h +4 -5
index d0de593fc743..046689ee5fc7 100644
@@ -6,8 +6,7 @@
 #define APP_GRAPH_ETHDEV_H
 
 #include <cmdline_parse.h>
-
-#define ETHDEV_IPV6_ADDR_LEN	16
+#include <rte_ip6.h>
 
 struct ipv4_addr_config {
 	uint32_t ip;
@@ -15,8 +14,8 @@ struct ipv4_addr_config {
 };
 
 struct ipv6_addr_config {
-	uint8_t ip[ETHDEV_IPV6_ADDR_LEN];
-	uint8_t mask[ETHDEV_IPV6_ADDR_LEN];
+	struct rte_ipv6_addr ip;
+	struct rte_ipv6_addr mask;
 };
 
 extern uint32_t enabled_port_mask;
@@ -25,7 +24,7 @@ void ethdev_start(void);
 void ethdev_stop(void);
 void *ethdev_mempool_list_by_portid(uint16_t portid);
 int16_t ethdev_portid_by_ip4(uint32_t ip, uint32_t mask);
-int16_t ethdev_portid_by_ip6(uint8_t *ip, uint8_t *mask);
+int16_t ethdev_portid_by_ip6(struct rte_ipv6_addr *ip, struct rte_ipv6_addr *mask);
 int16_t ethdev_txport_by_rxport_get(uint16_t portid_rx);
 void ethdev_list_clean(void);
 
app/graph/ip6_route.c +13 -38

92 lines not on this page · raw message

app/graph/meson.build +1 -1
index 6dc54d5ee63f..344e4a418fc0 100644
@@ -9,7 +9,7 @@ if not build
     subdir_done()
 endif
 
-deps += ['graph', 'eal', 'lpm', 'ethdev', 'node', 'cmdline']
+deps += ['graph', 'eal', 'lpm', 'ethdev', 'node', 'cmdline', 'net']
 sources = files(
         'cli.c',
         'conn.c',
app/graph/neigh.c +7 -14
index eb7a09f1f145..3298f63c1a84 100644
@@ -62,12 +62,12 @@ find_neigh4_entry(uint32_t ip, uint64_t mac)
 }
 
 static struct neigh_ipv6_config *
-find_neigh6_entry(uint8_t *ip, uint64_t mac)
+find_neigh6_entry(struct rte_ipv6_addr *ip, uint64_t mac)
 {
 	struct neigh_ipv6_config *v6_config;
 
 	TAILQ_FOREACH(v6_config, &neigh6, next) {
-		if (!(memcmp(v6_config->ip, ip, 16)) && (v6_config->mac == mac))
+		if (rte_ipv6_addr_eq(&v6_config->ip, ip) && v6_config->mac == mac)
 			return v6_config;
 	}
 	return NULL;
@@ -82,7 +82,7 @@ ip6_rewrite_node_add(struct neigh_ipv6_config *v6_config)
 	int16_t portid = 0;
 	int rc;
 
-	portid = ethdev_portid_by_ip6(v6_config->ip, NULL);
+	portid = ethdev_portid_by_ip6(&v6_config->ip, NULL);
 	if (portid < 0) {
 		printf("Invalid portid found to add neigh\n");
 		return -EINVAL;
@@ -170,11 +170,10 @@ neigh_ip4_add(uint32_t ip, uint64_t mac)
 }
 
 static int
-neigh_ip6_add(uint8_t *ip, uint64_t mac)
+neigh_ip6_add(struct rte_ipv6_addr *ip, uint64_t mac)
 {
 	struct neigh_ipv6_config *v6_config;
 	int rc = -EINVAL;
-	int j;
 
 	v6_config = find_neigh6_entry(ip, mac);
 
@@ -184,9 +183,7 @@ neigh_ip6_add(uint8_t *ip, uint64_t mac)
 			return -ENOMEM;
 	}
 
-	for (j = 0; j < ETHDEV_IPV6_ADDR_LEN; j++)
-		v6_config->ip[j] = ip[j];
-
+	v6_config->ip = *ip;
 	v6_config->mac = mac;
 	v6_config->is_used = true;
 
@@ -261,19 +258,15 @@ cmd_neigh_add_ipv6_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
 			  void *data __rte_unused)
 {
 	struct cmd_neigh_add_ipv6_result *res = parsed_result;
-	uint8_t ip[ETHDEV_IPV6_ADDR_LEN];
-	int rc = -EINVAL, i;
+	int rc = -EINVAL;
 	uint64_t mac;
 
-	for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++)
-		ip[i] = res->ip.addr.ipv6.a[i];
-
 	if (parser_mac_read(&mac, res->mac)) {
 		printf(MSG_ARG_INVALID, "mac");
 		return;
 	}
 
-	rc = neigh_ip6_add(ip, mac);
+	rc = neigh_ip6_add(&res->ip.addr.ipv6, mac);
 	if (rc < 0)
 		printf(MSG_CMD_FAIL, res->neigh);
 }
app/graph/neigh_priv.h +3 -1
index 1a7106c309bc..b2a7607e01bb 100644
@@ -5,6 +5,8 @@
 #ifndef APP_GRAPH_NEIGH_PRIV_H
 #define APP_GRAPH_NEIGH_PRIV_H
 
+#include <rte_ip6.h>
+
 #define MAX_NEIGH_ENTRIES 32
 
 struct neigh_ipv4_config {
@@ -18,7 +20,7 @@ TAILQ_HEAD(neigh4_head, neigh_ipv4_config);
 
 struct neigh_ipv6_config {
 	TAILQ_ENTRY(neigh_ipv6_config) next;
-	uint8_t ip[16];
+	struct rte_ipv6_addr ip;
 	uint64_t mac;
 	bool is_used;
 };
app/graph/route.h +5 -3
index 23a7951d2dad..455aab8634d4 100644
@@ -5,6 +5,8 @@
 #ifndef APP_GRAPH_ROUTE_H
 #define APP_GRAPH_ROUTE_H
 
+#include <rte_ip6.h>
+
 #define MAX_ROUTE_ENTRIES 32
 
 struct route_ipv4_config {
@@ -19,9 +21,9 @@ TAILQ_HEAD(ip4_route, route_ipv4_config);
 
 struct route_ipv6_config {
 	TAILQ_ENTRY(route_ipv6_config) next;
-	uint8_t ip[16];
-	uint8_t mask[16];
-	uint8_t gateway[16];
+	struct rte_ipv6_addr ip;
+	struct rte_ipv6_addr mask;
+	struct rte_ipv6_addr gateway;
 	bool is_used;
 };
 
doc/guides/rel_notes/deprecation.rst +0 -2
index 735542d7a1e2..14b7f151afc1 100644
@@ -76,8 +76,6 @@ Deprecation Notices
     - ``struct rte_ipv6_tuple``
   ipsec
     - ``struct rte_ipsec_sadv6_key``
-  node
-    - ``rte_node_ip6_route_add()``
   pipeline
     - ``struct rte_table_action_ipv6_header``
 
doc/guides/rel_notes/release_24_11.rst +2 -0
index ae34f19df543..59d9338a59f8 100644
@@ -304,6 +304,8 @@ API Changes
     - ``rte_lpm6_lookup_bulk_func()``
   net
     - ``struct rte_ipv6_hdr``
+  node
+    - ``rte_node_ip6_route_add()``
   table
     - ``struct rte_table_lpm_ipv6_key``
   rib
examples/l3fwd-graph/main.c +12 -21
index 9bda0ab633e1..7fabd5b8d5cd 100644
@@ -151,7 +151,7 @@ struct ipv4_l3fwd_lpm_route {
 };
 
 struct ipv6_l3fwd_lpm_route {
-	uint8_t ip[RTE_IPV6_ADDR_SIZE];
+	struct rte_ipv6_addr ip;
 	uint8_t depth;
 	uint8_t if_out;
 };
@@ -170,23 +170,16 @@ static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = {
 #define IPV6_L3FWD_LPM_NUM_ROUTES                                              \
 	(sizeof(ipv6_l3fwd_lpm_route_array) /                                  \
 	 sizeof(ipv6_l3fwd_lpm_route_array[0]))
+
 static struct ipv6_l3fwd_lpm_route ipv6_l3fwd_lpm_route_array[] = {
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00}, 48, 0},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x01}, 48, 1},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x02}, 48, 2},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x03}, 48, 3},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x04}, 48, 4},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x05}, 48, 5},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x06}, 48, 6},
-	{{0x20, 0x01, 0xdb, 0x08, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x02}, 48, 7},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 0), 48, 0},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 1), 48, 1},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 2), 48, 2},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 3), 48, 3},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 4), 48, 4},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 5), 48, 5},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 6), 48, 6},
+	{RTE_IPV6(0x2001, 0xdb08, 0x1234, 0, 0, 0, 0, 2), 48, 7},
 };
 
 static int
@@ -1361,7 +1354,6 @@ main(int argc, char **argv)
 	for (i = 0; i < IPV6_L3FWD_LPM_NUM_ROUTES; i++) {
 		char route_str[INET6_ADDRSTRLEN * 4];
 		char abuf[INET6_ADDRSTRLEN];
-		struct in6_addr in6;
 		uint32_t dst_port;
 
 		/* Skip unused ports */
@@ -1371,14 +1363,13 @@ main(int argc, char **argv)
 
 		dst_port = ipv6_l3fwd_lpm_route_array[i].if_out;
 
-		memcpy(in6.s6_addr, ipv6_l3fwd_lpm_route_array[i].ip, RTE_IPV6_ADDR_SIZE);
 		snprintf(route_str, sizeof(route_str), "%s / %d (%d)",
-			 inet_ntop(AF_INET6, &in6, abuf, sizeof(abuf)),
+			 inet_ntop(AF_INET6, &ipv6_l3fwd_lpm_route_array[i].ip, abuf, sizeof(abuf)),
 			 ipv6_l3fwd_lpm_route_array[i].depth,
 			 ipv6_l3fwd_lpm_route_array[i].if_out);
 
 		/* Use route index 'i' as next hop id */
-		ret = rte_node_ip6_route_add(ipv6_l3fwd_lpm_route_array[i].ip,
+		ret = rte_node_ip6_route_add(&ipv6_l3fwd_lpm_route_array[i].ip,
 			ipv6_l3fwd_lpm_route_array[i].depth, i,
 			RTE_NODE_IP6_LOOKUP_NEXT_REWRITE);
 
lib/node/ip6_lookup.c +3 -6
index faaea5085938..f378d2d0646d 100644
@@ -258,17 +258,15 @@ ip6_lookup_node_process_scalar(struct rte_graph *graph, struct rte_node *node,
 }
 
 int
-rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop,
+rte_node_ip6_route_add(const struct rte_ipv6_addr *ip, uint8_t depth, uint16_t next_hop,
 		       enum rte_node_ip6_lookup_next next_node)
 {
 	char abuf[INET6_ADDRSTRLEN];
-	struct in6_addr in6;
 	uint8_t socket;
 	uint32_t val;
 	int ret;
 
-	memcpy(in6.s6_addr, ip, RTE_IPV6_ADDR_SIZE);
-	inet_ntop(AF_INET6, &in6, abuf, sizeof(abuf));
+	inet_ntop(AF_INET6, ip, abuf, sizeof(abuf));
 	/* Embedded next node id into 24 bit next hop */
 	val = ((next_node << 16) | next_hop) & ((1ull << 24) - 1);
 	node_dbg("ip6_lookup", "LPM: Adding route %s / %d nh (0x%x)", abuf,
@@ -278,8 +276,7 @@ rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop,
 		if (!ip6_lookup_nm.lpm_tbl[socket])
 			continue;
 
-		ret = rte_lpm6_add(ip6_lookup_nm.lpm_tbl[socket],
-				   (const struct rte_ipv6_addr *)ip, depth, val);
+		ret = rte_lpm6_add(ip6_lookup_nm.lpm_tbl[socket], ip, depth, val);
 		if (ret < 0) {
 			node_err("ip6_lookup",
 				 "Unable to add entry %s / %d nh (%x) to LPM "
lib/node/rte_node_ip6_api.h +2 -1
index f467aac7b6db..2875bc981a47 100644
@@ -17,6 +17,7 @@
  */
 #include <rte_common.h>
 #include <rte_compat.h>
+#include <rte_ip6.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -48,7 +49,7 @@ enum rte_node_ip6_lookup_next {
  *   0 on success, negative otherwise.
  */
 __rte_experimental
-int rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop,
+int rte_node_ip6_route_add(const struct rte_ipv6_addr *ip, uint8_t depth, uint16_t next_hop,
 			   enum rte_node_ip6_lookup_next next_node);
 
 /**
Signature · 1 line
2.47.0
#98 lore raw

PATCH v4 10/17 pipeline: use IPv6 structures

In reply to Robin Jarry

Update rte_table_action_ipv6_header and rte_table_action_nat_params to use rte_ipv6_addr structures instead of uint8_t[16] arrays.

For consistency, also update rte_swx_ipsec_sa_encap_params to use rte_ipv6_addr instead of in6_addr.

---
 doc/guides/rel_notes/deprecation.rst   |  2 -
 doc/guides/rel_notes/release_24_11.rst |  4 ++
 examples/ip_pipeline/cli.c             | 61 +++++++++++---------------
 examples/ip_pipeline/parser.c          |  2 +-
 examples/ip_pipeline/parser.h          |  3 +-
 examples/ip_pipeline/pipeline.h        |  6 +--
 examples/ip_pipeline/thread.c          | 15 +++----
 lib/pipeline/rte_swx_ipsec.c           | 16 ++++---
 lib/pipeline/rte_swx_ipsec.h           |  5 ++-
 lib/pipeline/rte_table_action.c        | 36 ++++++---------
 lib/pipeline/rte_table_action.h        |  7 +--
 11 files changed, 72 insertions(+), 85 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -2
index 14b7f151afc1..c41124ee6e4a 100644
@@ -76,8 +76,6 @@ Deprecation Notices
     - ``struct rte_ipv6_tuple``
   ipsec
     - ``struct rte_ipsec_sadv6_key``
-  pipeline
-    - ``struct rte_table_action_ipv6_header``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +4 -0
index 59d9338a59f8..cd6c4cf25ecc 100644
@@ -306,6 +306,10 @@ API Changes
     - ``struct rte_ipv6_hdr``
   node
     - ``rte_node_ip6_route_add()``
+  pipeline
+    - ``struct rte_swx_ipsec_sa_encap_params``
+    - ``struct rte_table_action_ipv6_header``
+    - ``struct rte_table_action_nat_params``
   table
     - ``struct rte_table_lpm_ipv6_key``
   rib
examples/ip_pipeline/cli.c +26 -35

188 lines not on this page · raw message

examples/ip_pipeline/parser.c +1 -1
index 62fc52f9db78..dfca026be58b 100644
@@ -387,7 +387,7 @@ parse_ipv4_addr(const char *token, struct in_addr *ipv4)
 }
 
 int
-parse_ipv6_addr(const char *token, struct in6_addr *ipv6)
+parse_ipv6_addr(const char *token, struct rte_ipv6_addr *ipv6)
 {
 	if (strlen(token) >= INET6_ADDRSTRLEN)
 		return -EINVAL;
examples/ip_pipeline/parser.h +2 -1
index 32b5ff99764b..758e0032ddc8 100644
@@ -9,6 +9,7 @@
 #include <stdint.h>
 
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_ether.h>
 
 #define PARSE_DELIMITER				" \f\n\r\t\v"
@@ -39,7 +40,7 @@ int parser_read_uint8_hex(uint8_t *value, const char *p);
 int parse_hex_string(char *src, uint8_t *dst, uint32_t *size);
 
 int parse_ipv4_addr(const char *token, struct in_addr *ipv4);
-int parse_ipv6_addr(const char *token, struct in6_addr *ipv6);
+int parse_ipv6_addr(const char *token, struct rte_ipv6_addr *ipv6);
 int parse_mac_addr(const char *token, struct rte_ether_addr *addr);
 int parse_mpls_labels(char *string, uint32_t *labels, uint32_t *n_labels);
 
examples/ip_pipeline/pipeline.h +3 -3
index 22f04fd752ca..89696480fc01 100644
@@ -218,8 +218,8 @@ struct table_rule_match_acl {
 		} ipv4;
 
 		struct {
-			uint8_t sa[16];
-			uint8_t da[16];
+			struct rte_ipv6_addr sa;
+			struct rte_ipv6_addr da;
 		} ipv6;
 	};
 
@@ -255,7 +255,7 @@ struct table_rule_match_lpm {
 
 	union {
 		uint32_t ipv4;
-		uint8_t ipv6[16];
+		struct rte_ipv6_addr ipv6;
 	};
 
 	uint8_t depth;
examples/ip_pipeline/thread.c +5 -10
index 9d8082b73080..0a44bddd90fc 100644
@@ -2409,10 +2409,8 @@ match_convert(struct table_rule_match *mh,
 			}
 		else
 			if (add) {
-				uint32_t *sa32 =
-					(uint32_t *) mh->match.acl.ipv6.sa;
-				uint32_t *da32 =
-					(uint32_t *) mh->match.acl.ipv6.da;
+				uint32_t *sa32 = (uint32_t *)&mh->match.acl.ipv6.sa;
+				uint32_t *da32 = (uint32_t *)&mh->match.acl.ipv6.da;
 				uint32_t sa32_depth[4], da32_depth[4];
 				int status;
 
@@ -2480,10 +2478,8 @@ match_convert(struct table_rule_match *mh,
 				ml->acl_add.priority =
 					(int32_t) mh->match.acl.priority;
 			} else {
-				uint32_t *sa32 =
-					(uint32_t *) mh->match.acl.ipv6.sa;
-				uint32_t *da32 =
-					(uint32_t *) mh->match.acl.ipv6.da;
+				uint32_t *sa32 = (uint32_t *)&mh->match.acl.ipv6.sa;
+				uint32_t *da32 = (uint32_t *)&mh->match.acl.ipv6.da;
 				uint32_t sa32_depth[4], da32_depth[4];
 				int status;
 
@@ -2563,8 +2559,7 @@ match_convert(struct table_rule_match *mh,
 			ml->lpm_ipv4.ip = mh->match.lpm.ipv4;
 			ml->lpm_ipv4.depth = mh->match.lpm.depth;
 		} else {
-			memcpy(&ml->lpm_ipv6.ip,
-				mh->match.lpm.ipv6, sizeof(ml->lpm_ipv6.ip));
+			ml->lpm_ipv6.ip = mh->match.lpm.ipv6;
 			ml->lpm_ipv6.depth = mh->match.lpm.depth;
 		}
 
lib/pipeline/rte_swx_ipsec.c +10 -6
index 0ed0ecd134c8..6bc81145409b 100644
@@ -1320,14 +1320,14 @@ rte_swx_ipsec_sa_read(struct rte_swx_ipsec *ipsec __rte_unused,
 			CHECK(!strcmp(t[2], "srcaddr"), "Missing \"srcaddr\" keyword");
 
 			status = hex_string_parse(t[3],
-						  p->encap.tunnel.ipv6.src_addr.s6_addr,
+						  p->encap.tunnel.ipv6.src_addr.a,
 						  16);
 			CHECK(!status, "Tunnel IPv6 source address invalid format");
 
 			CHECK(!strcmp(t[4], "dstaddr"), "Missing \"dstaddr\" keyword");
 
 			status = hex_string_parse(t[5],
-						  p->encap.tunnel.ipv6.dst_addr.s6_addr,
+						  p->encap.tunnel.ipv6.dst_addr.a,
 						  16);
 			CHECK(!status, "Tunnel IPv6 destination address invalid format");
 
@@ -1386,11 +1386,11 @@ tunnel_ipv6_header_set(struct rte_ipv6_hdr *h, struct rte_swx_ipsec_sa_params *p
 		.payload_len = 0, /* Cannot be pre-computed. */
 		.proto = IPPROTO_ESP,
 		.hop_limits = 64,
+		.src_addr = p->encap.tunnel.ipv6.src_addr,
+		.dst_addr = p->encap.tunnel.ipv6.dst_addr,
 	};
 
 	memcpy(h, &ipv6_hdr, sizeof(ipv6_hdr));
-	memcpy(&h->src_addr, p->encap.tunnel.ipv6.src_addr.s6_addr, 16);
-	memcpy(&h->dst_addr, p->encap.tunnel.ipv6.dst_addr.s6_addr, 16);
 }
 
 /* IPsec library SA parameters. */
@@ -1579,8 +1579,12 @@ ipsec_xform_get(struct rte_swx_ipsec_sa_params *p,
 			ipsec_xform->tunnel.ipv4.df = 0;
 			ipsec_xform->tunnel.ipv4.ttl = 64;
 		} else {
-			ipsec_xform->tunnel.ipv6.src_addr = p->encap.tunnel.ipv6.src_addr;
-			ipsec_xform->tunnel.ipv6.dst_addr = p->encap.tunnel.ipv6.dst_addr;
+			memcpy(&ipsec_xform->tunnel.ipv6.src_addr,
+				&p->encap.tunnel.ipv6.src_addr,
+				sizeof(ipsec_xform->tunnel.ipv6.src_addr));
+			memcpy(&ipsec_xform->tunnel.ipv6.dst_addr,
+				&p->encap.tunnel.ipv6.dst_addr,
+				sizeof(ipsec_xform->tunnel.ipv6.dst_addr));
 			ipsec_xform->tunnel.ipv6.dscp = 0;
 			ipsec_xform->tunnel.ipv6.flabel = 0;
 			ipsec_xform->tunnel.ipv6.hlimit = 64;
lib/pipeline/rte_swx_ipsec.h +3 -2
index d2e5abef7d61..6cff18084f9c 100644
@@ -48,6 +48,7 @@
 
 #include <rte_compat.h>
 #include <rte_crypto_sym.h>
+#include <rte_ip6.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -248,10 +249,10 @@ struct rte_swx_ipsec_sa_encap_params {
 		/** IPv6 header. */
 		struct {
 			/** Source address. */
-			struct in6_addr src_addr;
+			struct rte_ipv6_addr src_addr;
 
 			/** Destination address. */
-			struct in6_addr dst_addr;
+			struct rte_ipv6_addr dst_addr;
 		} ipv6;
 	} tunnel;
 };
lib/pipeline/rte_table_action.c +14 -22
index c0be656536eb..a7e63b984643 100644
@@ -871,12 +871,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));
+			d->ipv6.src_addr = p->vxlan.ipv6.sa;
+			d->ipv6.dst_addr = p->vxlan.ipv6.da;
 
 			/* UDP */
 			d->udp.src_port = rte_htons(p->vxlan.udp.sp);
@@ -906,12 +902,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));
+			d->ipv6.src_addr = p->vxlan.ipv6.sa;
+			d->ipv6.dst_addr = p->vxlan.ipv6.da;
 
 			/* UDP */
 			d->udp.src_port = rte_htons(p->vxlan.udp.sp);
@@ -1210,7 +1202,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;
 
@@ -1257,7 +1249,7 @@ nat_apply(void *data,
 	} else {
 		struct nat_ipv6_data *d = data;
 
-		memcpy(d->addr, p->addr.ipv6, sizeof(d->addr));
+		d->addr = p->addr.ipv6;
 		d->port = rte_htons(p->port);
 	}
 
@@ -1437,11 +1429,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);
+			ip->src_addr = data->addr;
 			tcp->src_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1450,11 +1442,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);
+			ip->src_addr = data->addr;
 			udp->src_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
@@ -1465,11 +1457,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);
+			ip->dst_addr = data->addr;
 			tcp->dst_port = data->port;
 			tcp->cksum = tcp_cksum;
 		} else {
@@ -1478,11 +1470,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,
-				(uint16_t *)data->addr,
+				(uint16_t *)&data->addr,
 				udp->dst_port,
 				data->port);
 
-			rte_memcpy(&ip->dst_addr, data->addr, 16);
+			ip->dst_addr = data->addr;
 			udp->dst_port = data->port;
 			udp->dgram_cksum = udp_cksum;
 		}
lib/pipeline/rte_table_action.h +4 -3
index bab4bfd2e23c..47a7bdfc01cc 100644
@@ -56,6 +56,7 @@
 
 #include <rte_compat.h>
 #include <rte_ether.h>
+#include <rte_ip6.h>
 #include <rte_meter.h>
 #include <rte_table_hash.h>
 
@@ -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. */
Signature · 1 line
2.47.0
#99 lore raw

PATCH v4 11/17 ipsec: use IPv6 address structure

In reply to Robin Jarry

Update rte_ipsec_sadv6_key to use rte_ipv6_addr structures instead of uint8_t[16] arrays.

---
 app/test-sad/main.c                    |  24 ++--
 app/test/test_ipsec_sad.c              |  46 ++++----
 doc/guides/prog_guide/ipsec_lib.rst    |   4 +-
 doc/guides/rel_notes/deprecation.rst   |   2 -
 doc/guides/rel_notes/release_24_11.rst |   2 +
 examples/ipsec-secgw/flow.c            |  20 ++--
 examples/ipsec-secgw/ipsec.c           |  33 ++----
 examples/ipsec-secgw/ipsec.h           |   5 +-
 examples/ipsec-secgw/parser.c          |   2 +-
 examples/ipsec-secgw/parser.h          |   4 +-
 examples/ipsec-secgw/rt.c              |   4 +-
 examples/ipsec-secgw/sa.c              |  37 +++---
 examples/ipsec-secgw/sad.h             |  12 +-
 examples/ipsec-secgw/sp6.c             | 154 ++++++++++++++-----------
 lib/ipsec/rte_ipsec_sad.h              |   5 +-
 15 files changed, 171 insertions(+), 183 deletions(-)
app/test-sad/main.c +10 -14
index addfc0714521..54e3fa0c91e6 100644
@@ -248,8 +248,8 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 						(uint64_t)(edge + step));
 			if (config.ipv6) {
 				for (j = 0; j < 16; j++) {
-					tbl[i].tuple.v6.dip[j] = rte_rand();
-					tbl[i].tuple.v6.sip[j] = rte_rand();
+					tbl[i].tuple.v6.dip.a[j] = rte_rand();
+					tbl[i].tuple.v6.sip.a[j] = rte_rand();
 				}
 			} else {
 				tbl[i].tuple.v4.dip = rte_rand();
@@ -274,9 +274,9 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 					(uint64_t)(edge + step));
 				if (config.ipv6) {
 					for (j = 0; j < 16; j++) {
-						tbl[i].tuple.v6.dip[j] =
+						tbl[i].tuple.v6.dip.a[j] =
 								rte_rand();
-						tbl[i].tuple.v6.sip[j] =
+						tbl[i].tuple.v6.sip.a[j] =
 								rte_rand();
 					}
 				} else {
@@ -289,12 +289,8 @@ get_random_rules(struct rule *tbl, uint32_t nb_rules, int rule_tbl)
 					config.nb_rules].tuple.v4.spi;
 				if (config.ipv6) {
 					int r_idx = i % config.nb_rules;
-					memcpy(tbl[i].tuple.v6.dip,
-						rules_tbl[r_idx].tuple.v6.dip,
-						sizeof(tbl[i].tuple.v6.dip));
-					memcpy(tbl[i].tuple.v6.sip,
-						rules_tbl[r_idx].tuple.v6.sip,
-						sizeof(tbl[i].tuple.v6.sip));
+					tbl[i].tuple.v6.dip = rules_tbl[r_idx].tuple.v6.dip;
+					tbl[i].tuple.v6.sip = rules_tbl[r_idx].tuple.v6.sip;
 				} else {
 					tbl[i].tuple.v4.dip = rules_tbl[i %
 						config.nb_rules].tuple.v4.dip;
@@ -472,8 +468,8 @@ print_result(const union rte_ipsec_sad_key *key, void *res)
 	v4 = &key->v4;
 	v6 = &key->v6;
 	spi = (config.ipv6 == 0) ? v4->spi : v6->spi;
-	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)v6->dip;
-	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)v6->sip;
+	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)&v6->dip;
+	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)&v6->sip;
 
 	if (res == NULL) {
 		printf("TUPLE: ");
@@ -500,8 +496,8 @@ print_result(const union rte_ipsec_sad_key *key, void *res)
 	v4 = &rule->tuple.v4;
 	v6 = &rule->tuple.v6;
 	spi = (config.ipv6 == 0) ? v4->spi : v6->spi;
-	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)v6->dip;
-	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)v6->sip;
+	dip = (config.ipv6 == 0) ? &v4->dip : (const void *)&v6->dip;
+	sip = (config.ipv6 == 0) ? &v4->sip : (const void *)&v6->sip;
 	printf("\n\tpoints to RULE ID %zu ",
 		RTE_PTR_DIFF(res, rules_tbl)/sizeof(struct rule));
 	print_tuple(af, spi, dip, sip);
app/test/test_ipsec_sad.c +24 -22

82 lines not on this page · raw message

doc/guides/prog_guide/ipsec_lib.rst +2 -2
index 3fa0a70d1325..458a82828ce8 100644
@@ -275,8 +275,8 @@ and v6 is a tuple for IPv6:
 
     struct rte_ipsec_sadv6_key {
         uint32_t spi;
-        uint8_t dip[16];
-        uint8_t sip[16];
+        struct rte_ipv6_addr dip;
+        struct rte_ipv6_addr sip;
     };
 
 As an example, lookup related code could look like that:
doc/guides/rel_notes/deprecation.rst +0 -2
index c41124ee6e4a..d67d63d37275 100644
@@ -74,8 +74,6 @@ Deprecation Notices
     - ``struct tcp6_flow_key``
   hash
     - ``struct rte_ipv6_tuple``
-  ipsec
-    - ``struct rte_ipsec_sadv6_key``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +2 -0
index cd6c4cf25ecc..ca8b9441d430 100644
@@ -295,6 +295,8 @@ API Changes
     - ``rte_fib6_add()``
     - ``rte_fib6_delete()``
     - ``rte_fib6_lookup_bulk()``
+  ipsec
+    - ``struct rte_ipsec_sadv6_key``
   lpm
     - ``rte_lpm6_add()``
     - ``rte_lpm6_delete()``
examples/ipsec-secgw/flow.c +10 -10
index 3f7630f5fd53..70742387c6be 100644
@@ -88,10 +88,10 @@ ipv6_hdr_print(struct rte_ipv6_hdr *hdr)
 }
 
 static int
-ipv6_addr_cpy(uint8_t *spec, uint8_t *mask, char *token,
+ipv6_addr_cpy(struct rte_ipv6_addr *spec, struct rte_ipv6_addr *mask, char *token,
 	      struct parse_status *status)
 {
-	struct in6_addr ip;
+	struct rte_ipv6_addr ip;
 	uint32_t depth, i;
 
 	APP_CHECK(parse_ipv6_addr(token, &ip, &depth) == 0, status,
@@ -99,11 +99,11 @@ ipv6_addr_cpy(uint8_t *spec, uint8_t *mask, char *token,
 	if (status->status < 0)
 		return -1;
 
-	memcpy(mask, &rte_flow_item_ipv6_mask.hdr.src_addr, sizeof(ip));
-	memcpy(spec, ip.s6_addr, sizeof(struct in6_addr));
+	*mask = rte_flow_item_ipv6_mask.hdr.src_addr;
+	*spec = ip;
 
-	for (i = 0; i < depth && (i%8 <= sizeof(struct in6_addr)); i++)
-		mask[i/8] &= ~(1 << (7-i%8));
+	for (i = 0; i < depth && (i%8 <= sizeof(*mask)); i++)
+		mask->a[i/8] &= ~(1 << (7-i%8));
 
 	return 0;
 }
@@ -175,8 +175,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.src_addr.a,
-						  rule->ipv6.mask.hdr.src_addr.a,
+				if (ipv6_addr_cpy(&rule->ipv6.spec.hdr.src_addr,
+						  &rule->ipv6.mask.hdr.src_addr,
 						  tokens[ti], status))
 					return;
 			}
@@ -184,8 +184,8 @@ parse_flow_tokens(char **tokens, uint32_t n_tokens,
 				INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
 				if (status->status < 0)
 					return;
-				if (ipv6_addr_cpy(rule->ipv6.spec.hdr.dst_addr.a,
-						  rule->ipv6.mask.hdr.dst_addr.a,
+				if (ipv6_addr_cpy(&rule->ipv6.spec.hdr.dst_addr,
+						  &rule->ipv6.mask.hdr.dst_addr,
 						  tokens[ti], status))
 					return;
 			}
examples/ipsec-secgw/ipsec.c +10 -23
index ebde28639c12..3b1e2a710971 100644
@@ -41,12 +41,8 @@ set_ipsec_conf(struct ipsec_sa *sa, struct rte_security_ipsec_xform *ipsec)
 			tunnel->ipv6.hlimit = IPDEFTTL;
 			tunnel->ipv6.dscp = 0;
 			tunnel->ipv6.flabel = 0;
-
-			memcpy((uint8_t *)&tunnel->ipv6.src_addr,
-				(uint8_t *)&sa->src.ip.ip6.ip6_b, 16);
-
-			memcpy((uint8_t *)&tunnel->ipv6.dst_addr,
-				(uint8_t *)&sa->dst.ip.ip6.ip6_b, 16);
+			memcpy(&tunnel->ipv6.src_addr, &sa->src.ip.ip6, 16);
+			memcpy(&tunnel->ipv6.dst_addr, &sa->dst.ip.ip6, 16);
 		}
 		/* TODO support for Transport */
 	}
@@ -450,10 +446,8 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sess_conf.ipsec.tunnel.type =
 				RTE_SECURITY_IPSEC_TUNNEL_IPV6;
 
-			memcpy(sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr,
-				sa->src.ip.ip6.ip6_b, 16);
-			memcpy(sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr,
-				sa->dst.ip.ip6.ip6_b, 16);
+			memcpy(&sess_conf.ipsec.tunnel.ipv6.src_addr, &sa->src.ip.ip6, 16);
+			memcpy(&sess_conf.ipsec.tunnel.ipv6.dst_addr, &sa->dst.ip.ip6, 16);
 		}
 	} else if (IS_TUNNEL(sa->flags)) {
 		sess_conf.ipsec.mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL;
@@ -470,10 +464,8 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sess_conf.ipsec.tunnel.type =
 				RTE_SECURITY_IPSEC_TUNNEL_IPV6;
 
-			memcpy(sess_conf.ipsec.tunnel.ipv6.src_addr.s6_addr,
-				sa->src.ip.ip6.ip6_b, 16);
-			memcpy(sess_conf.ipsec.tunnel.ipv6.dst_addr.s6_addr,
-				sa->dst.ip.ip6.ip6_b, 16);
+			memcpy(&sess_conf.ipsec.tunnel.ipv6.src_addr, &sa->src.ip.ip6, 16);
+			memcpy(&sess_conf.ipsec.tunnel.ipv6.dst_addr, &sa->dst.ip.ip6, 16);
 		} else {
 			RTE_LOG(ERR, IPSEC, "invalid tunnel type\n");
 			return -1;
@@ -528,11 +520,8 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sa->pattern[1].mask = &rte_flow_item_ipv6_mask;
 			sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 			sa->pattern[1].spec = &sa->ipv6_spec;
-
-			memcpy(&sa->ipv6_spec.hdr.dst_addr,
-				sa->dst.ip.ip6.ip6_b, 16);
-			memcpy(&sa->ipv6_spec.hdr.src_addr,
-			       sa->src.ip.ip6.ip6_b, 16);
+			sa->ipv6_spec.hdr.dst_addr = sa->dst.ip.ip6;
+			sa->ipv6_spec.hdr.src_addr = sa->src.ip.ip6;
 		} else if (IS_IP4(sa->flags)) {
 			sa->pattern[1].mask = &rte_flow_item_ipv4_mask;
 			sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV4;
@@ -735,10 +724,8 @@ create_ipsec_esp_flow(struct ipsec_sa *sa)
 		sa->pattern[1].mask = &rte_flow_item_ipv6_mask;
 		sa->pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV6;
 		sa->pattern[1].spec = &sa->ipv6_spec;
-		memcpy(&sa->ipv6_spec.hdr.dst_addr,
-			sa->dst.ip.ip6.ip6_b, sizeof(sa->dst.ip.ip6.ip6_b));
-		memcpy(&sa->ipv6_spec.hdr.src_addr,
-			sa->src.ip.ip6.ip6_b, sizeof(sa->src.ip.ip6.ip6_b));
+		sa->ipv6_spec.hdr.dst_addr = sa->dst.ip.ip6;
+		sa->ipv6_spec.hdr.src_addr = sa->src.ip.ip6;
 		sa->pattern[2].type = RTE_FLOW_ITEM_TYPE_ESP;
 		sa->pattern[2].spec = &sa->esp_spec;
 		sa->pattern[2].mask = &rte_flow_item_esp_mask;
examples/ipsec-secgw/ipsec.h +1 -4
index 1fe6b97168db..f12f57e2d5c7 100644
@@ -65,10 +65,7 @@ typedef int32_t (*ipsec_xform_fn)(struct rte_mbuf *m, struct ipsec_sa *sa,
 struct ip_addr {
 	union {
 		uint32_t ip4;
-		union {
-			uint64_t ip6[2];
-			uint8_t ip6_b[16];
-		} ip6;
+		struct rte_ipv6_addr ip6;
 	} ip;
 };
 
examples/ipsec-secgw/parser.c +1 -1
index 2bd6df335b47..cb463c704f97 100644
@@ -75,7 +75,7 @@ parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask)
 }
 
 int
-parse_ipv6_addr(const char *token, struct in6_addr *ipv6, uint32_t *mask)
+parse_ipv6_addr(const char *token, struct rte_ipv6_addr *ipv6, uint32_t *mask)
 {
 	char ip_str[256] = {0};
 	char *pch;
examples/ipsec-secgw/parser.h +3 -1
index b5c5d0210f04..63f7844ed89f 100644
@@ -11,6 +11,8 @@
 #include <netinet/ip.h>
 #include <string.h>
 
+#include <rte_ip6.h>
+
 struct parse_status {
 	int status;
 	char parse_msg[256];
@@ -63,7 +65,7 @@ int
 parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask);
 
 int
-parse_ipv6_addr(const char *token, struct in6_addr *ipv6, uint32_t *mask);
+parse_ipv6_addr(const char *token, struct rte_ipv6_addr *ipv6, uint32_t *mask);
 
 int
 parse_range(const char *token, uint16_t *low, uint16_t *high);
examples/ipsec-secgw/rt.c +2 -2
index 059fc0c8f28c..132e200adb2a 100644
@@ -89,7 +89,7 @@ parse_rt_tokens(char **tokens, uint32_t n_tokens,
 					(uint32_t)ip.s_addr);
 				route_ipv4->depth = (uint8_t)depth;
 			} else {
-				struct in6_addr ip;
+				struct rte_ipv6_addr ip;
 				uint32_t depth;
 
 				APP_CHECK(parse_ipv6_addr(tokens[ti],
@@ -99,7 +99,7 @@ parse_rt_tokens(char **tokens, uint32_t n_tokens,
 					tokens[ti]);
 				if (status->status < 0)
 					return;
-				memcpy(&route_ipv6->ip, ip.s6_addr, 16);
+				route_ipv6->ip = ip;
 				route_ipv6->depth = (uint8_t)depth;
 			}
 		}
examples/ipsec-secgw/sa.c +13 -24
index 1a0afd2ed2e8..425bfbf590fc 100644
@@ -32,7 +32,7 @@
 
 #define IP4_FULL_MASK (sizeof(((struct ip_addr *)NULL)->ip.ip4) * CHAR_BIT)
 
-#define IP6_FULL_MASK (sizeof(((struct ip_addr *)NULL)->ip.ip6.ip6) * CHAR_BIT)
+#define IP6_FULL_MASK RTE_IPV6_MAX_DEPTH
 
 #define MBUF_NO_SEC_OFFLOAD(m) ((m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD) == 0)
 
@@ -661,7 +661,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 				rule->src.ip.ip4 = rte_bswap32(
 					(uint32_t)ip.s_addr);
 			} else if (IS_IP6_TUNNEL(rule->flags)) {
-				struct in6_addr ip;
+				struct rte_ipv6_addr ip;
 
 				APP_CHECK(parse_ipv6_addr(tokens[ti], &ip,
 					NULL) == 0, status,
@@ -670,8 +670,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 					tokens[ti]);
 				if (status->status < 0)
 					return;
-				memcpy(rule->src.ip.ip6.ip6_b,
-					ip.s6_addr, 16);
+
+				rule->src.ip.ip6 = ip;
 			} else if (IS_TRANSPORT(rule->flags)) {
 				APP_CHECK(0, status, "unrecognized input "
 					"\"%s\"", tokens[ti]);
@@ -704,7 +704,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 				rule->dst.ip.ip4 = rte_bswap32(
 					(uint32_t)ip.s_addr);
 			} else if (IS_IP6_TUNNEL(rule->flags)) {
-				struct in6_addr ip;
+				struct rte_ipv6_addr ip;
 
 				APP_CHECK(parse_ipv6_addr(tokens[ti], &ip,
 					NULL) == 0, status,
@@ -713,7 +713,8 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 					tokens[ti]);
 				if (status->status < 0)
 					return;
-				memcpy(rule->dst.ip.ip6.ip6_b, ip.s6_addr, 16);
+
+				rule->dst.ip.ip6 = ip;
 			} else if (IS_TRANSPORT(rule->flags)) {
 				APP_CHECK(0, status, "unrecognized "
 					"input \"%s\"",	tokens[ti]);
@@ -1010,19 +1011,9 @@ print_one_sa_rule(const struct ipsec_sa *sa, int inbound)
 		break;
 	case IP6_TUNNEL:
 		printf("IP6Tunnel ");
-		for (i = 0; i < 16; i++) {
-			if (i % 2 && i != 15)
-				printf("%.2x:", sa->src.ip.ip6.ip6_b[i]);
-			else
-				printf("%.2x", sa->src.ip.ip6.ip6_b[i]);
-		}
+		printf(RTE_IPV6_ADDR_FMT, RTE_IPV6_ADDR_SPLIT(&sa->src.ip.ip6));
 		printf(" ");
-		for (i = 0; i < 16; i++) {
-			if (i % 2 && i != 15)
-				printf("%.2x:", sa->dst.ip.ip6.ip6_b[i]);
-			else
-				printf("%.2x", sa->dst.ip.ip6.ip6_b[i]);
-		}
+		printf(RTE_IPV6_ADDR_FMT, RTE_IPV6_ADDR_SPLIT(&sa->dst.ip.ip6));
 		break;
 	case TRANSPORT:
 		printf("Transport ");
@@ -1220,10 +1211,8 @@ sa_add_address_inline_crypto(struct ipsec_sa *sa)
 		sa->flags |= IP6_TRANSPORT;
 		if (mask[0] == IP6_FULL_MASK &&
 				mask[1] == IP6_FULL_MASK &&
-				(ip_addr[0].ip.ip6.ip6[0] != 0 ||
-				ip_addr[0].ip.ip6.ip6[1] != 0) &&
-				(ip_addr[1].ip.ip6.ip6[0] != 0 ||
-				ip_addr[1].ip.ip6.ip6[1] != 0)) {
+				!rte_ipv6_addr_is_unspec(&ip_addr[0].ip.ip6) &&
+				!rte_ipv6_addr_is_unspec(&ip_addr[1].ip.ip6)) {
 
 			sa->src.ip.ip6 = ip_addr[0].ip.ip6;
 			sa->dst.ip.ip6 = ip_addr[1].ip.ip6;
@@ -1571,8 +1560,8 @@ ipsec_sa_init(struct ipsec_sa *lsa, struct rte_ipsec_sa *sa, uint32_t sa_size,
 	};
 
 	if (IS_IP6_TUNNEL(lsa->flags)) {
-		memcpy(&v6.src_addr, lsa->src.ip.ip6.ip6_b, sizeof(v6.src_addr));
-		memcpy(&v6.dst_addr, lsa->dst.ip.ip6.ip6_b, sizeof(v6.dst_addr));
+		v6.src_addr = lsa->src.ip.ip6;
+		v6.dst_addr = lsa->dst.ip.ip6;
 	}
 
 	rc = fill_ipsec_sa_prm(&prm, lsa, &v4, &v6);
examples/ipsec-secgw/sad.h +6 -6
index fdb1d2ef1790..d8f3a91e7aa8 100644
@@ -9,6 +9,8 @@
 #include <rte_ip6.h>
 #include <rte_ipsec_sad.h>
 
+#include "ipsec.h"
+
 #define SA_CACHE_SZ	128
 #define SPI2IDX(spi, mask)	((spi) & (mask))
 
@@ -39,8 +41,8 @@ cmp_sa_key(struct ipsec_sa *sa, int is_v4, struct rte_ipv4_hdr *ipv4,
 			(sa->dst.ip.ip4 == ipv4->dst_addr)) ||
 			/* IPv6 check */
 			(!is_v4 && (sa_type == IP6_TUNNEL) &&
-			(!memcmp(sa->src.ip.ip6.ip6, &ipv6->src_addr, 16)) &&
-			(!memcmp(sa->dst.ip.ip6.ip6, &ipv6->dst_addr, 16))))
+			(rte_ipv6_addr_eq(&sa->src.ip.ip6, &ipv6->src_addr)) &&
+			(rte_ipv6_addr_eq(&sa->dst.ip.ip6, &ipv6->dst_addr))))
 		return 1;
 
 	return 0;
@@ -130,10 +132,8 @@ sad_lookup(struct ipsec_sad *sad, struct rte_mbuf *pkts[],
 				}
 			}
 			v6[nb_v6].spi = esp->spi;
-			memcpy(v6[nb_v6].dip, &ipv6->dst_addr,
-					sizeof(ipv6->dst_addr));
-			memcpy(v6[nb_v6].sip, &ipv6->src_addr,
-					sizeof(ipv6->src_addr));
+			v6[nb_v6].dip = ipv6->dst_addr;
+			v6[nb_v6].sip = ipv6->src_addr;
 			keys_v6[nb_v6] = (const union rte_ipsec_sad_key *)
 						&v6[nb_v6];
 			v6_idxes[nb_v6++] = i;
examples/ipsec-secgw/sp6.c +84 -70

226 lines not on this page · raw message

lib/ipsec/rte_ipsec_sad.h +3 -2
index 0adf89d9310c..c7fb4744304e 100644
@@ -8,6 +8,7 @@
 
 #include <stdint.h>
 
+#include <rte_ip6.h>
 
 /**
  * @file rte_ipsec_sad.h
@@ -38,8 +39,8 @@ struct rte_ipsec_sadv4_key {
 
 struct rte_ipsec_sadv6_key {
 	uint32_t spi;
-	uint8_t dip[16];
-	uint8_t sip[16];
+	struct rte_ipv6_addr dip;
+	struct rte_ipv6_addr sip;
 };
 
 union rte_ipsec_sad_key {
Signature · 1 line
2.47.0
#100 lore raw

PATCH v4 12/17 security: use IPv6 address structure

In reply to Robin Jarry

For consistency with the rest of the code base, update rte_security_ipsec_tunnel_param to use rte_ipv6_addr structures instead of in6_addr.

---
 doc/guides/rel_notes/release_24_11.rst |  2 ++
 drivers/common/cnxk/cnxk_security.c    | 14 ++++++--------
 drivers/net/iavf/iavf_ipsec_crypto.c   |  3 +--
 drivers/net/nfp/nfp_ipsec.c            |  4 ++--
 examples/ipsec-secgw/ipsec.c           | 12 ++++++------
 lib/pipeline/rte_swx_ipsec.c           |  8 ++------
 lib/security/rte_security.h            |  5 +++--
 7 files changed, 22 insertions(+), 26 deletions(-)
doc/guides/rel_notes/release_24_11.rst +2 -0
index ca8b9441d430..05212a4cc2b3 100644
@@ -312,6 +312,8 @@ API Changes
     - ``struct rte_swx_ipsec_sa_encap_params``
     - ``struct rte_table_action_ipv6_header``
     - ``struct rte_table_action_nat_params``
+  security
+    - ``struct rte_security_ipsec_tunnel_param``
   table
     - ``struct rte_table_lpm_ipv6_key``
   rib
drivers/common/cnxk/cnxk_security.c +6 -8
index e67c3f233187..c2871ad2bda5 100644
@@ -271,9 +271,9 @@ ot_ipsec_inb_tunnel_hdr_fill(struct roc_ot_ipsec_inb_sa *sa,
 	case RTE_SECURITY_IPSEC_TUNNEL_IPV6:
 		sa->w2.s.outer_ip_ver = ROC_IE_SA_IP_VERSION_6;
 		memcpy(&sa->outer_hdr.ipv6.src_addr, &tunnel->ipv6.src_addr,
-		       sizeof(struct in6_addr));
+		       sizeof(sa->outer_hdr.ipv6.src_addr));
 		memcpy(&sa->outer_hdr.ipv6.dst_addr, &tunnel->ipv6.dst_addr,
-		       sizeof(struct in6_addr));
+		       sizeof(sa->outer_hdr.ipv6.dst_addr));
 
 		/* IP Source and Dest are in LE/CPU endian */
 		ot_ipsec_update_ipv6_addr_endianness((uint64_t *)&sa->outer_hdr.ipv6.src_addr);
@@ -472,9 +472,9 @@ cnxk_ot_ipsec_outb_sa_fill(struct roc_ot_ipsec_outb_sa *sa,
 	case RTE_SECURITY_IPSEC_TUNNEL_IPV6:
 		sa->w2.s.outer_ip_ver = ROC_IE_SA_IP_VERSION_6;
 		memcpy(&sa->outer_hdr.ipv6.src_addr, &tunnel->ipv6.src_addr,
-		       sizeof(struct in6_addr));
+		       sizeof(sa->outer_hdr.ipv6.src_addr));
 		memcpy(&sa->outer_hdr.ipv6.dst_addr, &tunnel->ipv6.dst_addr,
-		       sizeof(struct in6_addr));
+		       sizeof(sa->outer_hdr.ipv6.dst_addr));
 
 		/* IP Source and Dest are in LE/CPU endian */
 		ot_ipsec_update_ipv6_addr_endianness((uint64_t *)&sa->outer_hdr.ipv6.src_addr);
@@ -1087,10 +1087,8 @@ cnxk_on_ipsec_outb_sa_create(struct rte_security_ipsec_xform *ipsec,
 			ip6->hop_limits = ipsec->tunnel.ipv6.hlimit ?
 						  ipsec->tunnel.ipv6.hlimit :
 						  0x40;
-			memcpy(&ip6->src_addr, &ipsec->tunnel.ipv6.src_addr,
-			       sizeof(struct in6_addr));
-			memcpy(&ip6->dst_addr, &ipsec->tunnel.ipv6.dst_addr,
-			       sizeof(struct in6_addr));
+			ip6->src_addr = ipsec->tunnel.ipv6.src_addr;
+			ip6->dst_addr = ipsec->tunnel.ipv6.dst_addr;
 		}
 	} else
 		ctx_len += sizeof(template->ip4);
drivers/net/iavf/iavf_ipsec_crypto.c +1 -2
index 89dd5af5500f..90421a66c309 100644
@@ -510,8 +510,7 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,
 		*((uint32_t *)sa_cfg->dst_addr)	=
 			htonl(conf->ipsec.tunnel.ipv4.dst_ip.s_addr);
 	} else {
-		uint32_t *v6_dst_addr =
-			(uint32_t *)conf->ipsec.tunnel.ipv6.dst_addr.s6_addr;
+		uint32_t *v6_dst_addr = (uint32_t *)&conf->ipsec.tunnel.ipv6.dst_addr;
 
 		sa_cfg->virtchnl_ip_type = VIRTCHNL_IPV6;
 
drivers/net/nfp/nfp_ipsec.c +2 -2
index 89116af1b22f..13f2b850e59d 100644
@@ -1042,8 +1042,8 @@ nfp_ipsec_msg_build(struct rte_eth_dev *eth_dev,
 			cfg->dst_ip[0] = rte_be_to_cpu_32(dst_ip[0]);
 			cfg->ipv6 = 0;
 		} else if (type == RTE_SECURITY_IPSEC_TUNNEL_IPV6) {
-			src_ip = (rte_be32_t *)conf->ipsec.tunnel.ipv6.src_addr.s6_addr;
-			dst_ip = (rte_be32_t *)conf->ipsec.tunnel.ipv6.dst_addr.s6_addr;
+			src_ip = (rte_be32_t *)&conf->ipsec.tunnel.ipv6.src_addr;
+			dst_ip = (rte_be32_t *)&conf->ipsec.tunnel.ipv6.dst_addr;
 			for (i = 0; i < 4; i++) {
 				cfg->src_ip[i] = rte_be_to_cpu_32(src_ip[i]);
 				cfg->dst_ip[i] = rte_be_to_cpu_32(dst_ip[i]);
examples/ipsec-secgw/ipsec.c +6 -6
index 3b1e2a710971..c65efd1c166a 100644
@@ -41,8 +41,8 @@ set_ipsec_conf(struct ipsec_sa *sa, struct rte_security_ipsec_xform *ipsec)
 			tunnel->ipv6.hlimit = IPDEFTTL;
 			tunnel->ipv6.dscp = 0;
 			tunnel->ipv6.flabel = 0;
-			memcpy(&tunnel->ipv6.src_addr, &sa->src.ip.ip6, 16);
-			memcpy(&tunnel->ipv6.dst_addr, &sa->dst.ip.ip6, 16);
+			tunnel->ipv6.src_addr = sa->src.ip.ip6;
+			tunnel->ipv6.dst_addr = sa->dst.ip.ip6;
 		}
 		/* TODO support for Transport */
 	}
@@ -446,8 +446,8 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sess_conf.ipsec.tunnel.type =
 				RTE_SECURITY_IPSEC_TUNNEL_IPV6;
 
-			memcpy(&sess_conf.ipsec.tunnel.ipv6.src_addr, &sa->src.ip.ip6, 16);
-			memcpy(&sess_conf.ipsec.tunnel.ipv6.dst_addr, &sa->dst.ip.ip6, 16);
+			sess_conf.ipsec.tunnel.ipv6.src_addr = sa->src.ip.ip6;
+			sess_conf.ipsec.tunnel.ipv6.dst_addr = sa->dst.ip.ip6;
 		}
 	} else if (IS_TUNNEL(sa->flags)) {
 		sess_conf.ipsec.mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL;
@@ -464,8 +464,8 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,
 			sess_conf.ipsec.tunnel.type =
 				RTE_SECURITY_IPSEC_TUNNEL_IPV6;
 
-			memcpy(&sess_conf.ipsec.tunnel.ipv6.src_addr, &sa->src.ip.ip6, 16);
-			memcpy(&sess_conf.ipsec.tunnel.ipv6.dst_addr, &sa->dst.ip.ip6, 16);
+			sess_conf.ipsec.tunnel.ipv6.src_addr = sa->src.ip.ip6;
+			sess_conf.ipsec.tunnel.ipv6.dst_addr = sa->dst.ip.ip6;
 		} else {
 			RTE_LOG(ERR, IPSEC, "invalid tunnel type\n");
 			return -1;
lib/pipeline/rte_swx_ipsec.c +2 -6
index 6bc81145409b..17a9d2b98bc0 100644
@@ -1579,12 +1579,8 @@ ipsec_xform_get(struct rte_swx_ipsec_sa_params *p,
 			ipsec_xform->tunnel.ipv4.df = 0;
 			ipsec_xform->tunnel.ipv4.ttl = 64;
 		} else {
-			memcpy(&ipsec_xform->tunnel.ipv6.src_addr,
-				&p->encap.tunnel.ipv6.src_addr,
-				sizeof(ipsec_xform->tunnel.ipv6.src_addr));
-			memcpy(&ipsec_xform->tunnel.ipv6.dst_addr,
-				&p->encap.tunnel.ipv6.dst_addr,
-				sizeof(ipsec_xform->tunnel.ipv6.dst_addr));
+			ipsec_xform->tunnel.ipv6.src_addr = p->encap.tunnel.ipv6.src_addr;
+			ipsec_xform->tunnel.ipv6.dst_addr = p->encap.tunnel.ipv6.dst_addr;
 			ipsec_xform->tunnel.ipv6.dscp = 0;
 			ipsec_xform->tunnel.ipv6.flabel = 0;
 			ipsec_xform->tunnel.ipv6.hlimit = 64;
lib/security/rte_security.h +3 -2
index 7a9bafa0fa72..032bf9c5fbfa 100644
@@ -18,6 +18,7 @@
 #include <rte_common.h>
 #include <rte_crypto.h>
 #include <rte_ip.h>
+#include <rte_ip6.h>
 #include <rte_mbuf_dyn.h>
 
 #ifdef __cplusplus
@@ -85,9 +86,9 @@ struct rte_security_ipsec_tunnel_param {
 		} ipv4;
 		/**< IPv4 header parameters */
 		struct {
-			struct in6_addr src_addr;
+			struct rte_ipv6_addr src_addr;
 			/**< IPv6 source address */
-			struct in6_addr dst_addr;
+			struct rte_ipv6_addr dst_addr;
 			/**< IPv6 destination address */
 			uint8_t dscp;
 			/**< IPv6 Differentiated Services Code Point */
Signature · 1 line
2.47.0
#101 lore raw

PATCH v4 13/17 hash: use IPv6 address structure

In reply to Robin Jarry

Update rte_ipv6_tuple to use rte_ipv6_addr structures instead of uint8_t[16] arrays.

---
 app/test/test_thash.c                  | 46 ++++++++++----------------
 doc/guides/rel_notes/deprecation.rst   |  2 --
 doc/guides/rel_notes/release_24_11.rst |  2 ++
 lib/hash/rte_thash.h                   | 20 +++++------
 4 files changed, 29 insertions(+), 41 deletions(-)
app/test/test_thash.c +17 -29
index 952da6a52954..0ad6943cf839 100644
@@ -25,8 +25,8 @@ struct test_thash_v4 {
 };
 
 struct test_thash_v6 {
-	uint8_t		dst_ip[16];
-	uint8_t		src_ip[16];
+	struct rte_ipv6_addr dst_ip;
+	struct rte_ipv6_addr src_ip;
 	uint16_t	dst_port;
 	uint16_t	src_port;
 	uint32_t	hash_l3;
@@ -49,25 +49,19 @@ struct test_thash_v4 v4_tbl[] = {
 
 struct test_thash_v6 v6_tbl[] = {
 /*3ffe:2501:200:3::1*/
-{{0x3f, 0xfe, 0x25, 0x01, 0x02, 0x00, 0x00, 0x03,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,},
+{RTE_IPV6(0x3ffe, 0x2501, 0x0200, 0x0003, 0, 0, 0, 0x0001),
 /*3ffe:2501:200:1fff::7*/
-{0x3f, 0xfe, 0x25, 0x01, 0x02, 0x00, 0x1f, 0xff,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07,},
+RTE_IPV6(0x3ffe, 0x2501, 0x0200, 0x1fff, 0, 0, 0, 0x0007),
 1766, 2794, 0x2cc18cd5, 0x40207d3d},
 /*ff02::1*/
-{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,},
+{RTE_IPV6(0xff02, 0, 0, 0, 0, 0, 0, 0x0001),
 /*3ffe:501:8::260:97ff:fe40:efab*/
-{0x3f, 0xfe, 0x05, 0x01, 0x00, 0x08, 0x00, 0x00,
-0x02, 0x60, 0x97, 0xff, 0xfe, 0x40, 0xef, 0xab,},
+RTE_IPV6(0x3ffe, 0x0501, 0x0008, 0, 0x0260, 0x97ff, 0xfe40, 0xefab),
 4739, 14230, 0x0f0c461c, 0xdde51bbf},
 /*fe80::200:f8ff:fe21:67cf*/
-{{0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x02, 0x00, 0xf8, 0xff, 0xfe, 0x21, 0x67, 0xcf,},
+{RTE_IPV6(0xfe80, 0, 0, 0, 0x0200, 0xf8ff, 0xfe21, 0x67cf),
 /*3ffe:1900:4545:3:200:f8ff:fe21:67cf*/
-{0x3f, 0xfe, 0x19, 0x00, 0x45, 0x45, 0x00, 0x03,
-0x02, 0x00, 0xf8, 0xff, 0xfe, 0x21, 0x67, 0xcf,},
+RTE_IPV6(0x3ffe, 0x1900, 0x4545, 0x0003, 0x0200, 0xf8ff, 0xfe21, 0x67cf),
 38024, 44251, 0x4b61e985, 0x02d1feef},
 };
 
@@ -110,7 +104,7 @@ static const uint8_t big_rss_key[] = {
 static int
 test_toeplitz_hash_calc(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple;
 	uint32_t rss_l3, rss_l3l4;
 	uint8_t rss_key_be[RTE_DIM(default_rss_key)];
@@ -145,10 +139,8 @@ test_toeplitz_hash_calc(void)
 	}
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
 		/*Fill ipv6 hdr*/
-		for (j = 0; j < RTE_DIM(ipv6_hdr.src_addr.a); j++)
-			ipv6_hdr.src_addr.a[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(ipv6_hdr.dst_addr.a); j++)
-			ipv6_hdr.dst_addr.a[j] = v6_tbl[i].dst_ip[j];
+		ipv6_hdr.src_addr = v6_tbl[i].src_ip;
+		ipv6_hdr.dst_addr = v6_tbl[i].dst_ip;
 		/*Load and convert ipv6 address into tuple*/
 		rte_thash_load_v6_addrs(&ipv6_hdr, &tuple);
 		tuple.v6.sport = v6_tbl[i].src_port;
@@ -176,7 +168,7 @@ test_toeplitz_hash_calc(void)
 static int
 test_toeplitz_hash_gfni(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple;
 	uint32_t rss_l3, rss_l3l4;
 	uint64_t rss_key_matrixes[RTE_DIM(default_rss_key)];
@@ -204,10 +196,8 @@ test_toeplitz_hash_gfni(void)
 	}
 
 	for (i = 0; i < RTE_DIM(v6_tbl); i++) {
-		for (j = 0; j < RTE_DIM(tuple.v6.src_addr); j++)
-			tuple.v6.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(tuple.v6.dst_addr); j++)
-			tuple.v6.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		tuple.v6.src_addr = v6_tbl[i].src_ip;
+		tuple.v6.dst_addr = v6_tbl[i].dst_ip;
 		tuple.v6.sport = rte_cpu_to_be_16(v6_tbl[i].dst_port);
 		tuple.v6.dport = rte_cpu_to_be_16(v6_tbl[i].src_port);
 		rss_l3 = rte_thash_gfni(rss_key_matrixes, (uint8_t *)&tuple,
@@ -299,7 +289,7 @@ enum {
 static int
 test_toeplitz_hash_gfni_bulk(void)
 {
-	uint32_t i, j;
+	uint32_t i;
 	union rte_thash_tuple tuple[2];
 	uint8_t *tuples[2];
 	uint32_t rss[2] = { 0 };
@@ -328,10 +318,8 @@ test_toeplitz_hash_gfni_bulk(void)
 		rte_memcpy(tuples[0], &tuple[0], RTE_THASH_V4_L4_LEN * 4);
 
 		/*Load IPv6 headers and copy it into the corresponding tuple*/
-		for (j = 0; j < RTE_DIM(tuple[1].v6.src_addr); j++)
-			tuple[1].v6.src_addr[j] = v6_tbl[i].src_ip[j];
-		for (j = 0; j < RTE_DIM(tuple[1].v6.dst_addr); j++)
-			tuple[1].v6.dst_addr[j] = v6_tbl[i].dst_ip[j];
+		tuple[1].v6.src_addr = v6_tbl[i].src_ip;
+		tuple[1].v6.dst_addr = v6_tbl[i].dst_ip;
 		tuple[1].v6.sport = rte_cpu_to_be_16(v6_tbl[i].dst_port);
 		tuple[1].v6.dport = rte_cpu_to_be_16(v6_tbl[i].src_port);
 		rte_memcpy(tuples[1], &tuple[1], RTE_THASH_V6_L4_LEN * 4);
doc/guides/rel_notes/deprecation.rst +0 -2
index d67d63d37275..005f8c3e66a1 100644
@@ -72,8 +72,6 @@ Deprecation Notices
     - ``struct rte_flow_tunnel``
   gro
     - ``struct tcp6_flow_key``
-  hash
-    - ``struct rte_ipv6_tuple``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +2 -0
index 05212a4cc2b3..c59df2546a9d 100644
@@ -295,6 +295,8 @@ API Changes
     - ``rte_fib6_add()``
     - ``rte_fib6_delete()``
     - ``rte_fib6_lookup_bulk()``
+  hash
+    - ``struct rte_ipv6_tuple``
   ipsec
     - ``struct rte_ipsec_sadv6_key``
   lpm
lib/hash/rte_thash.h +10 -10
index eab753a06f3d..e8fdb8953044 100644
@@ -88,8 +88,8 @@ struct rte_ipv4_tuple {
  * ports/sctp_tag have to be CPU byte order
  */
 struct rte_ipv6_tuple {
-	uint8_t		src_addr[16];
-	uint8_t		dst_addr[16];
+	struct rte_ipv6_addr src_addr;
+	struct rte_ipv6_addr dst_addr;
 	union {
 		struct {
 			uint16_t dport;
@@ -140,22 +140,22 @@ rte_thash_load_v6_addrs(const struct rte_ipv6_hdr *orig,
 {
 #ifdef RTE_ARCH_X86
 	__m128i ipv6 = _mm_loadu_si128((const __m128i *)&orig->src_addr);
-	*(__m128i *)targ->v6.src_addr =
+	*(__m128i *)&targ->v6.src_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 	ipv6 = _mm_loadu_si128((const __m128i *)&orig->dst_addr);
-	*(__m128i *)targ->v6.dst_addr =
+	*(__m128i *)&targ->v6.dst_addr =
 			_mm_shuffle_epi8(ipv6, rte_thash_ipv6_bswap_mask);
 #elif defined(__ARM_NEON)
-	uint8x16_t ipv6 = vld1q_u8((uint8_t const *)&orig->src_addr);
-	vst1q_u8((uint8_t *)targ->v6.src_addr, vrev32q_u8(ipv6));
-	ipv6 = vld1q_u8((uint8_t const *)&orig->dst_addr);
-	vst1q_u8((uint8_t *)targ->v6.dst_addr, vrev32q_u8(ipv6));
+	uint8x16_t ipv6 = vld1q_u8(orig->src_addr.a);
+	vst1q_u8(targ->v6.src_addr.a, vrev32q_u8(ipv6));
+	ipv6 = vld1q_u8(orig->dst_addr.a);
+	vst1q_u8(targ->v6.dst_addr.a, vrev32q_u8(ipv6));
 #else
 	int i;
 	for (i = 0; i < 4; i++) {
-		*((uint32_t *)targ->v6.src_addr + i) =
+		*((uint32_t *)&targ->v6.src_addr + i) =
 			rte_be_to_cpu_32(*((const uint32_t *)&orig->src_addr + i));
-		*((uint32_t *)targ->v6.dst_addr + i) =
+		*((uint32_t *)&targ->v6.dst_addr + i) =
 			rte_be_to_cpu_32(*((const uint32_t *)&orig->dst_addr + i));
 	}
 #endif
Signature · 1 line
2.47.0
#102 lore raw

PATCH v4 14/17 gro: use IPv6 address structure

In reply to Robin Jarry

Update tcp6_flow_key to use rte_ipv6_addr structures instead of uint8_t[16] arrays.

---
 doc/guides/rel_notes/deprecation.rst   | 2 --
 doc/guides/rel_notes/release_24_11.rst | 2 ++
 lib/gro/gro_tcp6.c                     | 8 ++++----
 lib/gro/gro_tcp6.h                     | 6 ++++--
 4 files changed, 10 insertions(+), 8 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -2
index 005f8c3e66a1..bd2a7b877db0 100644
@@ -70,8 +70,6 @@ Deprecation Notices
     - ``struct rte_flow_item_icmp6_nd_na``
     - ``struct rte_flow_action_set_ipv6``
     - ``struct rte_flow_tunnel``
-  gro
-    - ``struct tcp6_flow_key``
 
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
doc/guides/rel_notes/release_24_11.rst +2 -0
index c59df2546a9d..473b6eb9be80 100644
@@ -297,6 +297,8 @@ API Changes
     - ``rte_fib6_lookup_bulk()``
   hash
     - ``struct rte_ipv6_tuple``
+  gro
+    - ``struct tcp6_flow_key``
   ipsec
     - ``struct rte_ipsec_sadv6_key``
   lpm
lib/gro/gro_tcp6.c +4 -4
index 6edfb6045cf6..ab4cd6c68bf0 100644
@@ -99,8 +99,8 @@ insert_new_flow(struct gro_tcp6_tbl *tbl,
 	dst = &(tbl->flows[flow_idx].key);
 
 	ASSIGN_COMMON_TCP_KEY((&src->cmn_key), (&dst->cmn_key));
-	memcpy(&dst->src_addr[0], &src->src_addr[0], sizeof(dst->src_addr));
-	memcpy(&dst->dst_addr[0], &src->dst_addr[0], sizeof(dst->dst_addr));
+	dst->src_addr = src->src_addr;
+	dst->dst_addr = src->dst_addr;
 	dst->vtc_flow = src->vtc_flow;
 
 	tbl->flows[flow_idx].start_index = item_idx;
@@ -168,8 +168,8 @@ gro_tcp6_reassemble(struct rte_mbuf *pkt,
 
 	rte_ether_addr_copy(&(eth_hdr->src_addr), &(key.cmn_key.eth_saddr));
 	rte_ether_addr_copy(&(eth_hdr->dst_addr), &(key.cmn_key.eth_daddr));
-	memcpy(&key.src_addr[0], &ipv6_hdr->src_addr, sizeof(key.src_addr));
-	memcpy(&key.dst_addr[0], &ipv6_hdr->dst_addr, sizeof(key.dst_addr));
+	key.src_addr = ipv6_hdr->src_addr;
+	key.dst_addr = ipv6_hdr->dst_addr;
 	key.cmn_key.src_port = tcp_hdr->src_port;
 	key.cmn_key.dst_port = tcp_hdr->dst_port;
 	key.cmn_key.recv_ack = tcp_hdr->recv_ack;
lib/gro/gro_tcp6.h +4 -2
index 073122f0ec84..acf3971bb6e9 100644
@@ -5,6 +5,8 @@
 #ifndef _GRO_TCP6_H_
 #define _GRO_TCP6_H_
 
+#include <rte_ip6.h>
+
 #include "gro_tcp.h"
 
 #define GRO_TCP6_TBL_MAX_ITEM_NUM (1024UL * 1024UL)
@@ -12,8 +14,8 @@
 /* Header fields representing a TCP/IPv6 flow */
 struct tcp6_flow_key {
 	struct cmn_tcp_key cmn_key;
-	uint8_t  src_addr[16];
-	uint8_t  dst_addr[16];
+	struct rte_ipv6_addr src_addr;
+	struct rte_ipv6_addr dst_addr;
 	rte_be32_t vtc_flow;
 };
 
Signature · 1 line
2.47.0
#103 lore raw

PATCH v4 15/17 flow: use IPv6 address structure

In reply to Robin Jarry

Update rte_flow_tunnel, rte_flow_action_set_ipv6, rte_flow_item_icmp6_nd_na and rte_flow_item_icmp6_nd_ns to use rte_ipv6_addr structures instead of uint8_t[16] arrays.

---
 app/test-flow-perf/actions_gen.c         |  4 ++--
 doc/guides/rel_notes/deprecation.rst     | 10 ----------
 doc/guides/rel_notes/release_24_11.rst   |  5 +++++
 drivers/net/cxgbe/cxgbe_flow.c           |  4 ++--
 drivers/net/nfp/flower/nfp_flower_flow.c |  2 +-
 lib/ethdev/rte_flow.h                    | 16 +++++++---------
 6 files changed, 17 insertions(+), 24 deletions(-)
app/test-flow-perf/actions_gen.c +2 -2
index b5336e83ff9f..54fcbacb98ce 100644
@@ -304,7 +304,7 @@ add_set_src_ipv6(struct rte_flow_action *actions,
 
 	/* IPv6 value to set is random each time */
 	for (i = 0; i < 16; i++) {
-		set_ipv6[para.core_idx].ipv6_addr[i] = ipv6 & 0xff;
+		set_ipv6[para.core_idx].ipv6_addr.a[i] = ipv6 & 0xff;
 		ipv6 = ipv6 >> 8;
 	}
 
@@ -327,7 +327,7 @@ add_set_dst_ipv6(struct rte_flow_action *actions,
 
 	/* IPv6 value to set is random each time */
 	for (i = 0; i < 16; i++) {
-		set_ipv6[para.core_idx].ipv6_addr[i] = ipv6 & 0xff;
+		set_ipv6[para.core_idx].ipv6_addr.a[i] = ipv6 & 0xff;
 		ipv6 = ipv6 >> 8;
 	}
 
doc/guides/rel_notes/deprecation.rst +0 -10
index bd2a7b877db0..17b733200740 100644
@@ -61,16 +61,6 @@ Deprecation Notices
   us extending existing enum/define.
   One solution can be using a fixed size array instead of ``.*MAX.*`` value.
 
-* net: A new IPv6 address structure will be introduced in DPDK 24.11.
-  It will replace all ad-hoc ``uint8_t[16]`` arrays in all public APIs and structures.
-  The following libraries and symbols are expected to be affected:
-
-  ethdev
-    - ``struct rte_flow_item_icmp6_nd_ns``
-    - ``struct rte_flow_item_icmp6_nd_na``
-    - ``struct rte_flow_action_set_ipv6``
-    - ``struct rte_flow_tunnel``
-
 * net, ethdev: The flow item ``RTE_FLOW_ITEM_TYPE_VXLAN_GPE``
   is replaced with ``RTE_FLOW_ITEM_TYPE_VXLAN``.
   The struct ``rte_flow_item_vxlan_gpe`` and its mask ``rte_flow_item_vxlan_gpe_mask``
doc/guides/rel_notes/release_24_11.rst +5 -0
index 473b6eb9be80..9cd413d023c6 100644
@@ -291,6 +291,11 @@ API Changes
 
   cmdline
     - ``cmdline_ipaddr_t``
+  ethdev
+    - ``struct rte_flow_action_set_ipv6``
+    - ``struct rte_flow_item_icmp6_nd_na``
+    - ``struct rte_flow_item_icmp6_nd_ns``
+    - ``struct rte_flow_tunnel``
   fib
     - ``rte_fib6_add()``
     - ``rte_fib6_delete()``
drivers/net/cxgbe/cxgbe_flow.c +2 -2
index b6d169097c1a..14b9b49792bc 100644
@@ -680,7 +680,7 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a,
 						  "found.");
 
 		ipv6 = (const struct rte_flow_action_set_ipv6 *)a->conf;
-		memcpy(fs->nat_fip, ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
+		memcpy(fs->nat_fip, &ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
 		*nmode |= 1 << 0;
 		break;
 	case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST:
@@ -693,7 +693,7 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a,
 						  "found.");
 
 		ipv6 = (const struct rte_flow_action_set_ipv6 *)a->conf;
-		memcpy(fs->nat_lip, ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
+		memcpy(fs->nat_lip, &ipv6->ipv6_addr, sizeof(ipv6->ipv6_addr));
 		*nmode |= 1 << 1;
 		break;
 	case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
drivers/net/nfp/flower/nfp_flower_flow.c +1 -1
index 43574afea8ac..df3fd5e2a298 100644
@@ -3011,7 +3011,7 @@ nfp_flow_action_set_ipv6(char *act_data,
 	set_ip->reserved = 0;
 
 	for (i = 0; i < 4; i++) {
-		rte_memcpy(&tmp, &set_ipv6->ipv6_addr[i * 4], 4);
+		rte_memcpy(&tmp, &set_ipv6->ipv6_addr.a[i * 4], 4);
 		set_ip->ipv6[i].exact = tmp;
 		set_ip->ipv6[i].mask = RTE_BE32(0xffffffff);
 	}
lib/ethdev/rte_flow.h +7 -9
index e8baedcc79d8..3d2ccdeb9226 100644
@@ -1498,15 +1498,14 @@ struct rte_flow_item_icmp6_nd_ns {
 	uint8_t code; /**< ICMPv6 code, normally 0. */
 	rte_be16_t checksum; /**< ICMPv6 checksum. */
 	rte_be32_t reserved; /**< Reserved, normally 0. */
-	uint8_t target_addr[16]; /**< Target address. */
+	struct rte_ipv6_addr target_addr; /**< Target address. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS. */
 #ifndef __cplusplus
 static const
 struct rte_flow_item_icmp6_nd_ns rte_flow_item_icmp6_nd_ns_mask = {
-	.target_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-			 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+	.target_addr = RTE_IPV6_MASK_FULL,
 };
 #endif
 
@@ -1524,15 +1523,14 @@ struct rte_flow_item_icmp6_nd_na {
 	 * reserved (29b).
 	 */
 	rte_be32_t rso_reserved;
-	uint8_t target_addr[16]; /**< Target address. */
+	struct rte_ipv6_addr target_addr; /**< Target address. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA. */
 #ifndef __cplusplus
 static const
 struct rte_flow_item_icmp6_nd_na rte_flow_item_icmp6_nd_na_mask = {
-	.target_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-			 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
+	.target_addr = RTE_IPV6_MASK_FULL,
 };
 #endif
 
@@ -3812,7 +3810,7 @@ struct rte_flow_action_set_ipv4 {
  * specified outermost IPv6 header.
  */
 struct rte_flow_action_set_ipv6 {
-	uint8_t ipv6_addr[16];
+	struct rte_ipv6_addr ipv6_addr;
 };
 
 /**
@@ -5210,8 +5208,8 @@ struct rte_flow_tunnel {
 			rte_be32_t dst_addr; /**< IPv4 destination address. */
 		} ipv4;
 		struct {
-			uint8_t src_addr[16]; /**< IPv6 source address. */
-			uint8_t dst_addr[16]; /**< IPv6 destination address. */
+			struct rte_ipv6_addr src_addr; /**< IPv6 source address. */
+			struct rte_ipv6_addr dst_addr; /**< IPv6 destination address. */
 		} ipv6;
 	};
 	rte_be16_t tp_src; /**< Tunnel port source. */
Signature · 1 line
2.47.0
#104 lore raw

PATCH v4 16/17 net: add utilities for well known IPv6 address types

In reply to Robin Jarry

Add more utilities to work with IPv6 addresses. These functions will be required in order to help building IPv6 routing applications.

---
 app/test/test_net_ip6.c |  68 +++++++++++++++++++
 lib/net/rte_ip6.h       | 143 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 211 insertions(+)
app/test/test_net_ip6.c +68 -0
index dcc80c1309d1..94033421ad0b 100644
@@ -81,20 +81,85 @@ static int
 test_ipv6_addr_kind(void)
 {
 	TEST_ASSERT(rte_ipv6_addr_is_unspec(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&zero_addr), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&zero_addr), "");
 
 	const struct rte_ipv6_addr ucast =
 		RTE_IPV6(0x2a01, 0xcb00, 0x0254, 0x3300, 0x6239, 0xe1f4, 0x7a0b, 0x2371);
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&ucast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&ucast), "");
 
 	const struct rte_ipv6_addr mcast = RTE_IPV6(0xff01, 0, 0, 0, 0, 0, 0, 1);
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&mcast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&mcast), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&mcast), "");
+	TEST_ASSERT(rte_ipv6_addr_is_mcast(&mcast), "");
 
 	const struct rte_ipv6_addr lo = RTE_IPV6_ADDR_LOOPBACK;
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&lo), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_linklocal(&lo), "");
+	TEST_ASSERT(rte_ipv6_addr_is_loopback(&lo), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&lo), "");
 
 	const struct rte_ipv6_addr local =
 		RTE_IPV6(0xfe80, 0, 0, 0, 0x5a84, 0xc52c, 0x6aef, 0x4639);
 	TEST_ASSERT(!rte_ipv6_addr_is_unspec(&local), "");
+	TEST_ASSERT(rte_ipv6_addr_is_linklocal(&local), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_loopback(&local), "");
+	TEST_ASSERT(!rte_ipv6_addr_is_mcast(&local), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ipv6_llocal_from_ethernet(void)
+{
+	const struct rte_ether_addr local_mac = {{0x04, 0x7b, 0xcb, 0x5c, 0x08, 0x44}};
+	const struct rte_ipv6_addr local_ip =
+		RTE_IPV6(0xfe80, 0, 0, 0, 0x047b, 0xcbff, 0xfe5c, 0x0844);
+	struct rte_ipv6_addr ip;
+
+	rte_ipv6_llocal_from_ethernet(&ip, &local_mac);
+	TEST_ASSERT(rte_ipv6_addr_eq(&ip, &local_ip), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ipv6_solnode_from_addr(void)
+{
+	struct rte_ipv6_addr sol;
+
+	const struct rte_ipv6_addr llocal =
+		RTE_IPV6(0xfe80, 0, 0, 0, 0x047b, 0xcbff, 0xfe5c, 0x0844);
+	const struct rte_ipv6_addr llocal_sol =
+		RTE_IPV6(0xff02, 0, 0, 0, 0, 0x0001, 0xff5c, 0x0844);
+	rte_ipv6_solnode_from_addr(&sol, &llocal);
+	TEST_ASSERT(rte_ipv6_addr_eq(&sol, &llocal_sol), "");
+
+	const struct rte_ipv6_addr ucast =
+		RTE_IPV6(0x2a01, 0xcb00, 0x0254, 0x3300, 0x1b9f, 0x8071, 0x67cd, 0xbf20);
+	const struct rte_ipv6_addr ucast_sol =
+		RTE_IPV6(0xff02, 0, 0, 0, 0, 0x0001, 0xffcd, 0xbf20);
+	rte_ipv6_solnode_from_addr(&sol, &ucast);
+	TEST_ASSERT(rte_ipv6_addr_eq(&sol, &ucast_sol), "");
+
+	return TEST_SUCCESS;
+}
+
+static int
+test_ether_mcast_from_ipv6(void)
+{
+	const struct rte_ether_addr mcast_mac = {{0x33, 0x33, 0xd3, 0x00, 0x02, 0x01}};
+	const struct rte_ipv6_addr mcast_ip =
+		RTE_IPV6(0xff02, 0, 0, 0x0201, 0, 0, 0xd300, 0x0201);
+	struct rte_ether_addr mac;
+
+	rte_ether_mcast_from_ipv6(&mac, &mcast_ip);
+	TEST_ASSERT(rte_is_same_ether_addr(&mac, &mcast_mac), "");
 
 	return TEST_SUCCESS;
 }
@@ -105,6 +170,9 @@ test_net_ipv6(void)
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_mask(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_eq_prefix(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_kind(), "");
+	TEST_ASSERT_SUCCESS(test_ipv6_llocal_from_ethernet(), "");
+	TEST_ASSERT_SUCCESS(test_ipv6_solnode_from_addr(), "");
+	TEST_ASSERT_SUCCESS(test_ether_mcast_from_ipv6(), "");
 	return TEST_SUCCESS;
 }
 
lib/net/rte_ip6.h +143 -0

155 lines not on this page · raw message

Signature · 1 line
2.47.0
#105 lore raw

PATCH v4 17/17 net: add function to check IPv6 version

In reply to Robin Jarry

Add a function to check the version in IPv6 headers.

---
 app/test/test_net_ip6.c | 16 ++++++++++++++++
 lib/net/rte_ip6.h       | 14 ++++++++++++++
 2 files changed, 30 insertions(+)
app/test/test_net_ip6.c +16 -0
index 94033421ad0b..9cc10b1f714f 100644
@@ -9,6 +9,21 @@
 static const struct rte_ipv6_addr mask_full = RTE_IPV6_MASK_FULL;
 static const struct rte_ipv6_addr zero_addr = RTE_IPV6_ADDR_UNSPEC;
 
+static int
+test_ipv6_check_version(void)
+{
+	struct rte_ipv6_hdr h;
+
+	h.vtc_flow = 0;
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, "");
+	h.vtc_flow = RTE_BE32(0x7f00ba44);
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), -EINVAL, "");
+	h.vtc_flow = RTE_BE32(0x6badcaca);
+	TEST_ASSERT_EQUAL(rte_ipv6_check_version(&h), 0, "");
+
+	return 0;
+}
+
 static int
 test_ipv6_addr_mask(void)
 {
@@ -167,6 +182,7 @@ test_ether_mcast_from_ipv6(void)
 static int
 test_net_ipv6(void)
 {
+	TEST_ASSERT_SUCCESS(test_ipv6_check_version(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_mask(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_eq_prefix(), "");
 	TEST_ASSERT_SUCCESS(test_ipv6_addr_kind(), "");
lib/net/rte_ip6.h +14 -0
index d02b225303e9..94bc5a39b348 100644
@@ -364,6 +364,20 @@ struct rte_ipv6_hdr {
 	struct rte_ipv6_addr dst_addr;	/**< IP address of destination host(s). */
 } __rte_packed;
 
+/**
+ * Check that the IPv6 header version field is valid according to RFC 8200 section 3.
+ *
+ * @return
+ *   0 if the version field is valid. -EINVAL otherwise.
+ */
+static inline int rte_ipv6_check_version(const struct rte_ipv6_hdr *ip)
+{
+	uint8_t version = ((const uint8_t *)ip)[0];
+	if ((version & 0xf0) != 0x60)
+		return -EINVAL;
+	return 0;
+}
+
 /* IPv6 routing extension type definition. */
 #define RTE_IPV6_SRCRT_TYPE_4 4
 
Signature · 1 line
2.47.0
#106 lore raw

v5 cover IPv6 APIs overhaul

In reply to Robin Jarry

Hi everyone,

As discussed recently [1], here is a first draft of the IPv6 APIs rework. The API change was announced before the 24.07 release [2]. This series is intended for 24.11.

[1] http://inbox.dpdk.org/dev/[email protected]/
[2] https://git.dpdk.org/dpdk/commit/?id=835d4c41e0ab58a115c2170c886ba6d3cc1b5764

I tried to keep the patches as small as possible; unfortunately some of them are quite big and cannot be broken down if we want to preserve a bisectable tree.

Thanks!

Cc Bruce Richardson <[email protected]>
Cc Ferruh Yigit <[email protected]>
Cc Konstantin Ananyev <[email protected]>
Cc Morten Brørup <[email protected]>
Cc Stephen Hemminger <[email protected]>
Cc Vladimir Medvedkin <[email protected]>

Changelog:

v5:

- rebase on e214d58eb87b ("net: improve VLAN header type alignment")
- fix include ordering
- improve doxygen api
- fix RTE_IPV6_U16_SPLIT to make sparse happy about 0xffff literals being truncated
- reformat macros with \ only separated with a space
- update changelog with deprecated symbols and their replacements, if any

Robin Jarry (17):
net: split raw checksum functions in separate header
net: split IPv4 and IPv6 symbols in separate headers
net: add IPv6 address structure and utils
net: use IPv6 structure for packet headers
lpm6: use IPv6 address structure and utils
fib6: use IPv6 address structure and utils
rib6: use IPv6 address structure and utils
cmdline: use IPv6 address structure
node: use IPv6 address structure and utils
pipeline: use IPv6 structures
ipsec: use IPv6 address structure
security: use IPv6 address structure
hash: use IPv6 address structure
gro: use IPv6 address structure
flow: use IPv6 address structure
net: add utilities for well known IPv6 address types
net: add function to check IPv6 version

 MAINTAINERS                              |    1 +
 app/graph/ethdev.c                       |   44 +-
 app/graph/ethdev.h                       |    9 +-
 app/graph/ip6_route.c                    |   51 +-
 app/graph/meson.build                    |    2 +-
 app/graph/neigh.c                        |   21 +-
 app/graph/neigh_priv.h                   |    4 +-
 app/graph/route.h                        |    8 +-
 app/test-fib/main.c                      |   74 +-
 app/test-flow-perf/actions_gen.c         |    4 +-
 app/test-flow-perf/items_gen.c           |    4 +-
 app/test-pipeline/pipeline_hash.c        |    4 +-
 app/test-pipeline/pipeline_lpm_ipv6.c    |   11 +-
 app/test-pmd/cmdline.c                   |    4 +-
 app/test-pmd/cmdline_flow.c              |   14 +-
 app/test-pmd/testpmd.h                   |   16 +-
 app/test-sad/main.c                      |   24 +-
 app/test/meson.build                     |    1 +
 app/test/packet_burst_generator.c        |    4 +-
 app/test/test_cmdline_ipaddr.c           |   49 +-
 app/test/test_fib6.c                     |   92 +-
 app/test/test_fib6_perf.c                |    8 +-
 app/test/test_ipfrag.c                   |    4 +-
 app/test/test_ipsec_sad.c                |   46 +-
 app/test/test_lpm6.c                     |  490 +++---
 app/test/test_lpm6_data.h                | 2025 +++++++++++-----------
 app/test/test_lpm6_perf.c                |   10 +-
 app/test/test_net_ip6.c                  |  195 +++
 app/test/test_reassembly_perf.c          |   23 +-
 app/test/test_rib6.c                     |   55 +-
 app/test/test_table_combined.c           |    2 +-
 app/test/test_table_tables.c             |    8 +-
 app/test/test_thash.c                    |   46 +-
 doc/api/doxy-api-index.md                |    4 +-
 doc/guides/prog_guide/ipsec_lib.rst      |    4 +-
 doc/guides/rel_notes/deprecation.rst     |   42 -
 doc/guides/rel_notes/release_24_11.rst   |   61 +
 drivers/common/cnxk/cnxk_security.c      |   14 +-
 drivers/net/bnxt/bnxt_flow.c             |   12 +-
 drivers/net/bonding/rte_eth_bond_pmd.c   |    6 +-
 drivers/net/cxgbe/cxgbe_flow.c           |   18 +-
 drivers/net/dpaa2/dpaa2_flow.c           |   22 +-
 drivers/net/hinic/hinic_pmd_flow.c       |    6 +-
 drivers/net/hinic/hinic_pmd_tx.c         |    2 +-
 drivers/net/hns3/hns3_flow.c             |    8 +-
 drivers/net/i40e/i40e_flow.c             |   12 +-
 drivers/net/iavf/iavf_fdir.c             |    8 +-
 drivers/net/iavf/iavf_fsub.c             |    8 +-
 drivers/net/iavf/iavf_ipsec_crypto.c     |    9 +-
 drivers/net/ice/ice_fdir_filter.c        |   12 +-
 drivers/net/ice/ice_switch_filter.c      |   16 +-
 drivers/net/igc/igc_flow.c               |    4 +-
 drivers/net/ixgbe/ixgbe_flow.c           |   12 +-
 drivers/net/ixgbe/ixgbe_ipsec.c          |    4 +-
 drivers/net/mlx5/hws/mlx5dr_definer.c    |   36 +-
 drivers/net/mlx5/mlx5_flow.c             |    6 +-
 drivers/net/mlx5/mlx5_flow_dv.c          |   16 +-
 drivers/net/mlx5/mlx5_flow_hw.c          |   10 +-
 drivers/net/mlx5/mlx5_flow_verbs.c       |    8 +-
 drivers/net/mvpp2/mrvl_flow.c            |   16 +-
 drivers/net/nfp/flower/nfp_flower_flow.c |   34 +-
 drivers/net/nfp/nfp_ipsec.c              |    4 +-
 drivers/net/nfp/nfp_net_flow.c           |   38 +-
 drivers/net/qede/qede_filter.c           |    4 +-
 drivers/net/sfc/sfc_flow.c               |   22 +-
 drivers/net/tap/tap_flow.c               |   10 +-
 drivers/net/txgbe/txgbe_flow.c           |   12 +-
 drivers/net/txgbe/txgbe_ipsec.c          |    4 +-
 examples/cmdline/commands.c              |   30 +-
 examples/ip_fragmentation/main.c         |   23 +-
 examples/ip_pipeline/cli.c               |   61 +-
 examples/ip_pipeline/parser.c            |    2 +-
 examples/ip_pipeline/parser.h            |    3 +-
 examples/ip_pipeline/pipeline.c          |   16 +-
 examples/ip_pipeline/pipeline.h          |    6 +-
 examples/ip_pipeline/thread.c            |   15 +-
 examples/ip_reassembly/main.c            |   23 +-
 examples/ipsec-secgw/flow.c              |   45 +-
 examples/ipsec-secgw/ipsec.c             |   33 +-
 examples/ipsec-secgw/ipsec.h             |    5 +-
 examples/ipsec-secgw/ipsec_lpm_neon.h    |    7 +-
 examples/ipsec-secgw/ipsec_worker.c      |   11 +-
 examples/ipsec-secgw/ipsec_worker.h      |    4 +-
 examples/ipsec-secgw/parser.c            |    2 +-
 examples/ipsec-secgw/parser.h            |    4 +-
 examples/ipsec-secgw/rt.c                |   24 +-
 examples/ipsec-secgw/sa.c                |   37 +-
 examples/ipsec-secgw/sad.h               |   14 +-
 examples/ipsec-secgw/sp6.c               |  154 +-
 examples/l3fwd-graph/main.c              |   33 +-
 examples/l3fwd/l3fwd_fib.c               |   39 +-
 examples/l3fwd/l3fwd_lpm.c               |    8 +-
 examples/l3fwd/l3fwd_route.h             |    9 +-
 examples/l3fwd/lpm_route_parse.c         |    9 +-
 examples/l3fwd/main.c                    |   32 +-
 lib/cmdline/cmdline_parse_ipaddr.h       |    3 +-
 lib/ethdev/rte_flow.h                    |   22 +-
 lib/fib/meson.build                      |    3 +-
 lib/fib/rte_fib6.c                       |   19 +-
 lib/fib/rte_fib6.h                       |   16 +-
 lib/fib/trie.c                           |  117 +-
 lib/fib/trie.h                           |   19 +-
 lib/fib/trie_avx512.c                    |   38 +-
 lib/fib/trie_avx512.h                    |   10 +-
 lib/gro/gro_tcp6.c                       |    8 +-
 lib/gro/gro_tcp6.h                       |    6 +-
 lib/hash/rte_thash.h                     |   28 +-
 lib/ip_frag/rte_ipv6_reassembly.c        |    4 +-
 lib/ipsec/rte_ipsec_sad.h                |    5 +-
 lib/lpm/meson.build                      |    1 +
 lib/lpm/rte_lpm6.c                       |  148 +-
 lib/lpm/rte_lpm6.h                       |   19 +-
 lib/net/meson.build                      |    3 +
 lib/net/rte_cksum.h                      |  180 ++
 lib/net/rte_ip.h                         |  840 +--------
 lib/net/rte_ip4.h                        |  381 ++++
 lib/net/rte_ip6.h                        |  798 +++++++++
 lib/node/ip6_lookup.c                    |   21 +-
 lib/node/rte_node_ip6_api.h              |    3 +-
 lib/pipeline/rte_swx_ipsec.c             |   10 +-
 lib/pipeline/rte_swx_ipsec.h             |    5 +-
 lib/pipeline/rte_table_action.c          |   44 +-
 lib/pipeline/rte_table_action.h          |    7 +-
 lib/rib/meson.build                      |    2 +-
 lib/rib/rte_rib6.c                       |  112 +-
 lib/rib/rte_rib6.h                       |   27 +-
 lib/security/rte_security.h              |    5 +-
 lib/table/rte_table_lpm_ipv6.c           |   12 +-
 lib/table/rte_table_lpm_ipv6.h           |    7 +-
 129 files changed, 3928 insertions(+), 3501 deletions(-)
 create mode 100644 app/test/test_net_ip6.c
 create mode 100644 lib/net/rte_cksum.h
 create mode 100644 lib/net/rte_ip4.h
 create mode 100644 lib/net/rte_ip6.h
Signature · 1 line
2.47.0
#107 lore raw

PATCH v5 1/17 net: split raw checksum functions in separate header

The checksum functions are used by both ipv4 and ipv6 functions. In preparation of moving ipv6 symbols to a new header, move the checksum related symbols to another dedicated header.

Update doxygen index accordingly.

---
 doc/api/doxy-api-index.md |   1 +
 lib/net/meson.build       |   1 +
 lib/net/rte_cksum.h       | 180 ++++++++++++++++++++++++++++++++++++++
 lib/net/rte_ip.h          | 148 +------------------------------
 4 files changed, 183 insertions(+), 147 deletions(-)
 create mode 100644 lib/net/rte_cksum.h
doc/api/doxy-api-index.md +1 -0
index 27e66d1406c8..8b83af53a863 100644
@@ -221,6 +221,7 @@ The public API headers are grouped by topics:
   [bitops](@ref rte_bitops.h),
   [approx fraction](@ref rte_approx.h),
   [random](@ref rte_random.h),
+  [checksum](@ref rte_cksum.h),
   [config file](@ref rte_cfgfile.h),
   [key/value args](@ref rte_kvargs.h),
   [argument parsing](@ref rte_argparse.h),
lib/net/meson.build +1 -0
index 06da7338ba97..ac76acd6a934 100644
@@ -2,6 +2,7 @@
 # Copyright(c) 2017-2020 Intel Corporation
 
 headers = files(
+        'rte_cksum.h',
         'rte_ip.h',
         'rte_tcp.h',
         'rte_udp.h',
lib/net/rte_cksum.h new file +180 -0

180 lines not on this page · raw message

lib/net/rte_ip.h +1 -147

160 lines not on this page · raw message

Signature · 1 line
2.47.0
#108 lore raw

PATCH v5 2/17 net: split IPv4 and IPv6 symbols in separate headers

In reply to Robin Jarry

Split IPv4 and IPv6 symbols in two separate headers. rte_ip4.h and rte_ip6.h, respectively.

Update doxygen index accordingly.

Include rte_ip4.h and rte_ip6.h in rte_ip.h for backward compatibility in applications.

---
 doc/api/doxy-api-index.md       |   3 +-
 lib/net/meson.build             |   2 +
 lib/net/rte_ip.h                | 694 +-------------------------------
 lib/net/{rte_ip.h => rte_ip4.h} | 325 +--------------
 lib/net/{rte_ip.h => rte_ip6.h} | 352 +---------------
 5 files changed, 16 insertions(+), 1360 deletions(-)
 copy lib/net/{rte_ip.h => rte_ip4.h} (52%)
 copy lib/net/{rte_ip.h => rte_ip6.h} (50%)
doc/api/doxy-api-index.md +2 -1
index 8b83af53a863..266c8b90dcfb 100644
@@ -117,7 +117,8 @@ The public API headers are grouped by topics:
   [IPsec group](@ref rte_ipsec_group.h),
   [IPsec SA](@ref rte_ipsec_sa.h),
   [IPsec SAD](@ref rte_ipsec_sad.h),
-  [IP](@ref rte_ip.h),
+  [IPv4](@ref rte_ip4.h),
+  [IPv6](@ref rte_ip6.h),
   [frag/reass](@ref rte_ip_frag.h),
   [UDP](@ref rte_udp.h),
   [SCTP](@ref rte_sctp.h),
lib/net/meson.build +2 -0
index ac76acd6a934..8afcc4ed372f 100644
@@ -4,6 +4,8 @@
 headers = files(
         'rte_cksum.h',
         'rte_ip.h',
+        'rte_ip4.h',
+        'rte_ip6.h',
         'rte_tcp.h',
         'rte_udp.h',
         'rte_tls.h',
lib/net/rte_ip.h +3 -691

703 lines not on this page · raw message

lib/net/rte_ip4.h renamed from lib/net/rte_ip.h +3 -322

341 lines not on this page · raw message

lib/net/rte_ip6.h renamed from lib/net/rte_ip.h +6 -346

385 lines not on this page · raw message

Signature · 1 line
2.47.0
#109 lore raw

PATCH v5 3/17 net: add IPv6 address structure and utils

In reply to Robin Jarry

There is currently no structure defined for IPv6 addresses. Introduce one that is simply a uint8_t array of 16 elements. The idea is to ensure this structure alignment is 1 so that it can be mapped directly on unaligned packet memory.

Add utility functions and macros that use the newly added rte_ipv6_addr structure. Add basic unit tests to ensure everything works as expected.

These functions will be used in the next commits to replace private and/or duplicated functions.

---
 MAINTAINERS                            |   1 +
 app/test/meson.build                   |   1 +
 app/test/test_net_ip6.c                | 111 +++++++++++++
 doc/guides/rel_notes/release_24_11.rst |   5 +
 lib/net/rte_ip6.h                      | 213 +++++++++++++++++++++++++
 5 files changed, 331 insertions(+)
 create mode 100644 app/test/test_net_ip6.c
MAINTAINERS +1 -0
index f09cda04c87d..b94bf57a2034 100644
@@ -1526,6 +1526,7 @@ F: lib/net/
 F: app/test/test_cksum.c
 F: app/test/test_cksum_perf.c
 F: app/test/test_net_ether.c
+F: app/test/test_net_ip6.c
 
 Packet CRC
 M: Jasvinder Singh <[email protected]>
app/test/meson.build +1 -0
index fe248b786c8e..0f7e11969a44 100644
@@ -131,6 +131,7 @@ source_file_deps = {
     'test_metrics.c': ['metrics'],
     'test_mp_secondary.c': ['hash'],
     'test_net_ether.c': ['net'],
+    'test_net_ip6.c': ['net'],
     'test_pcapng.c': ['ethdev', 'net', 'pcapng', 'bus_vdev'],
     'test_pdcp.c': ['eventdev', 'pdcp', 'net', 'timer', 'security'],
     'test_pdump.c': ['pdump'] + sample_packet_forward_deps,
app/test/test_net_ip6.c new file +111 -0

111 lines not on this page · raw message

doc/guides/rel_notes/release_24_11.rst +5 -0
index d2301461ce35..e68676caf029 100644
@@ -238,6 +238,11 @@ New Features
   Added ability for node to advertise and update multiple xstat counters,
   that can be retrieved using ``rte_graph_cluster_stats_get``.
 
+* **Added IPv6 address structure and related utilities.**
+
+  A new IPv6 address structure is now available in ``rte_ip6.h``.
+  It comes with a set of helper functions and macros.
+
 
 Removed Items
 -------------
lib/net/rte_ip6.h +213 -0

225 lines not on this page · raw message

Signature · 1 line
2.47.0