From 1c491dfbe646f885b0a570666da3ba1e062c2a6c Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 11 Jan 2024 10:34:05 +0200 Subject: [PATCH] tests: Check if the route over eBGP is preferred when eBGP-OAD is used If at least one of the candidate routes was received via EBGP, remove from consideration all routes that were received via EBGP-OAD and IBGP. Signed-off-by: Donatas Abraitis --- tests/topotests/bgp_oad/r1/frr.conf | 10 ++++++++++ tests/topotests/bgp_oad/r2/frr.conf | 8 ++++---- tests/topotests/bgp_oad/r3/frr.conf | 2 +- tests/topotests/bgp_oad/r4/frr.conf | 16 ++++++++++++++++ tests/topotests/bgp_oad/r5/frr.conf | 17 +++++++++++++++++ tests/topotests/bgp_oad/test_bgp_oad.py | 18 ++++++++++++++++-- 6 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 tests/topotests/bgp_oad/r4/frr.conf create mode 100644 tests/topotests/bgp_oad/r5/frr.conf diff --git a/tests/topotests/bgp_oad/r1/frr.conf b/tests/topotests/bgp_oad/r1/frr.conf index 471c5ef52d..39045ba648 100644 --- a/tests/topotests/bgp_oad/r1/frr.conf +++ b/tests/topotests/bgp_oad/r1/frr.conf @@ -8,4 +8,14 @@ router bgp 65001 neighbor 192.168.1.2 timers 1 3 neighbor 192.168.1.2 timers connect 1 neighbor 192.168.1.2 oad + neighbor 192.168.1.4 remote-as external + neighbor 192.168.1.4 timers 1 3 + neighbor 192.168.1.4 timers connect 1 + address-family ipv4 unicast + neighbor 192.168.1.4 route-map r4 in + exit-address-family ! +route-map r4 permit 10 + set local-preference 123 + set metric 123 +exit diff --git a/tests/topotests/bgp_oad/r2/frr.conf b/tests/topotests/bgp_oad/r2/frr.conf index c98b115896..fdd23f32b4 100644 --- a/tests/topotests/bgp_oad/r2/frr.conf +++ b/tests/topotests/bgp_oad/r2/frr.conf @@ -11,8 +11,8 @@ router bgp 65002 neighbor 192.168.1.1 timers 1 3 neighbor 192.168.1.1 timers connect 1 neighbor 192.168.1.1 oad - neighbor 192.168.2.1 remote-as external - neighbor 192.168.2.1 timers 1 3 - neighbor 192.168.2.1 timers connect 1 - neighbor 192.168.2.1 oad + neighbor 192.168.2.3 remote-as external + neighbor 192.168.2.3 timers 1 3 + neighbor 192.168.2.3 timers connect 1 + neighbor 192.168.2.3 oad ! diff --git a/tests/topotests/bgp_oad/r3/frr.conf b/tests/topotests/bgp_oad/r3/frr.conf index 875079a4f9..02dd5adfe1 100644 --- a/tests/topotests/bgp_oad/r3/frr.conf +++ b/tests/topotests/bgp_oad/r3/frr.conf @@ -3,7 +3,7 @@ int lo ip address 10.10.10.10/32 ! int r3-eth0 - ip address 192.168.2.1/24 + ip address 192.168.2.3/24 ! router bgp 65003 no bgp ebgp-requires-policy diff --git a/tests/topotests/bgp_oad/r4/frr.conf b/tests/topotests/bgp_oad/r4/frr.conf new file mode 100644 index 0000000000..83dcf391b7 --- /dev/null +++ b/tests/topotests/bgp_oad/r4/frr.conf @@ -0,0 +1,16 @@ +! +int r4-eth0 + ip address 192.168.1.4/24 +! +int r4-eth1 + ip address 192.168.4.4/24 +! +router bgp 65004 + no bgp ebgp-requires-policy + neighbor 192.168.1.1 remote-as external + neighbor 192.168.1.1 timers 1 3 + neighbor 192.168.1.1 timers connect 1 + neighbor 192.168.4.5 remote-as external + neighbor 192.168.4.5 timers 1 3 + neighbor 192.168.4.5 timers connect 1 +! diff --git a/tests/topotests/bgp_oad/r5/frr.conf b/tests/topotests/bgp_oad/r5/frr.conf new file mode 100644 index 0000000000..f8e1609d15 --- /dev/null +++ b/tests/topotests/bgp_oad/r5/frr.conf @@ -0,0 +1,17 @@ +! +int lo + ip address 10.10.10.10/32 +! +int r5-eth0 + ip address 192.168.4.5/24 +! +router bgp 65005 + no bgp ebgp-requires-policy + neighbor 192.168.4.4 remote-as external + neighbor 192.168.4.4 timers 1 3 + neighbor 192.168.4.4 timers connect 1 + ! + address-family ipv4 unicast + redistribute connected + exit-address-family +! diff --git a/tests/topotests/bgp_oad/test_bgp_oad.py b/tests/topotests/bgp_oad/test_bgp_oad.py index a2e3eddc26..b26c548357 100644 --- a/tests/topotests/bgp_oad/test_bgp_oad.py +++ b/tests/topotests/bgp_oad/test_bgp_oad.py @@ -31,7 +31,7 @@ pytestmark = [pytest.mark.bgpd] def setup_module(mod): - topodef = {"s1": ("r1", "r2"), "s2": ("r2", "r3")} + topodef = {"s1": ("r1", "r2", "r4"), "s2": ("r2", "r3"), "s3": ("r4", "r5")} tgen = Topogen(topodef, mod.__name__) tgen.start_topology() @@ -64,7 +64,21 @@ def test_bgp_dynamic_capability_role(): "aspath": {"string": "65002 65003"}, "metric": 123, "locPrf": 123, - } + "peer": { + "hostname": "r2", + "type": "external (oad)", + }, + }, + { + "aspath": {"string": "65004 65005"}, + "metric": 123, + "locPrf": 123, + "bestpath": {"selectionReason": "Peer Type"}, + "peer": { + "hostname": "r4", + "type": "external", + }, + }, ] } return topotest.json_cmp(output, expected) -- 2.39.5