staticd: add a separate function for uninstalling nexthops

Will be used in the following commit.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
This commit is contained in:
Igor Ryzhov 2024-02-03 21:38:12 +02:00
parent 0d9127bca1
commit 6090b2b939
2 changed files with 13 additions and 10 deletions

View File

@ -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) void static_delete_nexthop(struct static_nexthop *nh)
{ {
struct static_path *pn = nh->pn; struct static_path *pn = nh->pn;
@ -386,17 +397,8 @@ void static_delete_nexthop(struct static_nexthop *nh)
/* Remove BFD session/configuration if any. */ /* Remove BFD session/configuration if any. */
bfd_sess_free(&nh->bsp); bfd_sess_free(&nh->bsp);
if (nh->nh_vrf_id == VRF_UNKNOWN) static_uninstall_nexthop(nh);
goto EXIT;
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); route_unlock_node(rn);
/* Free static route configuration. */ /* Free static route configuration. */
XFREE(MTYPE_STATIC_NEXTHOP, nh); XFREE(MTYPE_STATIC_NEXTHOP, nh);

View File

@ -207,6 +207,7 @@ static_add_nexthop(struct static_path *pn, enum static_nh_type type,
struct ipaddr *ipaddr, const char *ifname, struct ipaddr *ipaddr, const char *ifname,
const char *nh_vrf, uint32_t color); const char *nh_vrf, uint32_t color);
extern void static_install_nexthop(struct static_nexthop *nh); 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); extern void static_delete_nexthop(struct static_nexthop *nh);