Skip to content

Commit

Permalink
zebra: update kernel routes with interface check
Browse files Browse the repository at this point in the history
Zebra NH check is wrong -- it does not update missing interface routes

Steps to reproduce:
```
ip link set dev eth0 up
ip -4 addr add 192.168.0.2/24 dev eth0
ip -4 route add default via 192.168.0.1
ip -4 addr flush dev eth0
```

Before
```
K>* 0.0.0.0/0 [0/0] via 192.168.0.1, eth0, 00:00:07
```

After
Route is removed from zebra
  • Loading branch information
Yaroslav Kholod committed Dec 18, 2024
1 parent 30467f8 commit 69bf312
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion zebra/zebra_nhg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2645,10 +2645,12 @@ static unsigned nexthop_active_check(struct route_node *rn,
*/
if (re->type == ZEBRA_ROUTE_KERNEL || re->type == ZEBRA_ROUTE_SYSTEM) {
struct interface *ifp;
int connected_if_count = 0;

ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id);
connected_if_count = connected_count_by_family(ifp->connected, AF_INET) + connected_count_by_family(ifp->connected, AF_INET6);

if (ifp && ifp->vrf->vrf_id == vrf_id && if_is_up(ifp)) {
if (ifp && ifp->vrf->vrf_id == vrf_id && if_is_up(ifp) && connected_if_count) {
SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE);
goto skip_check;
}
Expand Down

0 comments on commit 69bf312

Please sign in to comment.