aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--netlink/librtnl/mapper.c6
-rw-r--r--netlink/netlink.mk32
-rw-r--r--netlink/test/test.c13
-rw-r--r--router/README.md6
-rw-r--r--router/router.mk33
-rw-r--r--router/router/tap_inject.c47
-rw-r--r--router/router/tap_inject_netlink.c72
-rw-r--r--router/router/tap_inject_node.c42
8 files changed, 176 insertions, 75 deletions
diff --git a/netlink/librtnl/mapper.c b/netlink/librtnl/mapper.c
index b82fae8..65cc13a 100644
--- a/netlink/librtnl/mapper.c
+++ b/netlink/librtnl/mapper.c
@@ -96,7 +96,8 @@ int mapper_add_del_route(mapper_ns_t *ns, ns_route_t *route, int del)
fib_table_entry_path_add (ns->v6fib_index, &prefix, FIB_SOURCE_API,
FIB_ENTRY_FLAG_NONE, prefix.fp_proto,
&nh, map->sw_if_index, ns->v6fib_index,
- 0 /* weight */, MPLS_LABEL_INVALID,
+ 0 /* weight */,
+ (mpls_label_t *) MPLS_LABEL_INVALID,
FIB_ROUTE_PATH_FLAG_NONE);
#endif /* FIB_VERSION == 1 */
} else {
@@ -126,7 +127,8 @@ int mapper_add_del_route(mapper_ns_t *ns, ns_route_t *route, int del)
fib_table_entry_path_add (ns->v4fib_index, &prefix, FIB_SOURCE_API,
FIB_ENTRY_FLAG_NONE, prefix.fp_proto,
&nh, map->sw_if_index, ns->v4fib_index,
- 0 /* weight */, MPLS_LABEL_INVALID,
+ 0 /* weight */,
+ (mpls_label_t *) MPLS_LABEL_INVALID,
FIB_ROUTE_PATH_FLAG_NONE);
#endif /* FIB_VERSION == 1 */
}
diff --git a/netlink/netlink.mk b/netlink/netlink.mk
index 677a1b5..610205f 100644
--- a/netlink/netlink.mk
+++ b/netlink/netlink.mk
@@ -1,31 +1,5 @@
-netlink_configure_depend = \
- vppinfra-install \
- dpdk-install \
- svm-install \
- vlib-api-install \
- vlib-install \
- vnet-install \
- vpp-install \
- vpp-api-test-install
+netlink_configure_depend = vpp-install
-netlink_CPPFLAGS = $(call installed_includes_fn, \
- vppinfra \
- dpdk \
- openssl \
- svm \
- vlib \
- vlib-api \
- vnet \
- vpp \
- vpp-api-test)
+netlink_CPPFLAGS = $(call installed_includes_fn, vpp)
-netlink_LDFLAGS = $(call installed_libs_fn, \
- vppinfra \
- dpdk \
- openssl \
- svm \
- vlib \
- vlib-api \
- vnet \
- vpp \
- vpp-api-test)
+netlink_LDFLAGS = $(call installed_libs_fn, vpp)
diff --git a/netlink/test/test.c b/netlink/test/test.c
index 96f49f8..2922a40 100644
--- a/netlink/test/test.c
+++ b/netlink/test/test.c
@@ -200,11 +200,10 @@ VLIB_CLI_COMMAND (mapper_iface_command, static) = {
.function = mapper_iface_command_fn,
};
-clib_error_t *
-vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h,
- int from_early_init)
-{
- clib_warning("Loaded module");
- return 0;
-}
+/* *INDENT-OFF* */
+VLIB_PLUGIN_REGISTER () = {
+ // .version = VPP_BUILD_VER, FIXME
+ .description = "netlink",
+};
+/* *INDENT-ON* */
diff --git a/router/README.md b/router/README.md
index b4e8ce0..3401c76 100644
--- a/router/README.md
+++ b/router/README.md
@@ -34,7 +34,7 @@ Now build everything and create a link to the plugin in vpp's plugin path.
```
$ cd build-root
$ ./bootstrap.sh
-$ make V=0 PLATFORM=vpp TAG=vpp_debug router-install
+$ make V=0 PLATFORM=vpp TAG=vpp_debug netlink-install router-install
$ ln -sf /git/vpp/build-root/install-vpp_debug-native/router/lib64/router.so.0.0.0 \
/usr/lib/vpp_plugins/router.so
```
@@ -43,7 +43,7 @@ Once VPP is running and the plugin is loaded, data plane interfaces can
be tapped.
```
-$ vppctl tap inject arp,icmp4 from TenGigabitEthernet2/0/0 as vpp0
+$ vppctl enable tap-inject
```
The host operating system should see a tap named 'vpp0' with the same hardware
@@ -58,7 +58,7 @@ plane's default fib.
Currently the router plugin handles ARP, locally destined ICMPv4 and OSPF
traffic. It supports the classifier directing packets from an ip4-table to
-the 'tap-inject-classified' node (for handling multicast OSPF and IGMP).
+the 'tap-inject-neighbor' node (for handling multicast OSPF and IGMP).
### Objective
diff --git a/router/router.mk b/router/router.mk
index f9bb917..9ffbd3a 100644
--- a/router/router.mk
+++ b/router/router.mk
@@ -1,34 +1,11 @@
-router_configure_depend = \
- vppinfra-install \
- dpdk-install \
- svm-install \
- vlib-api-install \
- vlib-install \
- vnet-install \
- vpp-install \
- netlink-install \
- vpp-api-test-install
++router_configure_depend = \
++ vpp-install \
++ netlink-install
router_CPPFLAGS = $(call installed_includes_fn, \
- vppinfra \
- dpdk \
- openssl \
- svm \
- vlib \
- vlib-api \
- vnet \
vpp \
- netlink \
- vpp-api-test)
+ netlink)
router_LDFLAGS = $(call installed_libs_fn, \
- vppinfra \
- dpdk \
- openssl \
- svm \
- vlib \
- vlib-api \
- vnet \
vpp \
- netlink \
- vpp-api-test)
+ netlink)
diff --git a/router/router/tap_inject.c b/router/router/tap_inject.c
index 8d6f5af..75d6df2 100644
--- a/router/router/tap_inject.c
+++ b/router/router/tap_inject.c
@@ -16,7 +16,17 @@
#include "tap_inject.h"
+#include <vnet/ip/ip.h>
+#include <vnet/ip/lookup.h>
+#ifdef ip6_add_del_route_next_hop
+#define FIB_VERSION 1
+#else
+#include <vnet/fib/fib.h>
+#define FIB_VERSION 2
+#endif
+
static tap_inject_main_t tap_inject_main;
+extern dpo_type_t tap_inject_dpo_type;
tap_inject_main_t *
tap_inject_get_main (void)
@@ -84,12 +94,12 @@ tap_inject_lookup_sw_if_index_from_tap_if_index (u32 tap_if_index)
return sw_if_index ? *(u32 *)sw_if_index : ~0;
}
-
-clib_error_t *
-vlib_plugin_register (vlib_main_t * vm, vnet_plugin_handoff_t * h, int f)
-{
- return 0;
-}
+/* *INDENT-OFF* */
+VLIB_PLUGIN_REGISTER () = {
+ // .version = VPP_BUILD_VER, FIXME
+ .description = "router",
+};
+/* *INDENT-ON* */
static void
@@ -135,6 +145,7 @@ tap_inject_enable (void)
ip6_register_protocol (IP_PROTOCOL_TCP, im->tx_node_index);
ip6_register_protocol (IP_PROTOCOL_UDP, im->tx_node_index);
+#if FIB_VERSION == 1
/* Add IPv4 multicast route. */
{
ip4_add_del_route_args_t a;
@@ -163,6 +174,30 @@ tap_inject_enable (void)
ip4_add_del_route (&ip4_main, &a);
}
+#else
+ {
+ dpo_proto_t proto = 0;
+ dpo_id_t dpo = DPO_INVALID;
+ fib_prefix_t pfx = {};
+
+ pfx.fp_addr.ip4.as_u32 = 0x000000E0; /* 224.0.0.0 */
+ pfx.fp_len = 24;
+ pfx.fp_proto = FIB_PROTOCOL_IP4;
+ proto = DPO_PROTO_IP4;
+
+ vlib_node_add_next (vm, ip4_lookup_node.index, im->tx_node_index);
+
+ dpo_set(&dpo, tap_inject_dpo_type, proto, ~0);
+
+ fib_table_entry_special_dpo_add(0,
+ &pfx,
+ FIB_SOURCE_API,
+ FIB_ENTRY_FLAG_EXCLUSIVE,
+ &dpo);
+
+ dpo_reset(&dpo);
+ }
+#endif /* FIB_VERSION == 1 */
im->flags |= TAP_INJECT_F_ENABLED;
diff --git a/router/router/tap_inject_netlink.c b/router/router/tap_inject_netlink.c
index a30e262..19d5d04 100644
--- a/router/router/tap_inject_netlink.c
+++ b/router/router/tap_inject_netlink.c
@@ -19,7 +19,16 @@
#include <librtnl/netns.h>
#include <vlibmemory/api.h>
#include <vnet/ethernet/arp_packet.h>
+#include <vnet/ip/ip6_neighbor.h>
+#include <vnet/ip/ip.h>
+#include <vnet/ip/lookup.h>
+#ifdef ip6_add_del_route_next_hop
+#define FIB_VERSION 1
+#else
+#include <vnet/fib/fib.h>
+#define FIB_VERSION 2
+#endif
static void
add_del_addr (ns_addr_t * a, int is_del)
@@ -109,16 +118,41 @@ add_del_neigh (ns_neigh_t * n, int is_del)
clib_memcpy (&a.ethernet, n->lladdr, ETHER_ADDR_LEN);
clib_memcpy (&a.ip4, n->dst, sizeof (a.ip4));
+
if (n->nd.ndm_state & NUD_REACHABLE)
+ {
+#if FIB_VERSION == 1
vnet_arp_set_ip4_over_ethernet (vnet_main, sw_if_index, ~0, &a, 0);
+#else
+ vnet_arp_set_ip4_over_ethernet (vnet_main, sw_if_index,
+ &a, 0 /* static */ ,
+ 0 /* no fib entry */);
+
+#endif /* FIB_VERSION == 1 */
+ }
else if (n->nd.ndm_state & NUD_FAILED)
+ {
+#if FIB_VERSION == 1
vnet_arp_unset_ip4_over_ethernet (vnet_main, sw_if_index, ~0, &a);
+#else
+ vnet_arp_unset_ip4_over_ethernet (vnet_main, sw_if_index, &a);
+#endif /* FIB_VERSION == 1 */
+ }
}
else if (n->nd.ndm_family == AF_INET6)
{
if (n->nd.ndm_state & NUD_REACHABLE)
+ {
+#if FIB_VERSION == 1
vnet_set_ip6_ethernet_neighbor (vm, sw_if_index,
(ip6_address_t *) n->dst, n->lladdr, ETHER_ADDR_LEN, 0);
+#else
+ vnet_set_ip6_ethernet_neighbor (vm, sw_if_index,
+ (ip6_address_t *) n->dst, n->lladdr, ETHER_ADDR_LEN,
+ 0 /* static */,
+ 0 /* no fib entry */);
+#endif /* FIB_VERSION == 1 */
+ }
else
vnet_unset_ip6_ethernet_neighbor (vm, sw_if_index,
(ip6_address_t *) n->dst, n->lladdr, ETHER_ADDR_LEN);
@@ -140,17 +174,55 @@ add_del_route (ns_route_t * r, int is_del)
if (r->rtm.rtm_family == AF_INET)
{
+#if FIB_VERSION == 1
ip4_add_del_route_next_hop (&ip4_main,
is_del ? IP4_ROUTE_FLAG_DEL : IP4_ROUTE_FLAG_ADD,
(ip4_address_t *) r->dst, r->rtm.rtm_dst_len,
(ip4_address_t *) r->gateway, sw_if_index, 0, ~0, 0);
+#else
+ fib_prefix_t prefix;
+ ip46_address_t nh;
+
+ memset (&prefix, 0, sizeof (prefix));
+ prefix.fp_len = r->rtm.rtm_dst_len;
+ prefix.fp_proto = FIB_PROTOCOL_IP4;
+ clib_memcpy (&prefix.fp_addr.ip4, r->dst, sizeof (prefix.fp_addr.ip4));
+
+ memset (&nh, 0, sizeof (nh));
+ clib_memcpy (&nh.ip4, r->gateway, sizeof (nh.ip4));
+
+ fib_table_entry_path_add (0, &prefix, FIB_SOURCE_API,
+ FIB_ENTRY_FLAG_NONE, prefix.fp_proto,
+ &nh, sw_if_index, 0,
+ 0 /* weight */, NULL,
+ FIB_ROUTE_PATH_FLAG_NONE);
+#endif /* FIB_VERSION == 1 */
}
else if (r->rtm.rtm_family == AF_INET6)
{
+#if FIB_VERSION == 1
ip6_add_del_route_next_hop (&ip6_main,
is_del ? IP6_ROUTE_FLAG_DEL : IP6_ROUTE_FLAG_ADD,
(ip6_address_t *) r->dst, r->rtm.rtm_dst_len,
(ip6_address_t *) r->gateway, sw_if_index, 0, ~0, 0);
+#else
+ fib_prefix_t prefix;
+ ip46_address_t nh;
+
+ memset (&prefix, 0, sizeof (prefix));
+ prefix.fp_len = r->rtm.rtm_dst_len;
+ prefix.fp_proto = FIB_PROTOCOL_IP6;
+ clib_memcpy (&prefix.fp_addr.ip6, r->dst, sizeof (prefix.fp_addr.ip6));
+
+ memset (&nh, 0, sizeof (nh));
+ clib_memcpy (&nh.ip6, r->gateway, sizeof (nh.ip6));
+
+ fib_table_entry_path_add (0, &prefix, FIB_SOURCE_API,
+ FIB_ENTRY_FLAG_NONE, prefix.fp_proto,
+ &nh, sw_if_index, 0,
+ 0 /* weight */, NULL,
+ FIB_ROUTE_PATH_FLAG_NONE);
+#endif /* FIB_VERSION == 1 */
}
}
diff --git a/router/router/tap_inject_node.c b/router/router/tap_inject_node.c
index fe108dc..5429846 100644
--- a/router/router/tap_inject_node.c
+++ b/router/router/tap_inject_node.c
@@ -28,6 +28,10 @@ enum {
NEXT_NEIGHBOR_ICMP6,
};
+/**
+ * @brief Dynamically added tap_inject DPO type
+ */
+dpo_type_t tap_inject_dpo_type;
static inline void
tap_inject_tap_send_buffer (int fd, vlib_buffer_t * b)
@@ -312,6 +316,42 @@ VLIB_REGISTER_NODE (tap_inject_rx_node) = {
.vector_size = sizeof (u32),
};
+/**
+ * @brief no-op lock function.
+ */
+static void
+tap_inject_dpo_lock (dpo_id_t * dpo)
+{
+}
+
+/**
+ * @brief no-op unlock function.
+ */
+static void
+tap_inject_dpo_unlock (dpo_id_t * dpo)
+{
+}
+
+u8 *
+format_tap_inject_dpo (u8 * s, va_list * args)
+{
+ return (format (s, "tap-inject:[%d]", 0));
+}
+
+const static dpo_vft_t tap_inject_vft = {
+ .dv_lock = tap_inject_dpo_lock,
+ .dv_unlock = tap_inject_dpo_unlock,
+ .dv_format = format_tap_inject_dpo,
+};
+
+const static char *const tap_inject_tx_nodes[] = {
+ "tap-inject-tx",
+ NULL,
+};
+
+const static char *const *const tap_inject_nodes[DPO_PROTO_NUM] = {
+ [DPO_PROTO_IP6] = tap_inject_tx_nodes,
+};
static clib_error_t *
tap_inject_init (vlib_main_t * vm)
@@ -322,6 +362,8 @@ tap_inject_init (vlib_main_t * vm)
im->tx_node_index = tap_inject_tx_node.index;
im->neighbor_node_index = tap_inject_neighbor_node.index;
+ tap_inject_dpo_type = dpo_register_new_type (&tap_inject_vft, tap_inject_nodes);
+
vec_alloc (im->rx_buffers, NUM_BUFFERS_TO_ALLOC);
vec_reset_length (im->rx_buffers);