]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: All slave devices were being treated as vrfs
authorsharpd <sharpd@cumulusnetworks.com>
Thu, 11 Feb 2016 02:28:13 +0000 (18:28 -0800)
committersharpd <sharpd@cumulusnetworks.com>
Thu, 11 Feb 2016 02:41:59 +0000 (18:41 -0800)
When a slave device is received via netlink, all the
devices were being treated as vrf's instead of the
myriad of slave devices that are possible.

Add code to check to see if the device is truly a vrf slave
or not.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/rt_netlink.c

index 31d64c8829312841b497939dfe1d43563a37b250..ddfcfd9e956d679e516d61c6d2a1efc2bb3f4a09 100644 (file)
@@ -600,7 +600,8 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h,
   struct ifinfomsg *ifi;
   struct rtattr *tb[IFLA_MAX + 1];
   struct interface *ifp;
-  char *name;
+  char *name = NULL;
+  char *kind = NULL;
 
   ifi = NLMSG_DATA (h);
 
@@ -634,7 +635,7 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h,
 
   if (tb[IFLA_LINKINFO])
     {
-      char *kind = parse_link_kind(tb[IFLA_LINKINFO]);
+      kind = parse_link_kind(tb[IFLA_LINKINFO]);
 
       if (kind && strcmp(kind, "vrf") == 0)
         {
@@ -644,7 +645,12 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h,
     }
 
   if (tb[IFLA_MASTER])
-    vrf_id = *(u_int32_t *)RTA_DATA(tb[IFLA_MASTER]);
+    {
+      if (kind && strcmp(kind, "vrf") == 0)
+        vrf_id = *(u_int32_t *)RTA_DATA(tb[IFLA_MASTER]);
+      else
+       vrf_id = VRF_DEFAULT;
+    }
 
   /* Add interface. */
   ifp = if_get_by_name_vrf (name, vrf_id);
@@ -1204,7 +1210,8 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
   struct ifinfomsg *ifi;
   struct rtattr *tb[IFLA_MAX + 1];
   struct interface *ifp;
-  char *name;
+  char *name = NULL;
+  char *kind = NULL;
   struct connected *ifc;
   struct listnode *node;
 
@@ -1248,7 +1255,7 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
 
   if (tb[IFLA_LINKINFO])
     {
-      char *kind = parse_link_kind(tb[IFLA_LINKINFO]);
+      kind = parse_link_kind(tb[IFLA_LINKINFO]);
 
       if (kind && strcmp(kind, "vrf") == 0)
         {
@@ -1261,7 +1268,12 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
   if (h->nlmsg_type == RTM_NEWLINK)
     {
       if (tb[IFLA_MASTER])
-        vrf_id = *(u_int32_t *)RTA_DATA(tb[IFLA_MASTER]);
+       {
+         if (kind && strcmp (kind, "vrf") == 0)
+            vrf_id = *(u_int32_t *)RTA_DATA(tb[IFLA_MASTER]);
+         else
+           vrf_id = VRF_DEFAULT;
+       }
 
       /* clean up any old ifps in a different VRF */
       ifp = if_lookup_by_index_per_ns (dzns, ifi->ifi_index);