From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2BB7745834; Wed, 21 Aug 2024 18:27:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 17397427D3; Wed, 21 Aug 2024 18:27:58 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 78D824279D for ; Wed, 21 Aug 2024 18:27:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724257670; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IqK/6sEuPGEBTnKSKgxYcJ1Vgwadu4fNnI9s1jf27p4=; b=NfqUBu2/IcMVCztOSYdxyGkqdI1zGHJGd6XaPSpMlk45+Zzl3TaoTGNwxS0Yf1M+MfG0gO 0Um8gl9KY/rnZsoVij9V/F2BxpPrAGqMYOI6aMWL054Kxj6m+jTzq1C5efMvlN2NR+HBU9 MLswQHdUE39mZ5gLIr+G+DFu3t/SH/I= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-4Tc34zLpMm65eLEw_WNXYQ-1; Wed, 21 Aug 2024 12:27:45 -0400 X-MC-Unique: 4Tc34zLpMm65eLEw_WNXYQ-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3CAE11979055; Wed, 21 Aug 2024 16:27:35 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.208.21]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EF2C9190B386; Wed, 21 Aug 2024 16:26:47 +0000 (UTC) From: Robin Jarry To: dev@dpdk.org, Sunil Kumar Kori , Rakesh Kudurumalla , Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Zhirun Yan , Pavan Nikhilesh Subject: [PATCH dpdk v1 08/15] graph,node: use ipv6 addr struct and utils Date: Wed, 21 Aug 2024 18:25:25 +0200 Message-ID: <20240821162516.610624-25-rjarry@redhat.com> In-Reply-To: <20240821162516.610624-17-rjarry@redhat.com> References: <20240821162516.610624-17-rjarry@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace ad-hoc uint8_t[16] arrays with the previously introduced IPv6 address structure. Signed-off-by: Robin Jarry --- app/graph/ethdev.c | 40 ++++++++++--------------------- app/graph/ethdev.h | 9 ++++--- app/graph/ip6_route.c | 47 +++++++++---------------------------- app/graph/meson.build | 2 +- app/graph/neigh.c | 22 +++++++---------- app/graph/neigh_priv.h | 4 +++- app/graph/route.h | 8 ++++--- examples/l3fwd-graph/main.c | 30 +++++++++-------------- lib/node/ip6_lookup.c | 17 ++++++-------- lib/node/rte_node_ip6_api.h | 3 ++- 10 files changed, 65 insertions(+), 117 deletions(-) diff --git a/app/graph/ethdev.c b/app/graph/ethdev.c index cfc1b1856910..19c5ab685464 100644 --- a/app/graph/ethdev.c +++ b/app/graph/ethdev.c @@ -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]; - } + rte_ipv6_addr_cpy(ð_hdl->ip6_addr.ip, &config->ip); + rte_ipv6_addr_cpy(ð_hdl->ip6_addr.mask, &config->mask); return 0; } rc = -EINVAL; @@ -624,13 +611,10 @@ cmd_ethdev_dev_ip6_addr_add_parsed(void *parsed_result, __rte_unused struct cmdl { struct cmd_ethdev_dev_ip6_addr_add_result *res = parsed_result; struct ipv6_addr_config config; - int rc = -EINVAL, i; + int rc = -EINVAL; - for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) - config.ip[i] = res->ip.addr.ipv6.s6_addr[i]; - - for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) - config.mask[i] = res->mask.addr.ipv6.s6_addr[i]; + rte_memcpy(&config.ip, &res->ip.addr.ipv6, sizeof(config.ip)); + rte_memcpy(&config.mask, &res->mask.addr.ipv6, sizeof(config.mask)); rc = ethdev_ip6_addr_add(res->dev, &config); if (rc < 0) diff --git a/app/graph/ethdev.h b/app/graph/ethdev.h index d0de593fc743..046689ee5fc7 100644 --- a/app/graph/ethdev.h +++ b/app/graph/ethdev.h @@ -6,8 +6,7 @@ #define APP_GRAPH_ETHDEV_H #include - -#define ETHDEV_IPV6_ADDR_LEN 16 +#include 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); diff --git a/app/graph/ip6_route.c b/app/graph/ip6_route.c index 834719ecaeb4..5460e5070b42 100644 --- a/app/graph/ip6_route.c +++ b/app/graph/ip6_route.c @@ -11,6 +11,7 @@ #include #include +#include #include "module_api.h" #include "route_priv.h" @@ -43,38 +44,20 @@ find_route6_entry(struct route_ipv6_config *route) return NULL; } -static uint8_t -convert_ip6_netmask_to_depth(uint8_t *netmask) -{ - uint8_t setbits = 0; - uint8_t mask; - int i; - - for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) { - mask = netmask[i]; - while (mask & 0x80) { - mask = mask << 1; - setbits++; - } - } - - return setbits; -} - static int route6_rewirte_table_update(struct route_ipv6_config *ipv6route) { uint8_t depth; int portid; - portid = ethdev_portid_by_ip6(ipv6route->gateway, ipv6route->mask); + portid = ethdev_portid_by_ip6(&ipv6route->gateway, &ipv6route->mask); if (portid < 0) { printf("Invalid portid found to install the route\n"); return portid; } - depth = convert_ip6_netmask_to_depth(ipv6route->mask); + depth = rte_ipv6_mask_depth(&ipv6route->mask); - return rte_node_ip6_route_add(ipv6route->ip, depth, portid, + return rte_node_ip6_route_add(&ipv6route->ip, depth, portid, RTE_NODE_IP6_LOOKUP_NEXT_REWRITE); } @@ -84,7 +67,6 @@ route_ip6_add(struct route_ipv6_config *route) { struct route_ipv6_config *ipv6route; int rc = -EINVAL; - int j; ipv6route = find_route6_entry(route); if (!ipv6route) { @@ -95,11 +77,9 @@ route_ip6_add(struct route_ipv6_config *route) return 0; } - for (j = 0; j < ETHDEV_IPV6_ADDR_LEN; j++) { - ipv6route->ip[j] = route->ip[j]; - ipv6route->mask[j] = route->mask[j]; - ipv6route->gateway[j] = route->gateway[j]; - } + rte_ipv6_addr_cpy(&ipv6route->ip, &route->ip); + rte_ipv6_addr_cpy(&ipv6route->mask, &route->mask); + rte_ipv6_addr_cpy(&ipv6route->gateway, &route->gateway); ipv6route->is_used = true; if (!graph_status_get()) @@ -154,16 +134,11 @@ cmd_ipv6_lookup_route_add_ipv6_parsed(void *parsed_result, __rte_unused struct c { struct cmd_ipv6_lookup_route_add_ipv6_result *res = parsed_result; struct route_ipv6_config config; - int rc = -EINVAL, i; + int rc = -EINVAL; - for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) - config.ip[i] = res->ip.addr.ipv6.s6_addr[i]; - - for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) - config.mask[i] = res->mask.addr.ipv6.s6_addr[i]; - - for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) - config.gateway[i] = res->via_ip.addr.ipv6.s6_addr[i]; + rte_memcpy(&config.ip, &res->ip.addr.ipv6, sizeof(config.ip)); + rte_memcpy(&config.mask, &res->mask.addr.ipv6, sizeof(config.mask)); + rte_memcpy(&config.gateway, &res->via_ip.addr.ipv6, sizeof(config.gateway)); rc = route_ip6_add(&config); if (rc) diff --git a/app/graph/meson.build b/app/graph/meson.build index 6dc54d5ee63f..344e4a418fc0 100644 --- a/app/graph/meson.build +++ b/app/graph/meson.build @@ -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', diff --git a/app/graph/neigh.c b/app/graph/neigh.c index 79fd542c8948..0b35f4d6c294 100644 --- a/app/graph/neigh.c +++ b/app/graph/neigh.c @@ -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]; - + rte_ipv6_addr_cpy(&v6_config->ip, ip); v6_config->mac = mac; v6_config->is_used = true; @@ -261,19 +258,18 @@ 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; + struct rte_ipv6_addr ip; + int rc = -EINVAL; uint64_t mac; - for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) - ip[i] = res->ip.addr.ipv6.s6_addr[i]; + rte_memcpy(&ip, &res->ip.addr.ipv6, sizeof(ip)); if (parser_mac_read(&mac, res->mac)) { printf(MSG_ARG_INVALID, "mac"); return; } - rc = neigh_ip6_add(ip, mac); + rc = neigh_ip6_add(&ip, mac); if (rc < 0) printf(MSG_CMD_FAIL, res->neigh); } diff --git a/app/graph/neigh_priv.h b/app/graph/neigh_priv.h index 1a7106c309bc..b2a7607e01bb 100644 --- a/app/graph/neigh_priv.h +++ b/app/graph/neigh_priv.h @@ -5,6 +5,8 @@ #ifndef APP_GRAPH_NEIGH_PRIV_H #define APP_GRAPH_NEIGH_PRIV_H +#include + #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; }; diff --git a/app/graph/route.h b/app/graph/route.h index 23a7951d2dad..455aab8634d4 100644 --- a/app/graph/route.h +++ b/app/graph/route.h @@ -5,6 +5,8 @@ #ifndef APP_GRAPH_ROUTE_H #define APP_GRAPH_ROUTE_H +#include + #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; }; diff --git a/examples/l3fwd-graph/main.c b/examples/l3fwd-graph/main.c index a13dc011380d..c2067a05f3ef 100644 --- a/examples/l3fwd-graph/main.c +++ b/examples/l3fwd-graph/main.c @@ -151,7 +151,7 @@ struct ipv4_l3fwd_lpm_route { }; struct ipv6_l3fwd_lpm_route { - uint8_t ip[RTE_LPM6_IPV6_ADDR_SIZE]; + struct rte_ipv6_addr ip; uint8_t depth; uint8_t if_out; }; @@ -171,22 +171,14 @@ static struct ipv4_l3fwd_lpm_route ipv4_l3fwd_lpm_route_array[] = { (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}, + {{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"}, 48, 0}, + {{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"}, 48, 1}, + {{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02"}, 48, 2}, + {{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03"}, 48, 3}, + {{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04"}, 48, 4}, + {{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05"}, 48, 5}, + {{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06"}, 48, 6}, + {{.a = "\x20\x01\xdb\x08\x12\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02"}, 48, 7}, }; static int @@ -1371,14 +1363,14 @@ main(int argc, char **argv) dst_port = ipv6_l3fwd_lpm_route_array[i].if_out; - memcpy(in6.s6_addr, ipv6_l3fwd_lpm_route_array[i].ip, RTE_LPM6_IPV6_ADDR_SIZE); + memcpy(in6.s6_addr, &ipv6_l3fwd_lpm_route_array[i].ip, RTE_IPV6_ADDR_SIZE); snprintf(route_str, sizeof(route_str), "%s / %d (%d)", inet_ntop(AF_INET6, &in6, abuf, sizeof(abuf)), ipv6_l3fwd_lpm_route_array[i].depth, 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); diff --git a/lib/node/ip6_lookup.c b/lib/node/ip6_lookup.c index 1ad6e3fd18f2..0806500d86cf 100644 --- a/lib/node/ip6_lookup.c +++ b/lib/node/ip6_lookup.c @@ -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_ipv6_addr_cpy(&ip_batch[0], &ipv6_hdr->dst_addr); /* 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_ipv6_addr_cpy(&ip_batch[1], &ipv6_hdr->dst_addr); /* 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_ipv6_addr_cpy(&ip_batch[2], &ipv6_hdr->dst_addr); /* 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_ipv6_addr_cpy(&ip_batch[3], &ipv6_hdr->dst_addr); rte_lpm6_lookup_bulk_func(lpm6, ip_batch, next_hop, 4); @@ -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_LPM6_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 " diff --git a/lib/node/rte_node_ip6_api.h b/lib/node/rte_node_ip6_api.h index a538dc2ea701..dc8c86184afe 100644 --- a/lib/node/rte_node_ip6_api.h +++ b/lib/node/rte_node_ip6_api.h @@ -21,6 +21,7 @@ extern "C" { #include #include +#include /** * IP6 lookup next nodes. @@ -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); /** -- 2.46.0