From f1d6b7e36e7e50c94ac180dcd594154b8c5812b4 Mon Sep 17 00:00:00 2001 From: Xiao Liang Date: Mon, 27 Sep 2021 10:23:37 +0800 Subject: [PATCH] staticd: Don't register existing nexthop to zebra Zebra sends a nexthop-update message on registeration, which will cause existing routes to be reconfigured even no changes actually happened. Don't register the nexthop again if it's already done. Signed-off-by: Xiao Liang --- staticd/static_zebra.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c index b75e1a1cdf..cdbd37b5d4 100644 --- a/staticd/static_zebra.c +++ b/staticd/static_zebra.c @@ -302,12 +302,14 @@ void static_zebra_nht_register(struct static_nexthop *nh, bool reg) static_nht_hash_alloc); nhtd->refcount++; - DEBUGD(&static_dbg_route, - "Registered nexthop(%pFX) for %pRN %d", &p, rn, - nhtd->nh_num); - if (nhtd->refcount > 1 && nhtd->nh_num) { - static_nht_update(&rn->p, nhtd->nh, nhtd->nh_num, afi, - nh->nh_vrf_id); + if (nhtd->refcount > 1) { + DEBUGD(&static_dbg_route, + "Already registered nexthop(%pFX) for %pRN %d", + &p, rn, nhtd->nh_num); + if (nhtd->nh_num) + static_nht_update(&rn->p, nhtd->nh, + nhtd->nh_num, afi, + nh->nh_vrf_id); return; } } else { @@ -323,6 +325,9 @@ void static_zebra_nht_register(struct static_nexthop *nh, bool reg) static_nht_hash_free(nhtd); } + DEBUGD(&static_dbg_route, "%s nexthop(%pFX) for %pRN", + reg ? "Registering" : "Unregistering", &p, rn); + if (zclient_send_rnh(zclient, cmd, &p, false, false, nh->nh_vrf_id) == ZCLIENT_SEND_FAILURE) zlog_warn("%s: Failure to send nexthop to zebra", __func__); -- 2.39.5