diff options
author | Don Slice <dslice@cumulusnetworks.com> | 2016-02-15 19:36:57 +0100 |
---|---|---|
committer | Don Slice <dslice@cumulusnetworks.com> | 2016-02-15 19:36:57 +0100 |
commit | be08f6780bb7793874aff96923c1015018ca650b (patch) | |
tree | ac65bf2605425609b3b9ac8128c715785fca695b /zebra/rt_netlink.c | |
parent | BGP: VRF registration and cleanup (diff) | |
download | frr-be08f6780bb7793874aff96923c1015018ca650b.tar.xz frr-be08f6780bb7793874aff96923c1015018ca650b.zip |
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:
Diffstat (limited to 'zebra/rt_netlink.c')
-rw-r--r-- | zebra/rt_netlink.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index ddfcfd9e9..54652b853 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; |