From 6090b2b939cd01f1c9d44c14ebfa257795f06a1b Mon Sep 17 00:00:00 2001 From: Igor Ryzhov Date: Sat, 3 Feb 2024 21:38:12 +0200 Subject: [PATCH] staticd: add a separate function for uninstalling nexthops Will be used in the following commit. Signed-off-by: Igor Ryzhov --- staticd/static_routes.c | 22 ++++++++++++---------- staticd/static_routes.h | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/staticd/static_routes.c b/staticd/static_routes.c index db3fc32fd8..6c83c82c06 100644 --- a/staticd/static_routes.c +++ b/staticd/static_routes.c @@ -377,6 +377,17 @@ void static_install_nexthop(struct static_nexthop *nh) } } +void static_uninstall_nexthop(struct static_nexthop *nh) +{ + struct static_path *pn = nh->pn; + + if (nh->nh_vrf_id == VRF_UNKNOWN) + return; + + static_zebra_nht_register(nh, false); + static_uninstall_path(pn); +} + void static_delete_nexthop(struct static_nexthop *nh) { struct static_path *pn = nh->pn; @@ -386,17 +397,8 @@ void static_delete_nexthop(struct static_nexthop *nh) /* Remove BFD session/configuration if any. */ bfd_sess_free(&nh->bsp); - if (nh->nh_vrf_id == VRF_UNKNOWN) - goto EXIT; + static_uninstall_nexthop(nh); - static_zebra_nht_register(nh, false); - /* - * If we have other si nodes then route replace - * else delete the route - */ - static_uninstall_path(pn); - -EXIT: route_unlock_node(rn); /* Free static route configuration. */ XFREE(MTYPE_STATIC_NEXTHOP, nh); diff --git a/staticd/static_routes.h b/staticd/static_routes.h index d88ed29364..2e2e4986c3 100644 --- a/staticd/static_routes.h +++ b/staticd/static_routes.h @@ -207,6 +207,7 @@ static_add_nexthop(struct static_path *pn, enum static_nh_type type, struct ipaddr *ipaddr, const char *ifname, const char *nh_vrf, uint32_t color); extern void static_install_nexthop(struct static_nexthop *nh); +extern void static_uninstall_nexthop(struct static_nexthop *nh); extern void static_delete_nexthop(struct static_nexthop *nh);