summaryrefslogtreecommitdiffstats
path: root/tests/topotests/bgp_route_server_client
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:16:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:16:35 +0000
commite2bbf175a2184bd76f6c54ccf8456babeb1a46fc (patch)
treef0b76550d6e6f500ada964a3a4ee933a45e5a6f1 /tests/topotests/bgp_route_server_client
parentInitial commit. (diff)
downloadfrr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.tar.xz
frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.zip
Adding upstream version 9.1.upstream/9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/topotests/bgp_route_server_client')
-rw-r--r--tests/topotests/bgp_route_server_client/__init__.py0
-rw-r--r--tests/topotests/bgp_route_server_client/r1/bgpd.conf12
-rw-r--r--tests/topotests/bgp_route_server_client/r1/zebra.conf7
-rw-r--r--tests/topotests/bgp_route_server_client/r2/bgpd.conf17
-rw-r--r--tests/topotests/bgp_route_server_client/r2/zebra.conf7
-rw-r--r--tests/topotests/bgp_route_server_client/r3/bgpd.conf12
-rw-r--r--tests/topotests/bgp_route_server_client/r3/zebra.conf7
-rw-r--r--tests/topotests/bgp_route_server_client/test_bgp_route_server_client.py130
8 files changed, 192 insertions, 0 deletions
diff --git a/tests/topotests/bgp_route_server_client/__init__.py b/tests/topotests/bgp_route_server_client/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/topotests/bgp_route_server_client/__init__.py
diff --git a/tests/topotests/bgp_route_server_client/r1/bgpd.conf b/tests/topotests/bgp_route_server_client/r1/bgpd.conf
new file mode 100644
index 0000000..9826b67
--- /dev/null
+++ b/tests/topotests/bgp_route_server_client/r1/bgpd.conf
@@ -0,0 +1,12 @@
+!
+router bgp 65001
+ bgp router-id 10.10.10.1
+ no bgp ebgp-requires-policy
+ neighbor 2001:db8:1::1 remote-as external
+ neighbor 2001:db8:1::1 timers 3 10
+ neighbor 2001:db8:1::1 timers connect 5
+ address-family ipv6 unicast
+ redistribute connected
+ neighbor 2001:db8:1::1 activate
+ exit-address-family
+!
diff --git a/tests/topotests/bgp_route_server_client/r1/zebra.conf b/tests/topotests/bgp_route_server_client/r1/zebra.conf
new file mode 100644
index 0000000..08d0be6
--- /dev/null
+++ b/tests/topotests/bgp_route_server_client/r1/zebra.conf
@@ -0,0 +1,7 @@
+!
+int lo
+ ipv6 address 2001:db8:f::1/128
+!
+int r1-eth0
+ ipv6 address 2001:db8:1::2/64
+!
diff --git a/tests/topotests/bgp_route_server_client/r2/bgpd.conf b/tests/topotests/bgp_route_server_client/r2/bgpd.conf
new file mode 100644
index 0000000..3b0a24b
--- /dev/null
+++ b/tests/topotests/bgp_route_server_client/r2/bgpd.conf
@@ -0,0 +1,17 @@
+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:1::2 timers 3 10
+ neighbor 2001:db8:1::2 timers connect 5
+ neighbor 2001:db8:3::2 remote-as external
+ neighbor 2001:db8:3::2 timers 3 10
+ neighbor 2001:db8:3::2 timers connect 5
+ 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
+!
diff --git a/tests/topotests/bgp_route_server_client/r2/zebra.conf b/tests/topotests/bgp_route_server_client/r2/zebra.conf
new file mode 100644
index 0000000..806bc4f
--- /dev/null
+++ b/tests/topotests/bgp_route_server_client/r2/zebra.conf
@@ -0,0 +1,7 @@
+!
+int r2-eth0
+ ipv6 address 2001:db8:1::1/64
+!
+int r2-eth1
+ ipv6 address 2001:db8:3::1/64
+!
diff --git a/tests/topotests/bgp_route_server_client/r3/bgpd.conf b/tests/topotests/bgp_route_server_client/r3/bgpd.conf
new file mode 100644
index 0000000..60a5ffc
--- /dev/null
+++ b/tests/topotests/bgp_route_server_client/r3/bgpd.conf
@@ -0,0 +1,12 @@
+!
+router bgp 65003
+ bgp router-id 10.10.10.3
+ no bgp ebgp-requires-policy
+ neighbor 2001:db8:3::1 remote-as external
+ neighbor 2001:db8:3::1 timers 3 10
+ neighbor 2001:db8:3::1 timers connect 5
+ address-family ipv6 unicast
+ redistribute connected
+ neighbor 2001:db8:3::1 activate
+ exit-address-family
+!
diff --git a/tests/topotests/bgp_route_server_client/r3/zebra.conf b/tests/topotests/bgp_route_server_client/r3/zebra.conf
new file mode 100644
index 0000000..b5511a4
--- /dev/null
+++ b/tests/topotests/bgp_route_server_client/r3/zebra.conf
@@ -0,0 +1,7 @@
+!
+int lo
+ ipv6 address 2001:db8:f::3/128
+!
+int r3-eth0
+ ipv6 address 2001:db8:3::2/64
+!
diff --git a/tests/topotests/bgp_route_server_client/test_bgp_route_server_client.py b/tests/topotests/bgp_route_server_client/test_bgp_route_server_client.py
new file mode 100644
index 0000000..23cf041
--- /dev/null
+++ b/tests/topotests/bgp_route_server_client/test_bgp_route_server_client.py
@@ -0,0 +1,130 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
+
+# Copyright (c) 2021 by
+# Donatas Abraitis <donatas.abraitis@gmail.com>
+#
+
+"""
+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 ipv6 unicast summary json"))
+ expected = {"peers": {"2001:db8:1::1": {"state": "Established", "pfxRcd": 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 sessions to be up"
+
+ def _bgp_prefix_received(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_prefix_received, 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))