From ecffe9167b1debd0c7e3a632e5b1a5e834bb4ebe Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 29 Apr 2021 11:58:15 +0200 Subject: [PATCH 1/2] zebra: add the link interface information on interface updates There are cases where either link information is not present at interface creation or link information changed. handle this situation. Signed-off-by: Philippe.Guibert zebra dd link --- zebra/if_netlink.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 6aaf9d94f3..e6e86feb45 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -1550,6 +1550,9 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) memcpy(old_hw_addr, ifp->hw_addr, INTERFACE_HWADDR_MAX); + /* Update link. */ + zebra_if_update_link(ifp, link_ifindex, ns_id); + netlink_interface_update_hw_addr(tb, ifp); if (if_is_no_ptm_operative(ifp)) { From 357b150daec44c3309391cae921f0a284d171b43 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Thu, 29 Apr 2021 12:02:47 +0200 Subject: [PATCH 2/2] zebra: at startup, fix links on all namespaces when zebra has vrf backend mapped to namespaces, the polling of interfaces leads to fix all linkages of interfaces. This was not done on non default namespace. do it for other namespaces. Signed-off-by: Philippe Guibert --- zebra/if_netlink.c | 2 +- zebra/interface.c | 10 ++++------ zebra/interface.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index e6e86feb45..e7d8b318e0 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -974,7 +974,7 @@ int interface_lookup_netlink(struct zebra_ns *zns) return ret; /* fixup linkages */ - zebra_if_update_all_links(); + zebra_if_update_all_links(zns); return 0; } diff --git a/zebra/interface.c b/zebra/interface.c index 4b708496a1..a3134d6647 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1148,18 +1148,16 @@ void zebra_if_update_link(struct interface *ifp, ifindex_t link_ifindex, * during initial link dump kernel does not order lower devices before * upper devices so we need to fixup link dependencies at the end of dump */ -void zebra_if_update_all_links(void) +void zebra_if_update_all_links(struct zebra_ns *zns) { struct route_node *rn; struct interface *ifp; struct zebra_if *zif; - struct zebra_ns *ns; if (IS_ZEBRA_DEBUG_KERNEL) zlog_info("fixup link dependencies"); - ns = zebra_ns_lookup(NS_DEFAULT); - for (rn = route_top(ns->if_table); rn; rn = route_next(rn)) { + for (rn = route_top(zns->if_table); rn; rn = route_next(rn)) { ifp = (struct interface *)rn->info; if (!ifp) continue; @@ -1177,8 +1175,8 @@ void zebra_if_update_all_links(void) /* update SVI linkages */ if ((zif->link_ifindex != IFINDEX_INTERNAL) && !zif->link) { - zif->link = if_lookup_by_index_per_ns(ns, - zif->link_ifindex); + zif->link = if_lookup_by_index_per_ns( + zns, zif->link_ifindex); if (IS_ZEBRA_DEBUG_KERNEL) zlog_debug("interface %s/%d's lower fixup to %s/%d", ifp->name, ifp->ifindex, diff --git a/zebra/interface.h b/zebra/interface.h index 67eb1176b9..24bc70cb9b 100644 --- a/zebra/interface.h +++ b/zebra/interface.h @@ -482,7 +482,7 @@ extern int ipv6_address_configured(struct interface *ifp); extern void if_handle_vrf_change(struct interface *ifp, vrf_id_t vrf_id); extern void zebra_if_update_link(struct interface *ifp, ifindex_t link_ifindex, ns_id_t ns_id); -extern void zebra_if_update_all_links(void); +extern void zebra_if_update_all_links(struct zebra_ns *zns); extern void zebra_if_set_protodown(struct interface *ifp, bool down); extern int if_ip_address_install(struct interface *ifp, struct prefix *prefix, const char *label, struct prefix *pp);