aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--netlink/Makefile.am25
-rw-r--r--netlink/README.md25
-rw-r--r--netlink/configure.ac16
-rw-r--r--netlink/librtnl/mapper.c6
-rw-r--r--netlink/netlink.mk32
-rw-r--r--netlink/test/test.c27
-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
11 files changed, 230 insertions, 101 deletions
diff --git a/netlink/Makefile.am b/netlink/Makefile.am
index 85023f8..f760b86 100644
--- a/netlink/Makefile.am
+++ b/netlink/Makefile.am
@@ -13,7 +13,21 @@
AUTOMAKE_OPTIONS = foreign subdir-objects
-AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@
+AM_CFLAGS = -Wall -fstack-protector -fPIC -Werror -g -DFORTIFY_SOURCE=2
+if DEBUG
+AM_CFLAGS += -O0 -DCLIB_DEBUG
+vpp_build = vpp_debug-native
+else
+AM_CFLAGS += -O2
+vpp_build = vpp-native
+endif
+
+if VPP_DIR_SET
+vpp_install = @VPP_DIR@/build-root/install-$(vpp_build)
+AM_CFLAGS += -I$(vpp_install)/vpp/include/
+else
+AM_CFLAGS += -Wall
+endif
lib_LTLIBRARIES = librtnl.la
@@ -33,8 +47,9 @@ testrtnl_plugin_la_SOURCES = test/test.c
testrtnl_plugin_la_LDFLAGS = -module
testrtnl_plugin_la_LIBADD = librtnl.la
-if WITH_PLUGIN_TOOLKIT
-install-data-hook:
- mkdir /usr/lib/vpp_plugins || true
- cp $(prefix)/lib/testnl_plugin.so.*.*.* /usr/lib/vpp_plugins
+if VPP_DIR_SET
+install: install-am
+ mkdir -p $(vpp_install)/vpp/lib64/vpp_plugins/
+ cp $(prefix)/lib/testrtnl_plugin.so.*.*.* $(vpp_install)/vpp/lib64/vpp_plugins/testrtnl_plugin.so
+ cp $(prefix)/lib/librtnl.so $(vpp_install)/vpp/lib64/librtnl.so
endif
diff --git a/netlink/README.md b/netlink/README.md
index 02f4c18..f26a3c7 100644
--- a/netlink/README.md
+++ b/netlink/README.md
@@ -4,15 +4,34 @@ This VPP package provides a rtnetlink-based library to be used by [VPP](http://f
## HowTo
-The library and test plugin can be compiled by copying netlink.mk into VPP's build tree build-data/packages/ directory and using VPP make target netlink-install.
+The library and test plugin can be compiled by running the following commands from the plugin directory:
+```bash
+libtoolize
+aclocal
+autoconf
+automake --add-missing
+./configure
+make
+sudo make install
+```
+
+If VPP is not installed, but rather built in a separate directory, you can use the VPP_DIR 'configure' argument.
+
+```bash
+./configure VPP_DIR=<path/to/vpp/directory>
+make
+make install
+```
+
+You can also enable debug with the 'configure' --enable-debug option.
+
-Note that VPP build system can be configured to look in other directories for additional build-data/packages/ directories by adding those to build-root/build-config.mk SOURCE_PATH variable.
## Administrativa
### Current status
-This library is still under active development, which means the defined headers and functions are subject to changes without notice.
+This library is currently looking for some maintainers.
### Objective
diff --git a/netlink/configure.ac b/netlink/configure.ac
index 5fdd345..7e8380a 100644
--- a/netlink/configure.ac
+++ b/netlink/configure.ac
@@ -6,13 +6,15 @@ AM_PROG_AS
AC_PROG_CC
AM_PROG_CC_C_O
-AC_ARG_WITH(plugin-toolkit,
- AC_HELP_STRING([--with-plugin-toolkit],
- [build using the vpp toolkit]),
- [with_plugin_toolkit=${prefix}/include],
- [with_plugin_toolkit=.])
+AC_ARG_VAR(VPP_DIR,[ vpp build directory ])
+AM_CONDITIONAL([VPP_DIR_SET], [test ! -z "$VPP_DIR"])
-AC_SUBST(TOOLKIT_INCLUDE,[${with_plugin_toolkit}])
-AM_CONDITIONAL(WITH_PLUGIN_TOOLKIT, test "$with_plugin_toolkit" != ".")
+AC_ARG_ENABLE([debug],
+[ --enable-debug Turn on debugging],
+ [if test x$enableval = xyes; then
+ AC_DEFINE(DEBUG, 1, [Define this to enable debug.])
+ debug=true
+ fi], [debug=false])
+AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
AC_OUTPUT([Makefile])
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..916e1f8 100644
--- a/netlink/test/test.c
+++ b/netlink/test/test.c
@@ -18,6 +18,7 @@
#include <vnet/plugin/plugin.h>
#include <librtnl/mapper.h>
#include <vnet/ip/ip.h>
+#include <vnet/fib/fib.h>
u32 handles[10];
@@ -121,17 +122,8 @@ mapper_ns_add_command_fn (vlib_main_t * vm,
if (!strcmp(nsname, "default"))
nsname[0] = 0;
-#ifdef find_ip4_fib_by_table_index_or_id
- u32 fib4 = find_ip4_fib_by_table_index_or_id(&ip4_main, table_id, 0) - ip4_main.fibs;
-#else
- u32 fib4 = fib_table_id_find_fib_index (FIB_PROTOCOL_IP4, table_id);
-#endif
-
-#ifdef find_ip6_fib_by_table_index_or_id
- u32 fib6 = find_ip6_fib_by_table_index_or_id(&ip6_main, table_id, 0) - ip6_main.fibs;
-#else
- u32 fib6 = fib_table_id_find_fib_index (FIB_PROTOCOL_IP6, table_id);
-#endif
+ u32 fib4 = ip4_fib_index_from_table_id(table_id);
+ u32 fib6 = ip6_fib_index_from_table_id(table_id);
if (mapper_add_ns(nsname, fib4, fib6, &mapper_indexes[index]))
return clib_error_return(0, "Could not add ns %s", nsname);
@@ -200,11 +192,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);