]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: set vrf-id on vrf slave interfaces
authorDon Slice <dslice@cumulusnetworks.com>
Mon, 15 Feb 2016 18:36:57 +0000 (18:36 +0000)
committerDon Slice <dslice@cumulusnetworks.com>
Mon, 15 Feb 2016 18:36:57 +0000 (18:36 +0000)
vrf: check netlink message for slave info and set the vrf-id accoringly

When a netlink newlink or link change comes into zebra, check the IFLA_INFO_SLAVE_KIND
to discover if the interface is a member of a vrf or not.  Set the vrf-id to the correct
value if the interface is a slave member

Signed-off-by: Don Sice
Reviewed-by:

zebra/rt_netlink.c

index ddfcfd9e956d679e516d61c6d2a1efc2bb3f4a09..54652b853171908f76eae1489e02266a449ed4f5 100644 (file)
@@ -599,9 +599,11 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h,
   int len;
   struct ifinfomsg *ifi;
   struct rtattr *tb[IFLA_MAX + 1];
+  struct rtattr *linkinfo[IFLA_MAX + 1];
   struct interface *ifp;
   char *name = NULL;
   char *kind = NULL;
+  char *slave_kind = NULL;
 
   ifi = NLMSG_DATA (h);
 
@@ -636,6 +638,10 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h,
   if (tb[IFLA_LINKINFO])
     {
       kind = parse_link_kind(tb[IFLA_LINKINFO]);
+      parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb[IFLA_LINKINFO]);
+
+      if (linkinfo[IFLA_INFO_SLAVE_KIND])
+         slave_kind = RTA_DATA(linkinfo[IFLA_INFO_SLAVE_KIND]);
 
       if (kind && strcmp(kind, "vrf") == 0)
         {
@@ -646,7 +652,8 @@ netlink_interface (struct sockaddr_nl *snl, struct nlmsghdr *h,
 
   if (tb[IFLA_MASTER])
     {
-      if (kind && strcmp(kind, "vrf") == 0)
+      if ((kind && strcmp(kind, "vrf") == 0) ||
+          (slave_kind && strcmp(slave_kind, "vrf") == 0))
         vrf_id = *(u_int32_t *)RTA_DATA(tb[IFLA_MASTER]);
       else
        vrf_id = VRF_DEFAULT;
@@ -1209,9 +1216,11 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
   int len;
   struct ifinfomsg *ifi;
   struct rtattr *tb[IFLA_MAX + 1];
+  struct rtattr *linkinfo[IFLA_MAX + 1];
   struct interface *ifp;
   char *name = NULL;
   char *kind = NULL;
+  char *slave_kind = NULL;
   struct connected *ifc;
   struct listnode *node;
 
@@ -1256,6 +1265,10 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
   if (tb[IFLA_LINKINFO])
     {
       kind = parse_link_kind(tb[IFLA_LINKINFO]);
+      parse_rtattr_nested(linkinfo, IFLA_INFO_MAX, tb[IFLA_LINKINFO]);
+
+      if (linkinfo[IFLA_INFO_SLAVE_KIND])
+          slave_kind = RTA_DATA(linkinfo[IFLA_INFO_SLAVE_KIND]);
 
       if (kind && strcmp(kind, "vrf") == 0)
         {
@@ -1269,7 +1282,8 @@ netlink_link_change (struct sockaddr_nl *snl, struct nlmsghdr *h,
     {
       if (tb[IFLA_MASTER])
        {
-         if (kind && strcmp (kind, "vrf") == 0)
+          if ((kind && strcmp(kind, "vrf") == 0) ||
+              (slave_kind && strcmp(slave_kind, "vrf") == 0))
             vrf_id = *(u_int32_t *)RTA_DATA(tb[IFLA_MASTER]);
          else
            vrf_id = VRF_DEFAULT;