From: anlan_cs Date: Sat, 30 Nov 2024 13:11:04 +0000 (+0800) Subject: zebra: fix wrong nexthop check X-Git-Tag: base_10.3~148^2~3 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b9538fe481d1955090e41c04d86b2322362a83f5;p=matthieu%2Ffrr.git zebra: fix wrong nexthop check The kernel routes are wrongly selected even the nexthop interface is linkdown. Use `ip link set dev down` on the other box to set the box's nexthop interface linkdown. The kernel routes will be kept as `linkdown`, but are still with active nexthop in `zebra`. Add three changes/commits for kernel routes in this PR: 1) The active nexthop should be the operative interface. 2) Don't uninstall the kernel routes from `zebra` even no active nexthops. (It doesn't affect the kernel routes' deletion from kernel netlink messages.) 3) Update the kernel routes when the nexthop interface becomes up. Before: (during nexthop interface is linkdown) ``` K>* 3.3.3.3/32 [0/0] via 88.88.88.1, enp2s0, weight 1, 00:00:14 ``` After: (during nexthop interface is linkdown, with all three changes) ``` K 3.3.3.3/32 [0/0] via 88.88.88.1, enp2s0 inactive, weight 1, 00:00:07 ``` This commit is 1st change: Improve the judgment for "active" nexthop to be more accurate, the active nexthop should be the operative interface. Signed-off-by: anlan_cs --- diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 1519246c17..e61c158ca9 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -2648,7 +2648,7 @@ static unsigned nexthop_active_check(struct route_node *rn, ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id); - if (ifp && ifp->vrf->vrf_id == vrf_id && if_is_up(ifp)) { + if (ifp && ifp->vrf->vrf_id == vrf_id && if_is_up(ifp) && if_is_operative(ifp)) { SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE); goto skip_check; }