linux-cp: Linux Control Plane Netlink Listener

Type: feature

please see FEATURE.yaml for details.

Signed-off-by: Neale Ranns <nranns@cisco.com>
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Signed-off-by: Jon Loeliger <jdl@netgate.com>
Signed-off-by: Pim van Pelt <pim@ipng.nl>
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: I6255fd9953d0b03e6b4fe75b67a6845a7c206f74
Signed-off-by: Pim van Pelt <pim@ipng.nl>
This commit is contained in:
Neale Ranns
2021-02-05 09:04:35 +00:00
committed by Ole Tr�an
parent 1fd912c8dd
commit 616447c392
9 changed files with 1770 additions and 18 deletions
+2 -2
View File
@@ -71,7 +71,7 @@ DEB_DEPENDS += libffi-dev python3-ply libmbedtls-dev
DEB_DEPENDS += cmake ninja-build uuid-dev python3-jsonschema python3-yaml
DEB_DEPENDS += python3-venv # ensurepip
DEB_DEPENDS += python3-dev # needed for python3 -m pip install psutil
DEB_DEPENDS += libnl-3-dev libnl-route-3-dev
DEB_DEPENDS += libnl-3-dev libnl-route-3-dev libmnl-dev
DEB_DEPENDS += enchant # for docs
DEB_DEPENDS += python3-virtualenv
DEB_DEPENDS += libssl-dev
@@ -116,7 +116,7 @@ RPM_DEPENDS += mbedtls-devel
RPM_DEPENDS += ccache
RPM_DEPENDS += xmlto
RPM_DEPENDS += elfutils-libelf-devel
RPM_DEPENDS += libnl3-devel
RPM_DEPENDS += libnl3-devel libmnl-devel
ifeq ($(OS_ID),fedora)
RPM_DEPENDS += dnf-utils
+9
View File
@@ -60,3 +60,12 @@ add_vpp_plugin(linux_cp_unittest
LINK_LIBRARIES
lcp
)
add_vpp_plugin(linux_nl
SOURCES
lcp_router.c
lcp_nl.c
LINK_LIBRARIES
lcp
)
+5 -6
View File
@@ -3,10 +3,10 @@ name: Linux Control Plane (integration)
maintainer: Neale Ranns <neale@grahpiant.com>
description: |-
This plugin provides the beginnings of an integration with the
Linux network stack.
The plugin provides the capability to 'mirror' VPP interfaces in
the Linux kernel. This means that for any interface in VPP the user
These plugins provide an integration with the Linux network stack.
The "linux_cp" plugin provides the capability to 'mirror' VPP interfaces
in the Linux kernel. This means that for any interface in VPP the user
can create a corresponding TAP or TUN device in the Linux kernel
and have VPP plumb them together.
The plumbing mechanics is different in each direction.
@@ -17,8 +17,7 @@ description: |-
In the TX direction, packets received by VPP an the mirror Tap/Tun
are cross-connected to the VPP interfaces. For IP packets, IP output
features are applied.
This is the beginnings of integration, because there needs to be
an external agent that will configure (and synchronize) the IP
The "linux_nl" plugin listens to netlink messages and synchronizes the IP
configuration of the paired interfaces.
state: experimental
+1 -4
View File
@@ -42,10 +42,7 @@ interfaces. Any configuration that is made on these Linux interfaces,
also needs to be applied on the corresponding physical interface in
VPP.
This is functionality is not provided in this plugin, but it can be
achieved in various ways, for example by listening to the netlink
messages and applying the config. As a result all e.g. routes
programmed in Linux, will also be present in VPP's FIB.
This is functionality is provided by the "linux_nl" plugin.
Linux will own the [ARP/ND] neighbor tables (which will be copied via
netlink to VPP also). This means that Linux will send packets with the
+3 -4
View File
@@ -175,7 +175,6 @@ vl_api_lcp_default_ns_set_t_handler (vl_api_lcp_default_ns_set_t *mp)
static void
vl_api_lcp_default_ns_get_t_handler (vl_api_lcp_default_ns_get_t *mp)
{
lcp_main_t *lcpm = &lcp_main;
vl_api_lcp_default_ns_get_reply_t *rmp;
vl_api_registration_t *reg;
char *ns;
@@ -186,7 +185,7 @@ vl_api_lcp_default_ns_get_t_handler (vl_api_lcp_default_ns_get_t *mp)
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = (VL_API_LCP_DEFAULT_NS_GET_REPLY + lcpm->msg_id_base);
rmp->_vl_msg_id = (VL_API_LCP_DEFAULT_NS_GET_REPLY);
rmp->context = mp->context;
ns = (char *) lcp_get_default_ns ();
@@ -226,7 +225,7 @@ vl_api_lcp_itf_pair_replace_end_t_handler (
#include <linux-cp/lcp.api.c>
static clib_error_t *
lcp_plugin_api_hookup (vlib_main_t *vm)
lcp_api_init (vlib_main_t *vm)
{
/* Ask for a correctly-sized block of API message decode slots */
lcp_msg_id_base = setup_message_id_table ();
@@ -234,7 +233,7 @@ lcp_plugin_api_hookup (vlib_main_t *vm)
return (NULL);
}
VLIB_INIT_FUNCTION (lcp_plugin_api_hookup);
VLIB_INIT_FUNCTION (lcp_api_init);
#include <vpp/app/version.h>
VLIB_PLUGIN_REGISTER () = {
+2 -2
View File
@@ -1159,7 +1159,7 @@ lcp_itf_pair_link_up_down (vnet_main_t *vnm, u32 hw_if_index, u32 flags)
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (lcp_itf_pair_link_up_down);
static clib_error_t *
lcp_itf_pair_init (vlib_main_t *vm)
lcp_interface_init (vlib_main_t *vm)
{
vlib_punt_hdl_t punt_hdl = vlib_punt_client_register ("linux-cp");
@@ -1178,7 +1178,7 @@ lcp_itf_pair_init (vlib_main_t *vm)
return NULL;
}
VLIB_INIT_FUNCTION (lcp_itf_pair_init) = {
VLIB_INIT_FUNCTION (lcp_interface_init) = {
.runs_after = VLIB_INITS ("vnet_interface_init", "tcp_init", "udp_init"),
};
File diff suppressed because it is too large Load Diff
+113
View File
@@ -0,0 +1,113 @@
/*
* Copyright (c) 2019 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <vlib/vlib.h>
#include <netlink/route/link.h>
#include <netlink/route/route.h>
#include <netlink/route/neighbour.h>
#include <netlink/route/addr.h>
typedef void (*nl_rt_link_cb_t) (struct rtnl_link *rl, void *ctx);
typedef void (*nl_rt_addr_cb_t) (struct rtnl_addr *ra);
typedef void (*nl_rt_neigh_cb_t) (struct rtnl_neigh *rr);
typedef void (*nl_rt_route_cb_t) (struct rtnl_route *rn);
#define NL_RT_COMMON uword is_mp_safe
typedef struct nl_rt_link_t_
{
NL_RT_COMMON;
nl_rt_link_cb_t cb;
} nl_rt_link_t;
typedef struct nl_rt_addr_t_
{
NL_RT_COMMON;
nl_rt_addr_cb_t cb;
} nl_rt_addr_t;
typedef struct nl_rt_neigh_t_
{
NL_RT_COMMON;
nl_rt_neigh_cb_t cb;
} nl_rt_neigh_t;
typedef struct nl_rt_route_t_
{
NL_RT_COMMON;
nl_rt_route_cb_t cb;
} nl_rt_route_t;
#undef NL_RT_COMMON
typedef struct nl_vft_t_
{
nl_rt_link_t nvl_rt_link_add;
nl_rt_link_t nvl_rt_link_del;
nl_rt_addr_t nvl_rt_addr_add;
nl_rt_addr_t nvl_rt_addr_del;
nl_rt_neigh_t nvl_rt_neigh_add;
nl_rt_neigh_t nvl_rt_neigh_del;
nl_rt_route_t nvl_rt_route_add;
nl_rt_route_t nvl_rt_route_del;
} nl_vft_t;
extern void nl_register_vft (const nl_vft_t *nv);
typedef enum lcp_nl_obj_t_
{
LCP_NL_LINK,
LCP_NL_ADDR,
LCP_NL_NEIGH,
LCP_NL_ROUTE,
} lcp_nl_obj_t;
/* struct type to hold context on the netlink message being processed.
*
* At creation of a pair, a tap/tun is created and configured to match its
* corresponding hardware interface (MAC address, link state, MTU). Netlink
* messages are sent announcing the creation and subsequent configuration.
* We do not need to (and should not) act on those messages since applying
* those same configurations again is unnecessary and can be disruptive. So
* a timestamp for a message is stored and can be compared against the time
* the interface came under linux-cp management in order to figure out
* whether we should apply any configuration.
*/
typedef struct nl_msg_info
{
struct nl_msg *msg;
f64 ts;
} nl_msg_info_t;
#define LCP_NL_N_OBJS (LCP_NL_ROUTE + 1)
extern struct nl_cache *lcp_nl_get_cache (lcp_nl_obj_t t);
extern int lcp_nl_drain_messages (void);
extern void lcp_nl_set_buffer_size (u32 buf_size);
extern void lcp_nl_set_batch_size (u32 batch_size);
extern void lcp_nl_set_batch_delay (u32 batch_delay_ms);
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
File diff suppressed because it is too large Load Diff