From 8b48cdb913d7c04ee215cc64f337feb6a68954e2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 2 Oct 2020 14:49:09 -0400 Subject: [PATCH] zebra: Prevent installation of connected multiple times With recent changes to interface up mechanics in if_netlink.c FRR was receiving as many as 4 up events for an interface on ifdown/ifup events. This was causing timing issues in FRR based upon some fun timings. Remove this from happening. Ticket: CM-31623 Signed-off-by: Donald Sharp --- zebra/if_netlink.c | 5 +++-- zebra/interface.c | 9 +++++---- zebra/interface.h | 2 +- zebra/zebra_ptm.c | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 42e55acb51..a75b165270 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -1920,6 +1920,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) } if (if_is_no_ptm_operative(ifp)) { + bool is_up = if_is_operative(ifp); ifp->flags = ifi->ifi_flags & 0x0000fffff; if (!if_is_no_ptm_operative(ifp) || CHECK_FLAG(zif->flags, @@ -1939,7 +1940,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) zlog_debug( "Intf %s(%u) PTM up, notifying clients", name, ifp->ifindex); - if_up(ifp); + if_up(ifp, !is_up); /* Update EVPN VNI when SVI MAC change */ @@ -1975,7 +1976,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) zlog_debug( "Intf %s(%u) has come UP", name, ifp->ifindex); - if_up(ifp); + if_up(ifp, true); if (IS_ZEBRA_IF_BRIDGE(ifp)) chgflags = ZEBRA_BRIDGE_MASTER_UP; diff --git a/zebra/interface.c b/zebra/interface.c index fbd2aac005..12c073144c 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -517,7 +517,7 @@ void if_flags_update(struct interface *ifp, uint64_t newflags) /* inoperative -> operative? */ ifp->flags = newflags; if (if_is_operative(ifp)) - if_up(ifp); + if_up(ifp, true); } } @@ -1045,7 +1045,7 @@ bool if_nhg_dependents_is_empty(const struct interface *ifp) } /* Interface is up. */ -void if_up(struct interface *ifp) +void if_up(struct interface *ifp, bool install_connected) { struct zebra_if *zif; struct interface *link_if; @@ -1077,7 +1077,8 @@ void if_up(struct interface *ifp) #endif /* Install connected routes to the kernel. */ - if_install_connected(ifp); + if (install_connected) + if_install_connected(ifp); /* Handle interface up for specific types for EVPN. Non-VxLAN interfaces * are checked to see if (remote) neighbor entries need to be installed @@ -2778,7 +2779,7 @@ int if_linkdetect(struct interface *ifp, bool detect) /* Interface may come up after disabling link detection */ if (if_is_operative(ifp) && !if_was_operative) - if_up(ifp); + if_up(ifp, true); } /* FIXME: Will defer status change forwarding if interface does not come down! */ diff --git a/zebra/interface.h b/zebra/interface.h index c19e494860..315a3170d8 100644 --- a/zebra/interface.h +++ b/zebra/interface.h @@ -486,7 +486,7 @@ extern void if_nbr_ipv6ll_to_ipv4ll_neigh_update(struct interface *ifp, extern void if_nbr_ipv6ll_to_ipv4ll_neigh_del_all(struct interface *ifp); extern void if_delete_update(struct interface *ifp); extern void if_add_update(struct interface *ifp); -extern void if_up(struct interface *); +extern void if_up(struct interface *ifp, bool install_connected); extern void if_down(struct interface *); extern void if_refresh(struct interface *); extern void if_flags_update(struct interface *, uint64_t); diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 68e5c391cf..c28e251e3a 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -350,7 +350,7 @@ DEFUN (no_zebra_ptm_enable_if, if (IS_ZEBRA_DEBUG_EVENT) zlog_debug("%s: Bringing up interface %s", __func__, ifp->name); - if_up(ifp); + if_up(ifp, true); } } @@ -553,7 +553,7 @@ static int zebra_ptm_handle_cbl_msg(void *arg, void *in_ctxt, ifp->ptm_status = ZEBRA_PTM_STATUS_UP; if (ifp->ptm_enable && if_is_no_ptm_operative(ifp) && send_linkup) - if_up(ifp); + if_up(ifp, true); } else if (!strcmp(cbl_str, ZEBRA_PTM_FAIL_STR) && (ifp->ptm_status != ZEBRA_PTM_STATUS_DOWN)) { ifp->ptm_status = ZEBRA_PTM_STATUS_DOWN; @@ -1163,7 +1163,7 @@ void zebra_ptm_reset_status(int ptm_disable) zlog_debug( "%s: Bringing up interface %s", __func__, ifp->name); - if_up(ifp); + if_up(ifp, true); } } } -- 2.39.5