summaryrefslogtreecommitdiff
path: root/zebra/kernel_socket.c
diff options
context:
space:
mode:
authorFeng Lu <lu.feng@6wind.com>2014-07-03 18:23:09 +0800
committerVipin Kumar <vipin@cumulusnetworks.com>2015-10-30 01:45:21 -0700
commit8f7d9fc0883869bb32f67b4f70f017141d412ccb (patch)
tree0fcdf5979c2e3ebae576c3d14843827cc1c387a9 /zebra/kernel_socket.c
parentcd80d74fb275fe68247891d071075f450d4ec41c (diff)
zebra, lib/memtypes.c: the netlink sockets work per VRF
This patch lets the netlink sockets work per VRF. * The definition of "struct nlsock" is moved into zebra/rib.h. * The previous global variables "netlink" and "netlink_cmd" now become the members of "struct zebra_vrf", and are initialized in zebra_vrf_alloc(). * All relative functions now work for a specific VRF, by adding a new parameter which specifies the working VRF, except those functions in which the VRF ID can be obtained from the interface. * kernel_init(), interface_list() and route_read() are now also working per VRF, and moved from main() to zebra_vrf_enable(). * A new function kernel_terminate() is added to release the netlink sockets. It is called from zebra_vrf_disable(). * Correct VRF ID, instead of the previous VRF_DEFAULT, are now passed to the functions of processing interfaces or route entries. Signed-off-by: Feng Lu <lu.feng@6wind.com> Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> Conflicts: lib/memtypes.c zebra/rib.h zebra/rt_netlink.c Conflicts: zebra/if_netlink.c zebra/if_sysctl.c zebra/kernel_null.c zebra/rib.h zebra/rt_netlink.c zebra/rt_netlink.h
Diffstat (limited to 'zebra/kernel_socket.c')
-rw-r--r--zebra/kernel_socket.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index a1002a4d86..7b4f70fa83 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -38,6 +38,7 @@
#include "zebra/zserv.h"
#include "zebra/debug.h"
#include "zebra/kernel_socket.h"
+#include "zebra/rib.h"
extern struct zebra_privs_t zserv_privs;
extern struct zebra_t zebrad;
@@ -1262,8 +1263,11 @@ kernel_read (struct thread *thread)
/* Make routing socket. */
static void
-routing_socket (void)
+routing_socket (struct zebra_vrf *zvrf)
{
+ if (zvrf->vrf_id != VRF_DEFAULT)
+ return;
+
if ( zserv_privs.change (ZPRIVS_RAISE) )
zlog_err ("routing_socket: Can't raise privileges");
@@ -1294,7 +1298,13 @@ routing_socket (void)
/* Exported interface function. This function simply calls
routing_socket (). */
void
-kernel_init (void)
+kernel_init (struct zebra_vrf *zvrf)
+{
+ routing_socket (zvrf);
+}
+
+void
+kernel_terminate (struct zebra_vrf *zvrf)
{
- routing_socket ();
+ return;
}