IPv6 APIs overhaul
Subsystems (4)
PATCH v5 4/17 net: use IPv6 structure for packet headers
In reply to Robin JarryThe 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1005,10 +1005,8 @@ struct rte_flow_item_ipv6 {#ifndef __cplusplusstatic 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
@@ -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
@@ -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
@@ -256,8 +256,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. */
@@ -325,7 +325,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
@@ -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
@@ -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
@@ -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
PATCH v5 5/17 lpm6: use IPv6 address structure and utils
In reply to Robin JarryReplace 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 | 12 + 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, 1466 insertions(+), 1544 deletions(-)
app/test-fib/main.c +27 -47
@@ -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
@@ -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
@@ -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
doc/guides/rel_notes/release_24_11.rst +12 -0
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
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.
PATCH v5 6/17 fib6: use IPv6 address structure and utils
In reply to Robin JarryReplace 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 | 6 ++ 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, 195 insertions(+), 196 deletions(-)
app/test-fib/main.c +4 -4
@@ -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
@@ -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
@@ -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 +6 -0
@@ -289,6 +289,12 @@ 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()`` + - ``RTE_FIB6_IPV6_ADDR_SIZE`` (deprecated, replaced with ``RTE_IPV6_ADDR_SIZE``) + - ``RTE_FIB6_MAXDEPTH`` (deprecated, replaced with ``RTE_IPV6_MAX_DEPTH``) lpm - ``rte_lpm6_add()`` - ``rte_lpm6_delete()``
examples/l3fwd/l3fwd_fib.c +18 -21
@@ -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 voidfib_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
@@ -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
@@ -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
@@ -17,14 +17,16 @@#include <stdint.h> +#include <rte_common.h> +#include <rte_ip6.h> #ifdef __cplusplusextern "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 +10 -9
@@ -8,6 +8,9 @@#include <stdalign.h> +#include <rte_common.h> +#include <rte_fib6.h> +/** * @file * RTE IPv6 Longest Prefix Match (LPM)
@@ -15,8 +18,6 @@/* @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/* @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 +43,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 +108,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 +116,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 +139,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
@@ -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
@@ -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
PATCH v5 7/17 rib6: use IPv6 address structure and utils
In reply to Robin JarryReplace 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
@@ -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
@@ -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
@@ -309,6 +309,17 @@ API Changes table - ``struct rte_table_lpm_ipv6_key`` - ``RTE_LPM_IPV6_ADDR_SIZE`` (deprecated, replaced with ``RTE_IPV6_ADDR_SIZE``) + 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, replaced 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
@@ -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
@@ -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
@@ -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
@@ -16,12 +16,13 @@#include <rte_memcpy.h> #include <rte_common.h> +#include <rte_ip6.h> #ifdef __cplusplusextern "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
PATCH v5 8/17 cmdline: use IPv6 address structure
In reply to Robin JarryThe 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
@@ -627,10 +627,10 @@ cmd_ethdev_dev_ip6_addr_add_parsed(void *parsed_result, __rte_unused struct cmdlint 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
@@ -157,13 +157,13 @@ cmd_ipv6_lookup_route_add_ipv6_parsed(void *parsed_result, __rte_unused struct cint 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -9,6 +9,7 @@#include <cmdline_parse.h> #include <rte_ip.h> +#include <rte_ip6.h> #ifdef __cplusplusextern "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
Re: [PATCH dpdk v5 08/17] cmdline: use IPv6 address structure
Quoted 12 lines · Robin Jarry
The previous commits introduced a new
rte_ipv6_addrstructure without any alignment requirements. It is not compatible with thein6_addrPOSIX type available innetinet/in.h.The main issue is that
in6_addris 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_addrwithrte_ipv6_addrin the cmdline library. Update all code accordingly.Signed-off-by Robin Jarry <[email protected]>
Quoted 13 lines
--- 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(-)
PATCH v5 9/17 node: use IPv6 address structure and utils
In reply to Robin JarryReplace 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
@@ -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, ð_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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -308,6 +308,8 @@ API Changes - ``RTE_LPM6_MAX_DEPTH`` (deprecated, replaced with ``RTE_IPV6_MAX_DEPTH``) net - ``struct rte_ipv6_hdr`` + node + - ``rte_node_ip6_route_add()`` table - ``struct rte_table_lpm_ipv6_key`` - ``RTE_LPM_IPV6_ADDR_SIZE`` (deprecated, replaced with ``RTE_IPV6_ADDR_SIZE``)
examples/l3fwd-graph/main.c +12 -21
@@ -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
@@ -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
@@ -17,6 +17,7 @@*/ #include <rte_common.h> #include <rte_compat.h> +#include <rte_ip6.h> #ifdef __cplusplusextern "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
PATCH v5 10/17 pipeline: use IPv6 structures
In reply to Robin JarryUpdate 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
@@ -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
@@ -310,6 +310,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`` - ``RTE_LPM_IPV6_ADDR_SIZE`` (deprecated, replaced with ``RTE_IPV6_ADDR_SIZE``)
examples/ip_pipeline/cli.c +26 -35
188 lines not on this page · raw message
examples/ip_pipeline/parser.c +1 -1
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -48,6 +48,7 @@#include <rte_compat.h> #include <rte_crypto_sym.h> +#include <rte_ip6.h> #ifdef __cplusplusextern "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
@@ -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
@@ -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
PATCH v5 11/17 ipsec: use IPv6 address structure
In reply to Robin JarryUpdate 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
@@ -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
@@ -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
@@ -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
@@ -297,6 +297,8 @@ API Changes - ``rte_fib6_lookup_bulk()`` - ``RTE_FIB6_IPV6_ADDR_SIZE`` (deprecated, replaced with ``RTE_IPV6_ADDR_SIZE``) - ``RTE_FIB6_MAXDEPTH`` (deprecated, replaced with ``RTE_IPV6_MAX_DEPTH``) + ipsec + - ``struct rte_ipsec_sadv6_key`` lpm - ``rte_lpm6_add()`` - ``rte_lpm6_delete()``
examples/ipsec-secgw/flow.c +10 -10
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v5 12/17 security: use IPv6 address structure
In reply to Robin JarryFor 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
@@ -316,6 +316,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`` - ``RTE_LPM_IPV6_ADDR_SIZE`` (deprecated, replaced with ``RTE_IPV6_ADDR_SIZE``)
drivers/common/cnxk/cnxk_security.c +6 -8
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v5 13/17 hash: use IPv6 address structure
In reply to Robin JarryUpdate 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
@@ -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
@@ -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
@@ -297,6 +297,8 @@ API Changes - ``rte_fib6_lookup_bulk()`` - ``RTE_FIB6_IPV6_ADDR_SIZE`` (deprecated, replaced with ``RTE_IPV6_ADDR_SIZE``) - ``RTE_FIB6_MAXDEPTH`` (deprecated, replaced with ``RTE_IPV6_MAX_DEPTH``) + hash + - ``struct rte_ipv6_tuple`` ipsec - ``struct rte_ipsec_sadv6_key`` lpm
lib/hash/rte_thash.h +10 -10
@@ -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
PATCH v5 14/17 gro: use IPv6 address structure
In reply to Robin JarryUpdate 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
@@ -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
@@ -299,6 +299,8 @@ API Changes - ``RTE_FIB6_MAXDEPTH`` (deprecated, replaced with ``RTE_IPV6_MAX_DEPTH``) hash - ``struct rte_ipv6_tuple`` + gro + - ``struct tcp6_flow_key`` ipsec - ``struct rte_ipsec_sadv6_key`` lpm
lib/gro/gro_tcp6.c +4 -4
@@ -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
@@ -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
PATCH v5 15/17 flow: use IPv6 address structure
In reply to Robin JarryUpdate 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 __cplusplusstatic 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 __cplusplusstatic 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
PATCH v5 16/17 net: add utilities for well known IPv6 address types
In reply to Robin JarryAdd 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 | 209 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 277 insertions(+)
app/test/test_net_ip6.c +68 -0
@@ -81,20 +81,85 @@ static inttest_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 +209 -0
221 lines not on this page · raw message
Signature · 1 line
2.47.0
PATCH v5 17/17 net: add function to check IPv6 version
In reply to Robin JarryAdd a function to check the version in IPv6 headers.
--- app/test/test_net_ip6.c | 16 ++++++++++++++++ lib/net/rte_ip6.h | 16 ++++++++++++++++ 2 files changed, 32 insertions(+)
app/test/test_net_ip6.c +16 -0
@@ -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 +16 -0
@@ -469,6 +469,22 @@ 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. +* +* @param ip +* The IPv6 header. +* @return +* @c 0 if the version field is valid. @c -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
Quoted 179 lines · 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=835d4c41e0ab58a115c2170c886ba6d3cc1b5764I 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
- fixRTE_IPV6_U16_SPLITto make sparse happy about0xffffliterals being truncated
- reformat macros with \ only separated with a space
- update changelog with deprecated symbols and their replacements, if anyRobin 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 versionMAINTAINERS | 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 +-
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 +- 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
Fixed doxygen issue reported in GHA.
Removed RN update about private type in gro.
Series applied, thanks Robin.
Signature · 1 line
David Marchand
Quoted 180 lines · David Marchand
Quoted 179 lines · 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=835d4c41e0ab58a115c2170c886ba6d3cc1b5764I 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
- fixRTE_IPV6_U16_SPLITto make sparse happy about0xffffliterals being truncated
- reformat macros with \ only separated with a space
- update changelog with deprecated symbols and their replacements, if anyRobin 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 versionMAINTAINERS | 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 +-
Quoted 8 lines
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 +- 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
After almost two years, the next LTS release looks like a good time to drop the deprecated stuff in the rib library.
$ git grep -i deprecated lib/rib/
lib/rib/rte_rib6.h:#define RTE_RIB6_IPV6_ADDR_SIZE
(RTE_DEPRECATED(RTE_RIB6_IPV6_ADDR_SIZE) RTE_IPV6_ADDR_SIZE)
lib/rib/rte_rib6.h: __rte_deprecated_msg("use direct struct assignment");
lib/rib/rte_rib6.h: __rte_deprecated_msg("use rte_ipv6_addr_eq");
lib/rib/rte_rib6.h:static inline uint8_t get_msk_part(uint8_t depth,
int byte) __rte_deprecated;Could you send a patch please?
Signature · 1 line
David Marchand