From e7dce035abb000a9961d7ec7e4c384f150e4b2f6 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Fri, 11 Aug 2023 10:48:28 +0300 Subject: [PATCH] tests: Check if labeled IPv6 unicast default route works too Also, check if remote label is explicit null according to the AFI. Signed-off-by: Donatas Abraitis --- .../r1/bgpd.conf | 14 ++++++++++ .../r1/zebra.conf | 1 + .../r2/bgpd.conf | 8 ++++++ .../r2/zebra.conf | 1 + ...t_bgp_labeled_unicast_default_originate.py | 27 ++++++++++++++++--- 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/tests/topotests/bgp_labeled_unicast_default_originate/r1/bgpd.conf b/tests/topotests/bgp_labeled_unicast_default_originate/r1/bgpd.conf index 75a4aa6ab3..d0d13909a7 100644 --- a/tests/topotests/bgp_labeled_unicast_default_originate/r1/bgpd.conf +++ b/tests/topotests/bgp_labeled_unicast_default_originate/r1/bgpd.conf @@ -1,18 +1,32 @@ ! router bgp 65001 no bgp default ipv4-unicast + no bgp default ipv6-unicast no bgp ebgp-requires-policy neighbor 192.168.12.2 remote-as external neighbor 192.168.12.2 timers 1 3 neighbor 192.168.12.2 timers connect 1 + neighbor 2001:db8:12::2 remote-as external + neighbor 2001:db8:12::2 timers 1 3 + neighbor 2001:db8:12::2 timers connect 1 address-family ipv4 unicast redistribute connected exit-address-family + ! + address-family ipv6 unicast + redistribute connected + exit-address-family + ! address-family ipv4 labeled-unicast neighbor 192.168.12.2 activate neighbor 192.168.12.2 default-originate route-map r2 exit-address-family ! + address-family ipv6 labeled-unicast + neighbor 2001:db8:12::2 activate + neighbor 2001:db8:12::2 default-originate route-map r2 + exit-address-family + ! ! route-map r2 permit 10 set community 65001:65001 diff --git a/tests/topotests/bgp_labeled_unicast_default_originate/r1/zebra.conf b/tests/topotests/bgp_labeled_unicast_default_originate/r1/zebra.conf index 8eab7805df..686b0755c3 100644 --- a/tests/topotests/bgp_labeled_unicast_default_originate/r1/zebra.conf +++ b/tests/topotests/bgp_labeled_unicast_default_originate/r1/zebra.conf @@ -1,4 +1,5 @@ ! interface r1-eth0 ip address 192.168.12.1/24 + ipv6 address 2001:db8:12::1/64 ! diff --git a/tests/topotests/bgp_labeled_unicast_default_originate/r2/bgpd.conf b/tests/topotests/bgp_labeled_unicast_default_originate/r2/bgpd.conf index c81ba9fe02..1498dffc93 100644 --- a/tests/topotests/bgp_labeled_unicast_default_originate/r2/bgpd.conf +++ b/tests/topotests/bgp_labeled_unicast_default_originate/r2/bgpd.conf @@ -2,10 +2,18 @@ router bgp 65002 no bgp ebgp-requires-policy no bgp default ipv4-unicast + no bgp default ipv6-unicast neighbor 192.168.12.1 remote-as external neighbor 192.168.12.1 timers 1 3 neighbor 192.168.12.1 timers connect 1 + neighbor 2001:db8:12::1 remote-as external + neighbor 2001:db8:12::1 timers 1 3 + neighbor 2001:db8:12::1 timers connect 1 address-family ipv4 labeled-unicast neighbor 192.168.12.1 activate exit-address-family + ! + address-family ipv6 labeled-unicast + neighbor 2001:db8:12::1 activate + exit-address-family ! diff --git a/tests/topotests/bgp_labeled_unicast_default_originate/r2/zebra.conf b/tests/topotests/bgp_labeled_unicast_default_originate/r2/zebra.conf index d7dfd899cc..cb5c55ef0f 100644 --- a/tests/topotests/bgp_labeled_unicast_default_originate/r2/zebra.conf +++ b/tests/topotests/bgp_labeled_unicast_default_originate/r2/zebra.conf @@ -1,4 +1,5 @@ ! interface r2-eth0 ip address 192.168.12.2/24 + ipv6 address 2001:db8:12::2/64 ! diff --git a/tests/topotests/bgp_labeled_unicast_default_originate/test_bgp_labeled_unicast_default_originate.py b/tests/topotests/bgp_labeled_unicast_default_originate/test_bgp_labeled_unicast_default_originate.py index c3ccefb569..34c23d9b6f 100644 --- a/tests/topotests/bgp_labeled_unicast_default_originate/test_bgp_labeled_unicast_default_originate.py +++ b/tests/topotests/bgp_labeled_unicast_default_originate/test_bgp_labeled_unicast_default_originate.py @@ -82,7 +82,7 @@ def test_bgp_labeled_unicast_default_originate(): _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) assert result is None, "Failed to advertise default route for labeled-unicast" - def _bgp_check_received_routes(): + def _bgp_check_received_ipv4_routes(): output = json.loads( r2.vtysh_cmd("show bgp ipv4 labeled-unicast 0.0.0.0/0 json") ) @@ -94,14 +94,35 @@ def test_bgp_labeled_unicast_default_originate(): "community": { "string": "65001:65001", }, + "remoteLabel": 0, } ] } return topotest.json_cmp(output, expected) - test_func = functools.partial(_bgp_check_received_routes) + test_func = functools.partial(_bgp_check_received_ipv4_routes) _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) - assert result is None, "Failed to receive default route for labeled-unicast" + assert result is None, "Failed to receive IPv4 default route for labeled-unicast" + + def _bgp_check_received_ipv6_routes(): + output = json.loads(r2.vtysh_cmd("show bgp ipv6 labeled-unicast ::/0 json")) + expected = { + "paths": [ + { + "valid": True, + "metric": 666, + "community": { + "string": "65001:65001", + }, + "remoteLabel": 2, + } + ] + } + return topotest.json_cmp(output, expected) + + test_func = functools.partial(_bgp_check_received_ipv6_routes) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) + assert result is None, "Failed to receive IPv6 default route for labeled-unicast" if __name__ == "__main__":