]> git.proxmox.com Git - mirror_frr.git/commitdiff
staticd: Don't register existing nexthop to zebra
authorXiao Liang <shaw.leon@gmail.com>
Mon, 27 Sep 2021 02:23:37 +0000 (10:23 +0800)
committerXiao Liang <shaw.leon@gmail.com>
Mon, 28 Feb 2022 10:08:49 +0000 (18:08 +0800)
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 <shaw.leon@gmail.com>
staticd/static_zebra.c

index b75e1a1cdf6779fa46ece03e9c385e81000ac241..cdbd37b5d4c21c8e508cf133143d9f9a8059f1c3 100644 (file)
@@ -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__);