From: Ankur Dwivedi <adwivedi@marvell.com>
To: <dev@dpdk.org>
Cc: <jerinj@marvell.com>, <vladimir.medvedkin@intel.com>,
<ndabilpuram@marvell.com>, <pbhagavatula@marvell.com>,
<skori@marvell.com>, <rkudurumalla@marvell.com>,
<nsaxena@marvell.com>, Ankur Dwivedi <adwivedi@marvell.com>
Subject: [PATCH v3 03/14] node: add IP4 FIB route add
Date: Mon, 2 Jun 2025 12:06:28 +0530 [thread overview]
Message-ID: <20250602063639.198550-4-adwivedi@marvell.com> (raw)
In-Reply-To: <20250602063639.198550-1-adwivedi@marvell.com>
Adds a public function to add IP4 route to FIB. The applications should
call this function to add IP4 routes to FIB.
Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
---
lib/node/ip4_lookup_fib.c | 37 +++++++++++++++++++++++++++++++++++++
lib/node/rte_node_ip4_api.h | 19 +++++++++++++++++++
2 files changed, 56 insertions(+)
diff --git a/lib/node/ip4_lookup_fib.c b/lib/node/ip4_lookup_fib.c
index 977d97b713..f300266c00 100644
--- a/lib/node/ip4_lookup_fib.c
+++ b/lib/node/ip4_lookup_fib.c
@@ -2,6 +2,8 @@
* Copyright(C) 2025 Marvell.
*/
+#include <arpa/inet.h>
+
#include <eal_export.h>
#include <rte_errno.h>
#include <rte_ether.h>
@@ -58,6 +60,41 @@ rte_node_ip4_fib_create(int socket, struct rte_fib_conf *conf)
return 0;
}
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_node_ip4_fib_route_add, 25.07)
+int
+rte_node_ip4_fib_route_add(uint32_t ip, uint8_t depth, uint16_t next_hop,
+ enum rte_node_ip4_lookup_next next_node)
+{
+ char abuf[INET6_ADDRSTRLEN];
+ unsigned int nb_sockets;
+ struct in_addr in;
+ uint8_t socket;
+ uint32_t val;
+ int ret;
+
+ nb_sockets = rte_socket_count();
+ in.s_addr = htonl(ip);
+ inet_ntop(AF_INET, &in, abuf, sizeof(abuf));
+ /* Embedded next node id into 24 bit next hop */
+ val = ((next_node << 16) | next_hop) & ((1ull << 24) - 1);
+ node_dbg("ip4_lookup_fib", "FIB: Adding route %s / %d nh (0x%x)", abuf, depth, val);
+
+ for (socket = 0; socket < nb_sockets; socket++) {
+ if (!ip4_lookup_fib_nm.fib[socket])
+ continue;
+
+ ret = rte_fib_add(ip4_lookup_fib_nm.fib[socket], ip, depth, val);
+ if (ret < 0) {
+ node_err("ip4_lookup_fib",
+ "Unable to add entry %s / %d nh (%x) to FIB on sock %d, rc=%d",
+ abuf, depth, val, socket, ret);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
static int
setup_fib(int socket)
{
diff --git a/lib/node/rte_node_ip4_api.h b/lib/node/rte_node_ip4_api.h
index 1dac7a4936..4d75c5f874 100644
--- a/lib/node/rte_node_ip4_api.h
+++ b/lib/node/rte_node_ip4_api.h
@@ -132,6 +132,25 @@ int rte_node_ip4_reassembly_configure(struct rte_node_ip4_reassembly_cfg *cfg, u
__rte_experimental
int rte_node_ip4_fib_create(int socket, struct rte_fib_conf *conf);
+/**
+ * Add ipv4 route to FIB.
+ *
+ * @param ip
+ * IP address of route to be added.
+ * @param depth
+ * Depth of the rule to be added.
+ * @param next_hop
+ * Next hop id of the rule result to be added.
+ * @param next_node
+ * Next node to redirect traffic to.
+ *
+ * @return
+ * 0 on success, negative otherwise.
+ */
+__rte_experimental
+int rte_node_ip4_fib_route_add(uint32_t ip, uint8_t depth, uint16_t next_hop,
+ enum rte_node_ip4_lookup_next next_node);
+
#ifdef __cplusplus
}
#endif
--
2.25.1
next prev parent reply other threads:[~2025-06-02 6:37 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 12:10 [PATCH v1 00/12] add lookup fib nodes in graph library Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 01/12] fib: move macro to header file Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 02/12] node: add IP4 lookup FIB node Ankur Dwivedi
2025-04-16 7:32 ` Nitin Saxena
2025-04-16 10:26 ` [EXTERNAL] " Ankur Dwivedi
2025-04-16 9:34 ` Medvedkin, Vladimir
2025-04-16 10:07 ` [EXTERNAL] " Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 03/12] node: add IP4 FIB route add Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 04/12] node: add process callback for IP4 FIB Ankur Dwivedi
2025-04-16 7:54 ` Nitin Saxena
2025-04-16 12:54 ` Medvedkin, Vladimir
2025-04-18 7:38 ` [EXTERNAL] " Ankur Dwivedi
2025-04-19 18:14 ` Vladimir Medvedkin
2025-04-23 9:46 ` Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 05/12] node: add next node in packet classification Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 06/12] app/graph: add IP4 lookup mode command Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 07/12] fib: move macro to header file Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 08/12] node: add IP6 lookup FIB node Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 09/12] node: add IP6 FIB route add Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 10/12] node: add process callback for IP6 FIB Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 11/12] node: add next node in packet classification Ankur Dwivedi
2025-04-15 12:10 ` [PATCH v1 12/12] app/graph: add IP6 lookup mode command Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 00/13] add lookup fib nodes in graph library Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 01/13] fib: move macro to header file Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 02/13] node: add IP4 lookup FIB node Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 03/13] node: add IP4 FIB route add Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 04/13] node: add process callback for IP4 FIB Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 05/13] node: move next nodes to public header file Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 06/13] node: add next node in packet classification Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 07/13] app/graph: add IP4 lookup mode command Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 08/13] fib: move macro to header file Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 09/13] node: add IP6 lookup FIB node Ankur Dwivedi
2025-05-30 10:50 ` Jerin Jacob
2025-05-09 6:44 ` [PATCH v2 10/13] node: add IP6 FIB route add Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 11/13] node: add process callback for IP6 FIB Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 12/13] node: add next node in packet classification Ankur Dwivedi
2025-05-09 6:44 ` [PATCH v2 13/13] app/graph: add IP6 lookup mode command Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 00/14] add lookup fib nodes in graph library Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 01/14] fib: move macro to header file Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 02/14] node: add IP4 lookup FIB node Ankur Dwivedi
2025-06-02 6:36 ` Ankur Dwivedi [this message]
2025-06-02 6:36 ` [PATCH v3 04/14] node: add process callback for IP4 FIB Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 05/14] node: move next nodes to public header file Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 06/14] node: add next node in packet classification Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 07/14] app/graph: add IP4 lookup mode command Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 08/14] fib: move macro to header file Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 09/14] node: add IP6 lookup FIB node Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 10/14] node: add IP6 FIB route add Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 11/14] node: add process callback for IP6 FIB Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 12/14] node: add next node in packet classification Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 13/14] app/graph: add IP6 lookup mode command Ankur Dwivedi
2025-06-02 6:36 ` [PATCH v3 14/14] doc: add FIB nodes in graph guide Ankur Dwivedi
2025-06-02 8:34 ` [PATCH v3 00/14] add lookup fib nodes in graph library Morten Brørup
2025-06-03 5:44 ` Ankur Dwivedi
[not found] ` <CAG6-93zSt1SGRa0XnJnodCtiOKWUMTYBY26A3qy9cE1hd_K3oQ@mail.gmail.com>
2025-06-03 5:54 ` Nitin Saxena
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250602063639.198550-4-adwivedi@marvell.com \
--to=adwivedi@marvell.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=nsaxena@marvell.com \
--cc=pbhagavatula@marvell.com \
--cc=rkudurumalla@marvell.com \
--cc=skori@marvell.com \
--cc=vladimir.medvedkin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).