neighbor 192.168.34.4 remote-as external
neighbor 192.168.34.4 timers 1 3
neighbor 192.168.34.4 timers connect 1
+ neighbor 192.168.35.5 remote-as external
+ neighbor 192.168.35.5 timers 1 3
+ neighbor 192.168.35.5 timers connect 1
+ neighbor 192.168.35.5 shutdown
address-family ipv4 labeled-unicast
neighbor 192.168.31.1 activate
neighbor 192.168.32.2 activate
+ neighbor 192.168.35.5 activate
neighbor 192.168.34.4 activate
neighbor 192.168.34.4 route-map r4 out
neighbor 192.168.34.4 addpath-tx-all-paths
"""
Check if labeled-unicast works correctly with addpath capability.
+Initially R3 MUST announce 10.0.0.1/32 multipath(2) from R1 + R2.
+Later, we enable R5 and 10.0.0.1/32 multipath(3) MUST be announced,
+R1 + R2 + R5.
"""
import os
def build_topo(tgen):
- for routern in range(1, 5):
+ for routern in range(1, 6):
tgen.add_router("r{}".format(routern))
switch = tgen.add_switch("s1")
switch.add_link(tgen.gears["r3"])
switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s4")
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r5"])
+
def setup_module(mod):
tgen = Topogen(build_topo, mod.__name__)
r3 = tgen.gears["r3"]
r4 = tgen.gears["r4"]
- def _bgp_check_advertised_routes():
+ def _bgp_check_advertised_routes(prefix_num):
output = json.loads(
r3.vtysh_cmd(
"show bgp ipv4 labeled-unicast neighbors 192.168.34.4 advertised-routes json"
}
}
},
- "totalPrefixCounter": 2,
+ "totalPrefixCounter": prefix_num,
}
return topotest.json_cmp(output, expected)
- test_func = functools.partial(_bgp_check_advertised_routes)
+ test_func = functools.partial(_bgp_check_advertised_routes, 2)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert (
result is None
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert result is None, "Failed to receive labeled-unicast with addpath (multipath)"
+ step("Enable BGP session for R5")
+ r3.vtysh_cmd(
+ """
+ configure terminal
+ router bgp 65003
+ no neighbor 192.168.35.5 shutdown
+ """
+ )
+
+ test_func = functools.partial(_bgp_check_advertised_routes, 3)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ assert (
+ result is None
+ ), "Failed to advertise labeled-unicast with addpath (multipath)"
+
+ step("Disable BGP session for R5")
+ r3.vtysh_cmd(
+ """
+ configure terminal
+ router bgp 65003
+ neighbor 192.168.35.5 shutdown
+ """
+ )
+
+ test_func = functools.partial(_bgp_check_advertised_routes, 2)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ assert (
+ result is None
+ ), "Failed to advertise labeled-unicast with addpath (multipath)"
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]