From: sharpd Date: Thu, 11 Feb 2016 02:28:13 +0000 (-0800) Subject: zebra: All slave devices were being treated as vrfs X-Git-Tag: frr-2.0-rc1~1135 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b9590d4de4f5d819fa2df6fb7f2cf397e286217f;p=mirror%2Ffrr.git zebra: All slave devices were being treated as vrfs 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 --- diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 31d64c8829..ddfcfd9e95 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -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);