]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: fix wrong nexthop check
authoranlan_cs <anlan_cs@126.com>
Sat, 30 Nov 2024 13:11:04 +0000 (21:11 +0800)
committeranlan_cs <anlan_cs@126.com>
Tue, 17 Dec 2024 08:14:30 +0000 (16:14 +0800)
The kernel routes are wrongly selected even the nexthop interface is linkdown.

Use `ip link set dev <interface> 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 <anlan_cs@126.com>
zebra/zebra_nhg.c

index 1519246c179e4b25be3535087f912eefd94caa92..e61c158ca9f2c4a36184ec7fbdec0683db8460d2 100644 (file)
@@ -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;
                }