mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 15:58:18 +00:00
tests: Check if we are sending IPV6 GUA for route-server-client peers
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
This commit is contained in:
parent
2d02e34eab
commit
0d92307ee8
0
tests/topotests/bgp_route_server_client/__init__.py
Normal file
0
tests/topotests/bgp_route_server_client/__init__.py
Normal file
10
tests/topotests/bgp_route_server_client/r1/bgpd.conf
Normal file
10
tests/topotests/bgp_route_server_client/r1/bgpd.conf
Normal file
@ -0,0 +1,10 @@
|
||||
!
|
||||
router bgp 65001
|
||||
bgp router-id 10.10.10.1
|
||||
no bgp ebgp-requires-policy
|
||||
neighbor 2001:db8:1::1 remote-as external
|
||||
address-family ipv6 unicast
|
||||
redistribute connected
|
||||
neighbor 2001:db8:1::1 activate
|
||||
exit-address-family
|
||||
!
|
7
tests/topotests/bgp_route_server_client/r1/zebra.conf
Normal file
7
tests/topotests/bgp_route_server_client/r1/zebra.conf
Normal file
@ -0,0 +1,7 @@
|
||||
!
|
||||
int lo
|
||||
ipv6 address 2001:db8:f::1/128
|
||||
!
|
||||
int r1-eth0
|
||||
ipv6 address 2001:db8:1::2/64
|
||||
!
|
13
tests/topotests/bgp_route_server_client/r2/bgpd.conf
Normal file
13
tests/topotests/bgp_route_server_client/r2/bgpd.conf
Normal file
@ -0,0 +1,13 @@
|
||||
router bgp 65000 view RS
|
||||
bgp router-id 10.10.10.2
|
||||
no bgp ebgp-requires-policy
|
||||
neighbor 2001:db8:1::2 remote-as external
|
||||
neighbor 2001:db8:3::2 remote-as external
|
||||
address-family ipv6 unicast
|
||||
redistribute connected
|
||||
neighbor 2001:db8:1::2 activate
|
||||
neighbor 2001:db8:3::2 activate
|
||||
neighbor 2001:db8:1::2 route-server-client
|
||||
neighbor 2001:db8:3::2 route-server-client
|
||||
exit-address-family
|
||||
!
|
7
tests/topotests/bgp_route_server_client/r2/zebra.conf
Normal file
7
tests/topotests/bgp_route_server_client/r2/zebra.conf
Normal file
@ -0,0 +1,7 @@
|
||||
!
|
||||
int r2-eth0
|
||||
ipv6 address 2001:db8:1::1/64
|
||||
!
|
||||
int r2-eth1
|
||||
ipv6 address 2001:db8:3::1/64
|
||||
!
|
10
tests/topotests/bgp_route_server_client/r3/bgpd.conf
Normal file
10
tests/topotests/bgp_route_server_client/r3/bgpd.conf
Normal file
@ -0,0 +1,10 @@
|
||||
!
|
||||
router bgp 65003
|
||||
bgp router-id 10.10.10.3
|
||||
no bgp ebgp-requires-policy
|
||||
neighbor 2001:db8:3::1 remote-as external
|
||||
address-family ipv6 unicast
|
||||
redistribute connected
|
||||
neighbor 2001:db8:3::1 activate
|
||||
exit-address-family
|
||||
!
|
7
tests/topotests/bgp_route_server_client/r3/zebra.conf
Normal file
7
tests/topotests/bgp_route_server_client/r3/zebra.conf
Normal file
@ -0,0 +1,7 @@
|
||||
!
|
||||
int lo
|
||||
ipv6 address 2001:db8:f::3/128
|
||||
!
|
||||
int r3-eth0
|
||||
ipv6 address 2001:db8:3::2/64
|
||||
!
|
@ -0,0 +1,134 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2021 by
|
||||
# Donatas Abraitis <donatas.abraitis@gmail.com>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software
|
||||
# for any purpose with or without fee is hereby granted, provided
|
||||
# that the above copyright notice and this permission notice appear
|
||||
# in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
# OF THIS SOFTWARE.
|
||||
#
|
||||
|
||||
"""
|
||||
Test if we send ONLY GUA address for route-server-client peers.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import pytest
|
||||
import functools
|
||||
|
||||
pytestmark = pytest.mark.bgpd
|
||||
|
||||
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, TopoRouter, get_topogen
|
||||
|
||||
pytestmark = [pytest.mark.bgpd]
|
||||
|
||||
|
||||
def build_topo(tgen):
|
||||
for routern in range(1, 4):
|
||||
tgen.add_router("r{}".format(routern))
|
||||
|
||||
switch = tgen.add_switch("s1")
|
||||
switch.add_link(tgen.gears["r1"])
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
|
||||
switch = tgen.add_switch("s2")
|
||||
switch.add_link(tgen.gears["r2"])
|
||||
switch.add_link(tgen.gears["r3"])
|
||||
|
||||
|
||||
def setup_module(mod):
|
||||
tgen = Topogen(build_topo, mod.__name__)
|
||||
tgen.start_topology()
|
||||
|
||||
router_list = tgen.routers()
|
||||
|
||||
for i, (rname, router) in enumerate(router_list.items(), 1):
|
||||
router.load_config(
|
||||
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
|
||||
)
|
||||
router.load_config(
|
||||
TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
|
||||
)
|
||||
|
||||
tgen.start_router()
|
||||
|
||||
|
||||
def teardown_module(mod):
|
||||
tgen = get_topogen()
|
||||
tgen.stop_topology()
|
||||
|
||||
|
||||
def test_bgp_route_server_client():
|
||||
tgen = get_topogen()
|
||||
|
||||
if tgen.routers_have_failure():
|
||||
pytest.skip(tgen.errors)
|
||||
|
||||
r1 = tgen.gears["r1"]
|
||||
r2 = tgen.gears["r2"]
|
||||
|
||||
def _bgp_converge(router):
|
||||
output = json.loads(router.vtysh_cmd("show bgp 2001:db8:f::3/128 json"))
|
||||
expected = {
|
||||
"prefix": "2001:db8:f::3/128",
|
||||
"paths": [{"nexthops": [{"ip": "2001:db8:3::2"}]}],
|
||||
}
|
||||
return topotest.json_cmp(output, expected)
|
||||
|
||||
test_func = functools.partial(_bgp_converge, r1)
|
||||
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
|
||||
assert result is None, "Cannot see BGP GUA next hop from r3 in r1"
|
||||
|
||||
def _bgp_single_next_hop(router):
|
||||
output = json.loads(router.vtysh_cmd("show bgp 2001:db8:f::3/128 json"))
|
||||
return len(output["paths"][0]["nexthops"])
|
||||
|
||||
assert (
|
||||
_bgp_single_next_hop(r1) == 1
|
||||
), "Not ONLY one Next Hop received for 2001:db8:f::3/128"
|
||||
|
||||
def _bgp_gua_lla_next_hop(router):
|
||||
output = json.loads(router.vtysh_cmd("show bgp view RS 2001:db8:f::3/128 json"))
|
||||
expected = {
|
||||
"prefix": "2001:db8:f::3/128",
|
||||
"paths": [
|
||||
{
|
||||
"nexthops": [
|
||||
{
|
||||
"ip": "2001:db8:3::2",
|
||||
"hostname": "r3",
|
||||
"afi": "ipv6",
|
||||
"scope": "global",
|
||||
},
|
||||
{"hostname": "r3", "afi": "ipv6", "scope": "link-local"},
|
||||
]
|
||||
}
|
||||
],
|
||||
}
|
||||
return topotest.json_cmp(output, expected)
|
||||
|
||||
test_func = functools.partial(_bgp_gua_lla_next_hop, r2)
|
||||
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
|
||||
assert result is None, "Cannot see BGP LLA next hop from r3 in r2"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = ["-s"] + sys.argv[1:]
|
||||
sys.exit(pytest.main(args))
|
Loading…
Reference in New Issue
Block a user