summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ns.c6
-rw-r--r--lib/vrf.c17
-rw-r--r--lib/vrf.h6
3 files changed, 27 insertions, 2 deletions
diff --git a/lib/ns.c b/lib/ns.c
index 0b2a3bec7..e3a1d9d0d 100644
--- a/lib/ns.c
+++ b/lib/ns.c
@@ -378,7 +378,9 @@ static int ns_config_write(struct vty *vty)
struct ns *ns;
int write = 0;
- RB_FOREACH (ns, ns_head, &ns_tree) {
+ if (vrf_is_backend_netns())
+ return 0;
+ RB_FOREACH(ns, ns_head, &ns_tree) {
if (ns->ns_id == NS_DEFAULT || ns->name == NULL)
continue;
@@ -411,7 +413,7 @@ void ns_init(void)
exit(1);
}
- if (have_netns()) {
+ if (have_netns() && !vrf_is_backend_netns()) {
/* Install NS commands. */
install_node(&ns_node, ns_config_write);
install_element(CONFIG_NODE, &ns_netns_cmd);
diff --git a/lib/vrf.c b/lib/vrf.c
index 02946df2b..c300a87a3 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -44,6 +44,8 @@ RB_GENERATE(vrf_name_head, vrf, name_entry, vrf_name_compare);
struct vrf_id_head vrfs_by_id = RB_INITIALIZER(&vrfs_by_id);
struct vrf_name_head vrfs_by_name = RB_INITIALIZER(&vrfs_by_name);
+static int vrf_backend;
+
/*
* Turn on/off debug code
* for vrf.
@@ -446,6 +448,21 @@ int vrf_socket(int domain, int type, int protocol, vrf_id_t vrf_id)
return ret;
}
+int vrf_is_backend_netns(void)
+{
+ return (vrf_backend == VRF_BACKEND_NETNS);
+}
+
+int vrf_get_backend(void)
+{
+ return vrf_backend;
+}
+
+void vrf_configure_backend(int vrf_backend_netns)
+{
+ vrf_backend = vrf_backend_netns;
+}
+
/* vrf CLI commands */
DEFUN_NOSH (vrf,
vrf_cmd,
diff --git a/lib/vrf.h b/lib/vrf.h
index 99c048c70..f1dc45019 100644
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -96,6 +96,9 @@ RB_HEAD(vrf_name_head, vrf);
RB_PROTOTYPE(vrf_name_head, vrf, name_entry, vrf_name_compare)
DECLARE_QOBJ_TYPE(vrf)
+/* Allow VRF with netns as backend */
+#define VRF_BACKEND_VRF_LITE 0
+#define VRF_BACKEND_NETNS 1
extern struct vrf_id_head vrfs_by_id;
extern struct vrf_name_head vrfs_by_name;
@@ -203,6 +206,9 @@ extern void vrf_cmd_init(int (*writefunc)(struct vty *vty));
/* Create a socket serving for the given VRF */
extern int vrf_socket(int, int, int, vrf_id_t);
+extern void vrf_configure_backend(int vrf_backend_netns);
+extern int vrf_get_backend(void);
+extern int vrf_is_backend_netns(void);
/*
* VRF Debugging