forked from Mirror/frr
tests: Check if addpath with disabled RX flag is working correctly in RS setup
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
parent
eecfea9768
commit
4c79c560d1
0
tests/topotests/bgp_addpath_disable_rx/__init__.py
Normal file
0
tests/topotests/bgp_addpath_disable_rx/__init__.py
Normal file
38
tests/topotests/bgp_addpath_disable_rx/r1/frr.conf
Normal file
38
tests/topotests/bgp_addpath_disable_rx/r1/frr.conf
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
!
|
||||||
|
int r1-eth0
|
||||||
|
ip address 192.168.137.1/24
|
||||||
|
!
|
||||||
|
router bgp 65000
|
||||||
|
bgp router-id 192.168.137.1
|
||||||
|
no bgp ebgp-requires-policy
|
||||||
|
no bgp enforce-first
|
||||||
|
neighbor AS65100-V4 peer-group
|
||||||
|
neighbor AS65100-V4 remote-as 65100
|
||||||
|
neighbor AS65100-V4 timers 1 3
|
||||||
|
neighbor AS65200-V4 peer-group
|
||||||
|
neighbor AS65200-V4 remote-as 65200
|
||||||
|
neighbor AS65200-V4 timers 1 3
|
||||||
|
neighbor AS65600-V4 peer-group
|
||||||
|
neighbor AS65600-V4 remote-as 65600
|
||||||
|
neighbor AS65600-V4 timers 1 3
|
||||||
|
neighbor 192.168.137.100 peer-group AS65100-V4
|
||||||
|
neighbor 192.168.137.201 peer-group AS65200-V4
|
||||||
|
neighbor 192.168.137.202 peer-group AS65200-V4
|
||||||
|
neighbor 192.168.137.60 peer-group AS65600-V4
|
||||||
|
!
|
||||||
|
address-family ipv4 unicast
|
||||||
|
neighbor AS65100-V4 addpath-tx-bestpath-per-AS
|
||||||
|
neighbor AS65100-V4 route-server-client
|
||||||
|
neighbor AS65200-V4 addpath-tx-bestpath-per-AS
|
||||||
|
neighbor AS65200-V4 disable-addpath-rx
|
||||||
|
neighbor AS65200-V4 route-server-client
|
||||||
|
neighbor AS65600-V4 addpath-tx-bestpath-per-AS
|
||||||
|
neighbor AS65600-V4 disable-addpath-rx
|
||||||
|
neighbor AS65600-V4 route-server-client
|
||||||
|
neighbor 192.168.137.201 disable-addpath-rx
|
||||||
|
neighbor 192.168.137.202 disable-addpath-rx
|
||||||
|
neighbor 192.168.137.60 disable-addpath-rx
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
exit
|
||||||
|
!
|
19
tests/topotests/bgp_addpath_disable_rx/r2/frr.conf
Normal file
19
tests/topotests/bgp_addpath_disable_rx/r2/frr.conf
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
!
|
||||||
|
int r2-eth0
|
||||||
|
ip address 192.168.137.60/24
|
||||||
|
!
|
||||||
|
router bgp 65600
|
||||||
|
bgp router-id 192.168.137.60
|
||||||
|
no bgp ebgp-requires-policy
|
||||||
|
no bgp enforce-first-as
|
||||||
|
neighbor 192.168.137.1 remote-as 65000
|
||||||
|
!
|
||||||
|
address-family ipv4 unicast
|
||||||
|
neighbor 192.168.137.1 disable-addpath-rx
|
||||||
|
neighbor 192.168.137.1 prefix-list out out
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
exit
|
||||||
|
!
|
||||||
|
ip prefix-list out seq 100 deny any
|
||||||
|
!
|
20
tests/topotests/bgp_addpath_disable_rx/r3/frr.conf
Normal file
20
tests/topotests/bgp_addpath_disable_rx/r3/frr.conf
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
!
|
||||||
|
int r3-eth0
|
||||||
|
ip address 192.168.137.100/24
|
||||||
|
!
|
||||||
|
int r3-eth1
|
||||||
|
ip address 192.168.44.1/24
|
||||||
|
!
|
||||||
|
router bgp 65100
|
||||||
|
bgp router-id 192.168.137.100
|
||||||
|
no bgp ebgp-requires-policy
|
||||||
|
no bgp enforce-first
|
||||||
|
neighbor 192.168.44.44 remote-as 65444
|
||||||
|
neighbor 192.168.137.1 remote-as 65000
|
||||||
|
!
|
||||||
|
address-family ipv4 unicast
|
||||||
|
neighbor 192.168.44.44 disable-addpath-rx
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
exit
|
||||||
|
!
|
21
tests/topotests/bgp_addpath_disable_rx/r4/frr.conf
Normal file
21
tests/topotests/bgp_addpath_disable_rx/r4/frr.conf
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
!
|
||||||
|
int r4-eth0
|
||||||
|
ip address 192.168.137.201/24
|
||||||
|
!
|
||||||
|
int r4-eth1
|
||||||
|
ip address 192.168.54.21/24
|
||||||
|
!
|
||||||
|
router bgp 65200
|
||||||
|
bgp router-id 192.168.137.201
|
||||||
|
no bgp enforce-first
|
||||||
|
no bgp ebgp-requires-policy
|
||||||
|
neighbor 192.168.54.44 remote-as 65444
|
||||||
|
neighbor 192.168.137.1 remote-as 65000
|
||||||
|
!
|
||||||
|
address-family ipv4 unicast
|
||||||
|
neighbor 192.168.54.44 disable-addpath-rx
|
||||||
|
neighbor 192.168.137.1 disable-addpath-rx
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
exit
|
||||||
|
!
|
20
tests/topotests/bgp_addpath_disable_rx/r5/frr.conf
Normal file
20
tests/topotests/bgp_addpath_disable_rx/r5/frr.conf
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
int r5-eth0
|
||||||
|
ip address 192.168.137.202/24
|
||||||
|
!
|
||||||
|
int r5-eth1
|
||||||
|
ip address 192.168.54.22/24
|
||||||
|
!
|
||||||
|
router bgp 65200
|
||||||
|
bgp router-id 192.168.137.202
|
||||||
|
no bgp ebgp-requires-policy
|
||||||
|
no bgp enforce-first
|
||||||
|
neighbor 192.168.54.44 remote-as 65444
|
||||||
|
neighbor 192.168.137.1 remote-as 65000
|
||||||
|
!
|
||||||
|
address-family ipv4 unicast
|
||||||
|
neighbor 192.168.54.44 disable-addpath-rx
|
||||||
|
neighbor 192.168.137.1 disable-addpath-rx
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
exit
|
||||||
|
!
|
40
tests/topotests/bgp_addpath_disable_rx/r6/frr.conf
Normal file
40
tests/topotests/bgp_addpath_disable_rx/r6/frr.conf
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
!
|
||||||
|
int r6-eth0
|
||||||
|
ip address 192.168.44.44/24
|
||||||
|
!
|
||||||
|
int r6-eth1
|
||||||
|
ip address 192.168.54.44/24
|
||||||
|
!
|
||||||
|
router bgp 65444
|
||||||
|
bgp router-id 192.168.54.44
|
||||||
|
no bgp network import-check
|
||||||
|
no bgp ebgp-requires-policy
|
||||||
|
neighbor 192.168.44.1 remote-as 65100
|
||||||
|
neighbor 192.168.54.21 remote-as 65200
|
||||||
|
neighbor 192.168.54.22 remote-as 65200
|
||||||
|
!
|
||||||
|
address-family ipv4 unicast
|
||||||
|
network 10.0.0.0/24
|
||||||
|
neighbor 192.168.44.1 disable-addpath-rx
|
||||||
|
neighbor 192.168.44.1 route-map AS65100-OUT out
|
||||||
|
neighbor 192.168.54.21 disable-addpath-rx
|
||||||
|
neighbor 192.168.54.21 route-map AS65200-OUT out
|
||||||
|
neighbor 192.168.54.22 disable-addpath-rx
|
||||||
|
neighbor 192.168.54.22 route-map AS65200-OUT out
|
||||||
|
exit-address-family
|
||||||
|
!
|
||||||
|
exit
|
||||||
|
!
|
||||||
|
ip prefix-list out seq 2 permit 10.0.0.0/24
|
||||||
|
ip prefix-list out seq 100 deny any
|
||||||
|
ip prefix-list v4_our_to65200 seq 100 deny any
|
||||||
|
!
|
||||||
|
route-map AS65200-OUT permit 10
|
||||||
|
match ip address prefix-list v4_our_to65200
|
||||||
|
exit
|
||||||
|
!
|
||||||
|
route-map AS65100-OUT permit 10
|
||||||
|
match ip address prefix-list out
|
||||||
|
set as-path prepend 65444
|
||||||
|
exit
|
||||||
|
!
|
|
@ -0,0 +1,131 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# SPDX-License-Identifier: ISC
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright (c) 2025 by
|
||||||
|
# Donatas Abraitis <donatas@opensourcerouting.org>
|
||||||
|
#
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import pytest
|
||||||
|
import functools
|
||||||
|
|
||||||
|
CWD = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
sys.path.append(os.path.join(CWD, "../"))
|
||||||
|
|
||||||
|
# pylint: disable=C0413
|
||||||
|
from lib import topotest
|
||||||
|
from lib.topogen import Topogen, get_topogen
|
||||||
|
|
||||||
|
pytestmark = [pytest.mark.bgpd]
|
||||||
|
|
||||||
|
|
||||||
|
def build_topo(tgen):
|
||||||
|
r1 = tgen.add_router("r1")
|
||||||
|
r2 = tgen.add_router("r2")
|
||||||
|
r3 = tgen.add_router("r3")
|
||||||
|
r4 = tgen.add_router("r4")
|
||||||
|
r5 = tgen.add_router("r5")
|
||||||
|
r6 = tgen.add_router("r6")
|
||||||
|
|
||||||
|
switch = tgen.add_switch("s1")
|
||||||
|
switch.add_link(r1)
|
||||||
|
switch.add_link(r2)
|
||||||
|
switch.add_link(r3)
|
||||||
|
switch.add_link(r4)
|
||||||
|
switch.add_link(r5)
|
||||||
|
|
||||||
|
switch = tgen.add_switch("s2")
|
||||||
|
switch.add_link(r3)
|
||||||
|
switch.add_link(r6)
|
||||||
|
|
||||||
|
switch = tgen.add_switch("s3")
|
||||||
|
switch.add_link(r4)
|
||||||
|
switch.add_link(r5)
|
||||||
|
switch.add_link(r6)
|
||||||
|
|
||||||
|
|
||||||
|
def setup_module(mod):
|
||||||
|
tgen = Topogen(build_topo, mod.__name__)
|
||||||
|
tgen.start_topology()
|
||||||
|
|
||||||
|
for _, (rname, router) in enumerate(tgen.routers().items(), 1):
|
||||||
|
router.load_frr_config(os.path.join(CWD, "{}/frr.conf".format(rname)))
|
||||||
|
|
||||||
|
tgen.start_router()
|
||||||
|
|
||||||
|
|
||||||
|
def teardown_module(mod):
|
||||||
|
tgen = get_topogen()
|
||||||
|
tgen.stop_topology()
|
||||||
|
|
||||||
|
|
||||||
|
def test_bgp_addpath_disable_rx():
|
||||||
|
tgen = get_topogen()
|
||||||
|
|
||||||
|
if tgen.routers_have_failure():
|
||||||
|
pytest.skip(tgen.errors)
|
||||||
|
|
||||||
|
r1 = tgen.gears["r1"]
|
||||||
|
r2 = tgen.gears["r2"]
|
||||||
|
r6 = tgen.gears["r6"]
|
||||||
|
|
||||||
|
def _bgp_check_aspath(aspath):
|
||||||
|
output = json.loads(r2.vtysh_cmd("show bgp ipv4 10.0.0.0/24 json"))
|
||||||
|
expected = {
|
||||||
|
"paths": [
|
||||||
|
{
|
||||||
|
"aspath": {
|
||||||
|
"string": aspath,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return topotest.json_cmp(output, expected)
|
||||||
|
|
||||||
|
test_func = functools.partial(_bgp_check_aspath, "65100 65444 65444")
|
||||||
|
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
|
||||||
|
assert result is None, "10.0.0.0/24 should have aspath (65100 65444 65444)"
|
||||||
|
|
||||||
|
# Send 10.0.0.0/24 from r6 towards r2.
|
||||||
|
# This should be the best path for r2 without any prepends.
|
||||||
|
r6.vtysh_cmd(
|
||||||
|
"""
|
||||||
|
configure terminal
|
||||||
|
ip prefix-list v4_our_to65200 seq 2 permit 10.0.0.0/24
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
test_func = functools.partial(_bgp_check_aspath, "65200 65444")
|
||||||
|
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
|
||||||
|
assert result is None, "10.0.0.0/24 should have aspath (65200 65444)"
|
||||||
|
|
||||||
|
# Drop 10.0.0.0/24 from r6 towards r2.
|
||||||
|
# This should be removed from r2 and the old path (65100 65444 65444)
|
||||||
|
# should be used.
|
||||||
|
r6.vtysh_cmd(
|
||||||
|
"""
|
||||||
|
configure terminal
|
||||||
|
no ip prefix-list v4_our_to65200 seq 2 permit 10.0.0.0/24
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
test_func = functools.partial(_bgp_check_aspath, "65100 65444 65444")
|
||||||
|
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
|
||||||
|
assert result is None, "10.0.0.0/24 should have aspath (65100 65444 65444)"
|
||||||
|
|
||||||
|
|
||||||
|
def test_memory_leak():
|
||||||
|
"Run the memory leak test and report results."
|
||||||
|
tgen = get_topogen()
|
||||||
|
if not tgen.is_memleak_enabled():
|
||||||
|
pytest.skip("Memory leak test/report is disabled")
|
||||||
|
|
||||||
|
tgen.report_memory_leaks()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
args = ["-s"] + sys.argv[1:]
|
||||||
|
sys.exit(pytest.main(args))
|
Loading…
Reference in a new issue