@@ -27,6 +27,7 @@ ipv4_lookup mode <STRING>lkup_mode # Set IPv4 lookup mode
help ipv4_lookup # Print help on ipv4_lookup commands
ipv6_lookup route add ipv6 <IPv6>ip netmask <IPv6>mask via <IPv6>via_ip # Add IPv6 route to LPM6 table
+ipv6_lookup mode <STRING>lkup_mode # Set IPv6 lookup mode
help ipv6_lookup # Print help on ipv6_lookup commands
neigh add ipv4 <IPv4>ip <STRING>mac # Add static neighbour for IPv4
@@ -19,8 +19,13 @@
static const char
cmd_ipv6_lookup_help[] = "ipv6_lookup route add ipv6 <ip> netmask <mask> via <ip>";
+static const char
+cmd_ipv6_lookup_mode_help[] = "ipv6_lookup mode <lpm|fib>";
+
struct ip6_route route6 = TAILQ_HEAD_INITIALIZER(route6);
+enum ip6_lookup_mode ip6_lookup_m = IP6_LOOKUP_LPM;
+
void
route_ip6_list_clean(void)
{
@@ -49,6 +54,7 @@ route6_rewirte_table_update(struct route_ipv6_config *ipv6route)
{
uint8_t depth;
int portid;
+ int rc;
portid = ethdev_portid_by_ip6(&ipv6route->gateway, &ipv6route->mask);
if (portid < 0) {
@@ -57,9 +63,14 @@ route6_rewirte_table_update(struct route_ipv6_config *ipv6route)
}
depth = rte_ipv6_mask_depth(&ipv6route->mask);
- return rte_node_ip6_route_add(&ipv6route->ip, depth, portid,
- RTE_NODE_IP6_LOOKUP_NEXT_REWRITE);
+ if (ip6_lookup_m == IP6_LOOKUP_FIB)
+ rc = rte_node_ip6_fib_route_add(&ipv6route->ip, depth, portid,
+ RTE_NODE_IP6_LOOKUP_NEXT_REWRITE);
+ else
+ rc = rte_node_ip6_route_add(&ipv6route->ip, depth, portid,
+ RTE_NODE_IP6_LOOKUP_NEXT_REWRITE);
+ return rc;
}
static int
@@ -120,9 +131,9 @@ cmd_help_ipv6_lookup_parsed(__rte_unused void *parsed_result, __rte_unused struc
len = strlen(conn->msg_out);
conn->msg_out += len;
- snprintf(conn->msg_out, conn->msg_out_len_max, "\n%s\n%s\n",
+ snprintf(conn->msg_out, conn->msg_out_len_max, "\n%s\n%s\n%s\n",
"--------------------------- ipv6_lookup command help ---------------------------",
- cmd_ipv6_lookup_help);
+ cmd_ipv6_lookup_help, cmd_ipv6_lookup_mode_help);
len = strlen(conn->msg_out);
conn->msg_out_len_max -= len;
@@ -144,3 +155,17 @@ cmd_ipv6_lookup_route_add_ipv6_parsed(void *parsed_result, __rte_unused struct c
if (rc)
printf(MSG_CMD_FAIL, res->ipv6_lookup);
}
+
+void
+cmd_ipv6_lookup_mode_parsed(void *parsed_result, __rte_unused struct cmdline *cl,
+ void *data __rte_unused)
+{
+ struct cmd_ipv6_lookup_mode_result *res = parsed_result;
+
+ if (!strcmp(res->lkup_mode, "lpm"))
+ ip6_lookup_m = IP6_LOOKUP_LPM;
+ else if (!strcmp(res->lkup_mode, "fib"))
+ ip6_lookup_m = IP6_LOOKUP_FIB;
+ else
+ printf(MSG_CMD_FAIL, res->ipv6_lookup);
+}
@@ -16,6 +16,7 @@
#include <rte_lcore.h>
#include <rte_node_eth_api.h>
#include <rte_node_ip4_api.h>
+#include <rte_node_ip6_api.h>
#include <rte_node_pkt_cls_api.h>
#include "module_api.h"
@@ -37,6 +38,22 @@ setup_fib(int socket)
return rte_node_ip4_fib_create(socket, &conf);
}
+static int
+setup_fib6(int socket)
+{
+ struct rte_fib6_conf conf;
+
+#define FIB6_MAX_ROUTES (UINT16_MAX)
+#define FIB6_NUM_TBL8 (UINT16_MAX / 2)
+ conf.type = RTE_FIB6_TRIE;
+ conf.max_routes = FIB6_MAX_ROUTES;
+ conf.rib_ext_sz = 0;
+ conf.trie.nh_sz = RTE_FIB6_TRIE_4B;
+ conf.trie.num_tbl8 = FIB6_NUM_TBL8;
+
+ return rte_node_ip6_fib_create(socket, &conf);
+}
+
static int
l3fwd_pattern_configure(void)
{
@@ -82,6 +99,16 @@ l3fwd_pattern_configure(void)
rte_node_edge_update(pkt_cls, RTE_NODE_PKT_CLS_NEXT_IP4_LOOKUP_FIB, &lpm_n, 1);
}
+ if (ip6_lookup_m == IP6_LOOKUP_FIB) {
+ const char *fib6_n = "ip6_lookup_fib";
+ const char *lpm6_n = "ip6_lookup";
+ rte_node_t pkt_cls;
+
+ pkt_cls = rte_node_from_name("pkt_cls");
+ rte_node_edge_update(pkt_cls, RTE_NODE_PKT_CLS_NEXT_IP6_LOOKUP, &fib6_n, 1);
+ rte_node_edge_update(pkt_cls, RTE_NODE_PKT_CLS_NEXT_IP6_LOOKUP_FIB, &lpm6_n, 1);
+ }
+
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
rte_graph_t graph_id;
rte_edge_t i;
@@ -114,6 +141,13 @@ l3fwd_pattern_configure(void)
graph_conf.socket_id);
}
+ if (ip6_lookup_m == IP6_LOOKUP_FIB) {
+ rc = setup_fib6(graph_conf.socket_id);
+ if (rc < 0)
+ rte_exit(EXIT_FAILURE, "Unable to setup fib6 for socket %u\n",
+ graph_conf.socket_id);
+ }
+
graph_id = rte_graph_create(qconf->name, &graph_conf);
if (graph_id == RTE_GRAPH_ID_INVALID)
rte_exit(EXIT_FAILURE,
@@ -32,7 +32,13 @@ enum ip4_lookup_mode {
IP4_LOOKUP_FIB
};
+enum ip6_lookup_mode {
+ IP6_LOOKUP_LPM,
+ IP6_LOOKUP_FIB
+};
+
extern enum ip4_lookup_mode ip4_lookup_m;
+extern enum ip6_lookup_mode ip6_lookup_m;
bool app_graph_stats_enabled(void);
bool app_graph_exit(void);
@@ -248,10 +248,14 @@ file to express the requested use case configuration.
| | | help message. | | |
+--------------------------------------+-----------------------------------+-------------------+----------+
| | ipv6_lookup route add ipv6 <ip> | | Command to add a route into | :ref:`3 <scopes>` | Yes |
- | | netmask <mask> via <ip> | | ``ipv6_lookup`` LPM table. It is| | |
- | | | needed if user wishes to route | | |
- | | | the packets based on LPM6 lookup| | |
- | | | table. | | |
+ | | netmask <mask> via <ip> | | ``ipv6_lookup`` LPM table or. | | |
+ | | | FIB. It is needed if user wishes| | |
+ | | | to route the packets based on | | |
+ | | | LPM6 lookup table or FIB. | | |
+ +--------------------------------------+-----------------------------------+-------------------+----------+
+ | | ipv6_lookup mode <lpm|fib> | | Command to set ipv6 lookup mode | :ref:`1 <scopes>` | Yes |
+ | | | to either LPM or FIB. By default| | |
+ | | | the lookup mode is LPM. | | |
+--------------------------------------+-----------------------------------+-------------------+----------+
| help ipv6_lookup | | Command to dump ``ipv6_lookup`` | :ref:`2 <scopes>` | Yes |
| | | help message. | | |