Merge pull request #11001 from donaldsharp/system_route_recursion

zebra: Allow system routes to recurse through themselves
This commit is contained in:
Russ White 2022-04-18 09:47:47 -04:00 committed by GitHub
commit 1258cfcd8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 128 additions and 1 deletions

View File

@ -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
}
]
}
]
}

View File

@ -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))

View File

@ -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);