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 3DDE045B09; Thu, 10 Oct 2024 21:43:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3E5B409FA; Thu, 10 Oct 2024 21:42:58 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id BD09E409FA for ; Thu, 10 Oct 2024 21:42:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728589377; 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=uK3R7lAm8x4/8NJu3VnwOCixSntSxcsN5TjZeytQh7M=; b=gTYMrFIhZr/Tw1Z65l0AzN6WqJpLqDsZL+td8fJ8ELpHkUspGnTJzchF8YiXRGB2Tdjb6g sw5OFHCJp0gvVbJ1WOpXi3U3+pXxFWLK+gRGipyiVQB3dNHODxQTCIccu0vIfVtlQAxzb5 +N2Wkl7aLRvESyqPZklZHwXMgtGdbTM= 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-163-GDIGuBMnN5q7Fs1mIo6UhQ-1; Thu, 10 Oct 2024 15:42:54 -0400 X-MC-Unique: GDIGuBMnN5q7Fs1mIo6UhQ-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 D5DB0195608D; Thu, 10 Oct 2024 19:42:52 +0000 (UTC) Received: from ringo.redhat.com (unknown [10.39.208.7]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AEB8619560AA; Thu, 10 Oct 2024 19:42:49 +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 v3 10/17] graph,node: use struct rte_ipv6_addr and utils Date: Thu, 10 Oct 2024 21:41:40 +0200 Message-ID: <20241010194148.1877659-11-rjarry@redhat.com> In-Reply-To: <20241010194148.1877659-1-rjarry@redhat.com> References: <20240821162516.610624-17-rjarry@redhat.com> <20241010194148.1877659-1-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 rte_ipv6_addr structures. Replace duplicated code with utils from rte_ip6.h. Signed-off-by: Robin Jarry --- Notes: v3: - replace *memcpy() with direct struct assignments - replace string initializers with RTE_IPV6() - replace in6_addr with rte_ipv6_addr now that libcmdline uses it as well app/graph/ethdev.c | 44 +++++++--------------- app/graph/ethdev.h | 9 ++--- app/graph/ip6_route.c | 51 +++++++------------------- app/graph/meson.build | 2 +- app/graph/neigh.c | 21 ++++------- app/graph/neigh_priv.h | 4 +- app/graph/route.h | 8 ++-- doc/guides/rel_notes/deprecation.rst | 2 - doc/guides/rel_notes/release_24_11.rst | 1 + examples/l3fwd-graph/main.c | 33 ++++++----------- lib/node/ip6_lookup.c | 9 ++--- lib/node/rte_node_ip6_api.h | 3 +- 12 files changed, 65 insertions(+), 122 deletions(-) diff --git a/app/graph/ethdev.c b/app/graph/ethdev.c index 13ed791412e1..b890efecb52a 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]; - } + 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) 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 d91466cd78d6..ec53239b069b 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]; - } + ipv6route->ip = route->ip; + ipv6route->mask = route->mask; + ipv6route->gateway = route->gateway; ipv6route->is_used = true; if (!graph_status_get()) @@ -153,17 +133,12 @@ cmd_ipv6_lookup_route_add_ipv6_parsed(void *parsed_result, __rte_unused struct c void *data __rte_unused) { struct cmd_ipv6_lookup_route_add_ipv6_result *res = parsed_result; - struct route_ipv6_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]; - - for (i = 0; i < ETHDEV_IPV6_ADDR_LEN; i++) - config.gateway[i] = res->via_ip.addr.ipv6.a[i]; + struct route_ipv6_config config = { + .ip = res->ip.addr.ipv6, + .mask = res->mask.addr.ipv6, + .gateway = res->via_ip.addr.ipv6, + }; + int rc; 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 eb7a09f1f145..3298f63c1a84 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]; - + 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); } 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/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index ee958c689b3a..c268c497834c 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -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`` diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index f5a2ac3cfb4f..4b2f6627b0d0 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -146,6 +146,7 @@ API Changes * net: The ``rte_ipv6_hdr`` structure was modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` fields. * rib6,fib6,lpm6: All public API functions were modified to use ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` parameters. * cmdline: ``cmdline_ipaddr_t`` was modified to use ``struct rte_ipv6_addr`` instead of ``in6_addr``. +* node: ``rte_node_ip6_route_add()`` was modified to use a ``struct rte_ipv6_addr`` instead of ``uint8_t[16]`` parameter. ABI Changes ----------- diff --git a/examples/l3fwd-graph/main.c b/examples/l3fwd-graph/main.c index 9bda0ab633e1..7fabd5b8d5cd 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_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); diff --git a/lib/node/ip6_lookup.c b/lib/node/ip6_lookup.c index faaea5085938..f378d2d0646d 100644 --- a/lib/node/ip6_lookup.c +++ b/lib/node/ip6_lookup.c @@ -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 " diff --git a/lib/node/rte_node_ip6_api.h b/lib/node/rte_node_ip6_api.h index f467aac7b6db..2875bc981a47 100644 --- a/lib/node/rte_node_ip6_api.h +++ b/lib/node/rte_node_ip6_api.h @@ -17,6 +17,7 @@ */ #include #include +#include #ifdef __cplusplus extern "C" { @@ -48,7 +49,7 @@ enum rte_node_ip6_lookup_next { * 0 on success, negative otherwise. */ __rte_experimental -int rte_node_ip6_route_add(const uint8_t *ip, uint8_t depth, uint16_t next_hop, +int rte_node_ip6_route_add(const struct rte_ipv6_addr *ip, uint8_t depth, uint16_t next_hop, enum rte_node_ip6_lookup_next next_node); /** -- 2.46.2