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>
diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c
index fc384ea..3f33f74 100644
--- a/zebra/if_ioctl_solaris.c
+++ b/zebra/if_ioctl_solaris.c
@@ -30,8 +30,10 @@
 #include "memory.h"
 #include "log.h"
 #include "privs.h"
+#include "vrf.h"
 
 #include "zebra/interface.h"
+#include "zebra/rib.h"
 
 void lifreq_set_name (struct lifreq *, const char *);
 int if_get_flags_direct (const char *, uint64_t *, unsigned int af);
@@ -349,8 +351,13 @@
 
 /* Lookup all interface information. */
 void
-interface_list ()
+interface_list (struct zebra_vrf *zvrf)
 {
+  if (zvrf->vrf_id != VRF_DEFAULT)
+    {
+      zlog_warn ("interface_list: ignore VRF %u", zvrf->vrf_id);
+      return;
+    }
   interface_list_ioctl (AF_INET);
   interface_list_ioctl (AF_INET6);
   interface_list_ioctl (AF_UNSPEC);