From: Don Slice Date: Mon, 15 Feb 2016 18:36:57 +0000 (+0000) Subject: zebra: set vrf-id on vrf slave interfaces X-Git-Tag: frr-2.0-rc1~1124^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=be08f6780bb7793874aff96923c1015018ca650b;p=matthieu%2Ffrr.git zebra: set vrf-id on vrf slave interfaces 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: --- diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index ddfcfd9e95..54652b8531 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -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;