Skip to content

Commit

Permalink
Merge pull request #17326 from anlancs/fix/zebra-no-ifp-down
Browse files Browse the repository at this point in the history
zebra: fix missing kernel routes
  • Loading branch information
riw777 authored Nov 5, 2024
2 parents 408decf + 0073a87 commit fe20f83
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"0.0.0.0/0":[
{
"prefix":"0.0.0.0/0",
"prefixLen":0,
"protocol":"kernel",
"vrfName":"default",
"selected":true,
"destSelected":true,
"distance":0,
"metric":0,
"installed":true,
"table":254,
"nexthops":[
{
"fib":true,
"unreachable":true,
"blackhole":true,
"active":true
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,27 @@ def test_zebra_kernel_route_add():
assert result, "Connected Route should have been added\n{}".format(_)


def test_zebra_kernel_route_blackhole_add():
"Test that a blackhole route is not affected by interface's link change"

tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)

router = tgen.gears["r1"]
router.run("ip route add blackhole default")
router.run("ip link set dev r1-eth1 down")

kernel = "{}/{}/ip_route_kernel_blackhole.json".format(CWD, router.name)
expected = json.loads(open(kernel).read())

test_func = partial(
topotest.router_json_cmp, router, "show ip route 0.0.0.0/0 json", expected
)
result, _ = topotest.run_and_expect(test_func, None, count=20, wait=1)
assert result, "Blackhole Route should have not been removed\n{}".format(_)


if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))
2 changes: 1 addition & 1 deletion zebra/zebra_rib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4555,7 +4555,7 @@ rib_update_handle_kernel_route_down_possibility(struct route_node *rn,
struct interface *ifp = if_lookup_by_index(nexthop->ifindex,
nexthop->vrf_id);

if (ifp && if_is_up(ifp)) {
if ((ifp && if_is_up(ifp)) || nexthop->type == NEXTHOP_TYPE_BLACKHOLE) {
alive = true;
break;
}
Expand Down

0 comments on commit fe20f83

Please sign in to comment.