diff --git a/tests/topotests/zebra_multiple_connected/r1/ip_route2.json b/tests/topotests/zebra_multiple_connected/r1/ip_route2.json new file mode 100644 index 0000000000..26995654f7 --- /dev/null +++ b/tests/topotests/zebra_multiple_connected/r1/ip_route2.json @@ -0,0 +1,102 @@ +{ + "10.0.1.0/24":[ + { + "prefix":"10.0.1.0/24", + "prefixLen":24, + "protocol":"connected", + "vrfName":"default", + "distance":0, + "metric":0, + "installed":true, + "table":254, + "nexthops":[ + { + "fib":true, + "directlyConnected":true, + "interfaceName":"r1-eth1", + "active":true + } + ] + }, + { + "prefix":"10.0.1.0/24", + "prefixLen":24, + "protocol":"connected", + "vrfName":"default", + "distance":0, + "metric":0, + "installed":true, + "table":254, + "nexthops":[ + { + "fib":true, + "directlyConnected":true, + "interfaceName":"r1-eth0", + "active":true + } + ] + } + ], + "10.0.1.30/32":[ + { + "prefix":"10.0.1.30/32", + "prefixLen":32, + "protocol":"kernel", + "vrfName":"default", + "distance":0, + "metric":0, + "installed":true, + "table":254, + "nexthops":[ + { + "fib":true, + "directlyConnected":true, + "interfaceName":"r1-eth1", + "active":true + } + ] + } + ], + "10.9.9.0/24":[ + { + "prefix":"10.9.9.0/24", + "prefixLen":24, + "protocol":"kernel", + "vrfName":"default", + "distance":0, + "metric":0, + "installed":true, + "table":254, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.30", + "afi":"ipv4", + "interfaceName":"r1-eth1", + "active":true + } + ] + } + ], + "192.168.1.1/32":[ + { + "prefix":"192.168.1.1/32", + "prefixLen":32, + "protocol":"kernel", + "vrfName":"default", + "distance":0, + "metric":0, + "installed":true, + "table":254, + "nexthops":[ + { + "fib":true, + "ip":"10.0.1.99", + "afi":"ipv4", + "interfaceName":"r1-eth1", + "active":true + } + ] + } + ] +} diff --git a/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py b/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py index 31ac831b35..8882cf5bda 100644 --- a/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py +++ b/tests/topotests/zebra_multiple_connected/test_zebra_multiple_connected.py @@ -133,6 +133,30 @@ def test_zebra_connected_multiple(): assert result is None, "Kernel route is missing from zebra" +def test_zebra_system_recursion(): + "Test a system route recursing through another system route" + + tgen = get_topogen() + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + router = tgen.gears["r1"] + router.run("ip route add 10.0.1.30/32 dev r1-eth1") + router.run("ip route add 10.9.9.0/24 via 10.0.1.30 dev r1-eth1") + router.run("ip link add dummy2 type dummy") + router.run("ip link set dummy2 up") + router.run("ip link set dummy2 down") + + routes = "{}/{}/ip_route2.json".format(CWD, router.name) + expected = json.loads(open(routes).read()) + test_func = partial( + topotest.router_json_cmp, router, "show ip route json", expected + ) + + _, result = topotest.run_and_expect(test_func, None, count=20, wait=1) + assert result is None, "Kernel route is missing from zebra" + + if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args)) diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 02894632ea..d1a34d0962 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -2265,7 +2265,8 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe, continue; } - if (match->type == ZEBRA_ROUTE_CONNECT) { + if ((match->type == ZEBRA_ROUTE_CONNECT) || + (RIB_SYSTEM_ROUTE(match) && RSYSTEM_ROUTE(type))) { match = zebra_nhg_connected_ifindex(rn, match, nexthop->ifindex);