summaryrefslogtreecommitdiffstats
path: root/tests/topotests/bgp_tcp_mss
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/bgp_tcp_mss')
-rw-r--r--tests/topotests/bgp_tcp_mss/__init__.py0
-rw-r--r--tests/topotests/bgp_tcp_mss/bgp_vrf_tcp_mss.json222
-rw-r--r--tests/topotests/bgp_tcp_mss/r1/bgpd.conf6
-rw-r--r--tests/topotests/bgp_tcp_mss/r1/zebra.conf6
-rw-r--r--tests/topotests/bgp_tcp_mss/r2/bgpd.conf6
-rw-r--r--tests/topotests/bgp_tcp_mss/r2/zebra.conf6
-rw-r--r--tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py175
-rw-r--r--tests/topotests/bgp_tcp_mss/test_bgp_vrf_tcp_mss.py766
8 files changed, 1187 insertions, 0 deletions
diff --git a/tests/topotests/bgp_tcp_mss/__init__.py b/tests/topotests/bgp_tcp_mss/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/topotests/bgp_tcp_mss/__init__.py
diff --git a/tests/topotests/bgp_tcp_mss/bgp_vrf_tcp_mss.json b/tests/topotests/bgp_tcp_mss/bgp_vrf_tcp_mss.json
new file mode 100644
index 0000000..17cee03
--- /dev/null
+++ b/tests/topotests/bgp_tcp_mss/bgp_vrf_tcp_mss.json
@@ -0,0 +1,222 @@
+{
+ "address_types": [
+ "ipv4",
+ "ipv6"
+ ],
+ "ipv4base": "20.20.20.0",
+ "ipv4mask": 24,
+ "ipv6base": "fd00::",
+ "ipv6mask": 64,
+ "link_ip_start": {
+ "ipv4": "10.10.10.0",
+ "v4mask": 24,
+ "ipv6": "fd00::",
+ "v6mask": 64
+ },
+ "lo_prefix": {
+ "ipv4": "1.0.",
+ "v4mask": 24,
+ "ipv6": "2001:db8:f::",
+ "v6mask": 128
+ },
+ "routers": {
+ "r1": {
+ "links": {
+ "r2-link1": {
+ "ipv4": "auto",
+ "ipv6": "auto",
+ "vrf": "RED"
+ }
+ },
+ "vrfs": [
+ {
+ "name": "RED",
+ "id": "1"
+ }
+ ],
+ "bgp": [
+ {
+ "local_as": "100",
+ "vrf": "RED",
+ "address_family": {
+ "ipv4": {
+ "unicast": {
+ "neighbor": {
+ "r2": {
+ "dest_link": {
+ "r1-link1": {}
+ }
+ }
+ },
+ "redistribute": [
+ {
+ "redist_type": "static"
+ }
+ ]
+ }
+ },
+ "ipv6": {
+ "unicast": {
+ "neighbor": {
+ "r2": {
+ "dest_link": {
+ "r1-link1": {}
+ }
+ }
+ },
+ "redistribute": [
+ {
+ "redist_type": "static"
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ },
+ "r2": {
+ "links": {
+ "r1-link1": {
+ "ipv4": "auto",
+ "ipv6": "auto",
+ "vrf": "RED"
+ },
+ "r3-link1": {
+ "ipv4": "auto",
+ "ipv6": "auto"
+ }
+ },
+ "vrfs": [
+ {
+ "name": "RED",
+ "id": "1"
+ }
+ ],
+ "bgp": [
+ {
+ "local_as": "200",
+ "address_family": {
+ "ipv4": {
+ "unicast": {
+ "neighbor": {
+ "r3": {
+ "dest_link": {
+ "r2-link1": {}
+ }
+ }
+ },
+ "redistribute": [
+ {
+ "redist_type": "static"
+ }
+ ]
+ }
+ },
+ "ipv6": {
+ "unicast": {
+ "neighbor": {
+ "r3": {
+ "dest_link": {
+ "r2-link1": {}
+ }
+ }
+ },
+ "redistribute": [
+ {
+ "redist_type": "static"
+ }
+ ]
+ }
+ }
+ }
+ },
+ {
+ "local_as": "200",
+ "vrf": "RED",
+ "address_family": {
+ "ipv4": {
+ "unicast": {
+ "neighbor": {
+ "r1": {
+ "dest_link": {
+ "r2-link1": {}
+ }
+ }
+ },
+ "redistribute": [
+ {
+ "redist_type": "static"
+ }
+ ]
+ }
+ },
+ "ipv6": {
+ "unicast": {
+ "neighbor": {
+ "r1": {
+ "dest_link": {
+ "r2-link1": {}
+ }
+ }
+ },
+ "redistribute": [
+ {
+ "redist_type": "static"
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ },
+ "r3": {
+ "links": {
+ "r2-link1": {
+ "ipv4": "auto",
+ "ipv6": "auto"
+ }
+ },
+ "bgp": [
+ {
+ "local_as": "300",
+ "address_family": {
+ "ipv4": {
+ "unicast": {
+ "neighbor": {
+ "r2": {
+ "dest_link": {
+ "r3-link1": {}
+ }
+ }
+ },
+ "redistribute": [
+ {
+ "redist_type": "static"
+ }
+ ]
+ }
+ },
+ "ipv6": {
+ "unicast": {
+ "neighbor": {
+ "r2": {
+ "dest_link": {
+ "r3-link1": {}
+ }
+ }
+ },
+ "redistribute": [
+ {
+ "redist_type": "static"
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/topotests/bgp_tcp_mss/r1/bgpd.conf b/tests/topotests/bgp_tcp_mss/r1/bgpd.conf
new file mode 100644
index 0000000..07cfe2e
--- /dev/null
+++ b/tests/topotests/bgp_tcp_mss/r1/bgpd.conf
@@ -0,0 +1,6 @@
+router bgp 65000
+ no bgp ebgp-requires-policy
+ neighbor 192.168.255.2 remote-as 65001
+ neighbor 192.168.255.2 timers 3 10
+ exit-address-family
+!
diff --git a/tests/topotests/bgp_tcp_mss/r1/zebra.conf b/tests/topotests/bgp_tcp_mss/r1/zebra.conf
new file mode 100644
index 0000000..6e9b0b4
--- /dev/null
+++ b/tests/topotests/bgp_tcp_mss/r1/zebra.conf
@@ -0,0 +1,6 @@
+!
+interface r1-eth0
+ ip address 192.168.255.1/24
+!
+ip forwarding
+!
diff --git a/tests/topotests/bgp_tcp_mss/r2/bgpd.conf b/tests/topotests/bgp_tcp_mss/r2/bgpd.conf
new file mode 100644
index 0000000..b2d9455
--- /dev/null
+++ b/tests/topotests/bgp_tcp_mss/r2/bgpd.conf
@@ -0,0 +1,6 @@
+router bgp 65001
+ no bgp ebgp-requires-policy
+ neighbor 192.168.255.1 remote-as 65000
+ neighbor 192.168.255.1 timers 3 10
+ exit-address-family
+!
diff --git a/tests/topotests/bgp_tcp_mss/r2/zebra.conf b/tests/topotests/bgp_tcp_mss/r2/zebra.conf
new file mode 100644
index 0000000..6c14de5
--- /dev/null
+++ b/tests/topotests/bgp_tcp_mss/r2/zebra.conf
@@ -0,0 +1,6 @@
+!
+interface r2-eth0
+ ip address 192.168.255.2/24
+!
+ip forwarding
+!
diff --git a/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py b/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py
new file mode 100644
index 0000000..eed0b34
--- /dev/null
+++ b/tests/topotests/bgp_tcp_mss/test_bgp_tcp_mss.py
@@ -0,0 +1,175 @@
+#!/usr/bin/env python
+
+#
+# bgp_tcp_mss.py
+# Part of NetDEF Topology Tests
+#
+# Copyright (c) 2021 by
+# Abhinay Ramesh <rabhinay@vmware.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.
+#
+
+"""
+bgp_tcp_mss.py:
+
+Test if works the following commands:
+router bgp 65000
+ neighbor 192.168.255.2 tcp-mss 500
+
+Need to verify if the tcp-mss value is reflected in the TCP session.
+"""
+
+import os
+import sys
+import json
+import pytest
+import functools
+
+# add after imports, before defining classes or functions:
+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
+from lib.topolog import logger
+
+pytestmark = [pytest.mark.bgpd]
+
+
+def build_topo(tgen):
+ for routern in range(1, 3):
+ tgen.add_router("r{}".format(routern))
+
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+
+
+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_tcp_mss():
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ router1 = tgen.gears["r1"]
+ router2 = tgen.gears["r2"]
+
+ def _bgp_converge(router):
+ output = json.loads(router.vtysh_cmd("show ip bgp neighbor 192.168.255.2 json"))
+ expected = {
+ "192.168.255.2": {
+ "bgpState": "Established",
+ "addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 0}},
+ }
+ }
+ return topotest.json_cmp(output, expected)
+
+ def _bgp_conf_tcp_mss(router, as_num, neigh):
+ router.vtysh_cmd(
+ """configure terminal
+ router bgp {0}
+ neighbor {1} tcp-mss 500""".format(
+ as_num, neigh
+ )
+ )
+
+ def _bgp_clear_session(router):
+ router.vtysh_cmd("clear bgp *")
+
+ def _bgp_check_neighbor_tcp_mss(router, neigh):
+ output = json.loads(router.vtysh_cmd("show bgp neighbor {} json".format(neigh)))
+ expected = {
+ "{}".format(neigh): {"bgpTcpMssConfigured": 500, "bgpTcpMssSynced": 488}
+ }
+ return topotest.json_cmp(output, expected)
+
+ logger.info("Check if neighbor sessions are up in {}".format(router1.name))
+ test_func = functools.partial(_bgp_converge, router1)
+ success, result = topotest.run_and_expect(test_func, None, count=15, wait=0.5)
+ assert result is None, 'Failed to see BGP convergence in "{}"'.format(router1.name)
+
+ logger.info("BGP neighbor session is up in {}".format(router1.name))
+
+ logger.info(
+ "Configure tcp-mss 500 on {} and reset the session".format(router1.name)
+ )
+ _bgp_conf_tcp_mss(router1, "65000", "192.168.255.2")
+ _bgp_clear_session(router1)
+
+ logger.info(
+ "Configure tcp-mss 500 on {} and reset the session".format(router2.name)
+ )
+ _bgp_conf_tcp_mss(router2, "65001", "192.168.255.1")
+ _bgp_clear_session(router2)
+
+ logger.info(
+ "Check if neighbor session is up after reset in {}".format(router1.name)
+ )
+ test_func = functools.partial(_bgp_converge, router1)
+ success, result = topotest.run_and_expect(test_func, None, count=15, wait=0.5)
+ assert result is None, 'Failed to see BGP convergence after reset in "{}"'.format(
+ router1.name
+ )
+
+ logger.info(
+ "Verify if TCP MSS value is synced with neighbor in {}".format(router1.name)
+ )
+ test_func = functools.partial(_bgp_check_neighbor_tcp_mss, router1, "192.168.255.2")
+ success, result = topotest.run_and_expect(test_func, None, count=3, wait=0.5)
+ assert (
+ result is None
+ ), 'Failed to sync TCP MSS value over BGP session in "{}"'.format(router1.name)
+ logger.info("TCP MSS value is synced with neighbor in {}".format(router1.name))
+
+ logger.info(
+ "Verify if TCP MSS value is synced with neighbor in {}".format(router2.name)
+ )
+ test_func = functools.partial(_bgp_check_neighbor_tcp_mss, router2, "192.168.255.1")
+ success, result = topotest.run_and_expect(test_func, None, count=3, wait=0.5)
+ assert (
+ result is None
+ ), 'Failed to sync TCP MSS value over BGP session in "{}"'.format(router2.name)
+ logger.info("TCP MSS value is synced with neighbor in {}".format(router2.name))
+
+
+if __name__ == "__main__":
+ args = ["-s"] + sys.argv[1:]
+ sys.exit(pytest.main(args))
diff --git a/tests/topotests/bgp_tcp_mss/test_bgp_vrf_tcp_mss.py b/tests/topotests/bgp_tcp_mss/test_bgp_vrf_tcp_mss.py
new file mode 100644
index 0000000..7094c28
--- /dev/null
+++ b/tests/topotests/bgp_tcp_mss/test_bgp_vrf_tcp_mss.py
@@ -0,0 +1,766 @@
+#!/usr/bin/env python
+
+#
+# bgp_tcp_mss.py
+# Part of NetDEF Topology Tests
+#
+# Copyright (c) 2021 by
+# Shreenidhi A R <rshreenidhi@vmware.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.
+#
+
+"""
+bgp_tcp_mss_vrf.py:
+
+Need to verify if the tcp-mss value is reflected in the TCP session and in VRF.
+"""
+
+import os
+import sys
+import json
+import pytest
+import functools
+import platform
+import socket
+import subprocess
+
+# add after imports, before defining classes or functions:
+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
+from lib.topojson import build_config_from_json
+from lib.topolog import logger
+import time
+from lib.bgp import (
+ clear_bgp,
+ clear_bgp_and_verify,
+ create_router_bgp,
+ modify_as_number,
+ verify_as_numbers,
+ verify_bgp_convergence,
+ verify_bgp_rib,
+ verify_bgp_timers_and_functionality,
+ verify_router_id,
+ verify_tcp_mss
+)
+from lib.common_config import (
+ kill_router_daemons,
+ start_router_daemons,
+ addKernelRoute,
+ apply_raw_config,
+ check_address_types,
+ create_prefix_lists,
+ create_route_maps,
+ create_static_routes,
+ required_linux_kernel_version,
+ reset_config_on_routers,
+ start_topology,
+ step,
+ verify_admin_distance_for_static_routes,
+ verify_bgp_community,
+ verify_fib_routes,
+ verify_rib,
+ write_test_footer,
+ write_test_header
+)
+
+pytestmark = [pytest.mark.bgpd]
+# Global variables
+NETWORK1_1 = {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
+NETWORK1_2 = {"ipv4": "1.1.1.2/32", "ipv6": "1::2/128"}
+NETWORK2_1 = {"ipv4": "2.1.1.1/32", "ipv6": "2::1/128"}
+NETWORK2_2 = {"ipv4": "2.1.1.2/32", "ipv6": "2::2/128"}
+NETWORK3_1 = {"ipv4": "3.1.1.1/32", "ipv6": "3::1/128"}
+NETWORK3_2 = {"ipv4": "3.1.1.2/32", "ipv6": "3::2/128"}
+NETWORK4_1 = {"ipv4": "4.1.1.1/32", "ipv6": "4::1/128"}
+NETWORK4_2 = {"ipv4": "4.1.1.2/32", "ipv6": "4::2/128"}
+NETWORK5_1 = {"ipv4": "5.1.1.1/32", "ipv6": "5::1/128"}
+NETWORK5_2 = {"ipv4": "5.1.1.2/32", "ipv6": "5::2/128"}
+
+NEXT_HOP_IP = {"ipv4": "Null0", "ipv6": "Null0"}
+
+## File name
+TCPDUMP_FILE="test_tcp_packet_test.txt"
+
+def setup_module(mod):
+ """
+ Sets up the pytest environment
+
+ * `mod`: module name
+ """
+ global topo,TCPDUMP_FILE
+
+ # Required linux kernel version for this suite to run.
+ result = required_linux_kernel_version("4.15")
+ if result is not True:
+ pytest.skip("Kernel requirements are not met")
+
+ testsuite_run_time = time.asctime(time.localtime(time.time()))
+ step("Testsuite start time: {}".format(testsuite_run_time))
+ step("=" * 40)
+
+ step("Running setup_module to create topology")
+
+ # This function initiates the topology build with Topogen...
+ json_file = "{}/bgp_vrf_tcp_mss.json".format(CWD)
+ tgen = Topogen(json_file, mod.__name__)
+ global topo
+ topo = tgen.json_topo
+ # ... and here it calls Mininet initialization functions.
+ # Starting topology, create tmp files which are loaded to routers
+ # to start daemons and then start routers
+ start_topology(tgen)
+ # Creating configuration from JSON
+ build_config_from_json(tgen, topo)
+
+ global ADDR_TYPES
+ global BGP_CONVERGENCE
+ ADDR_TYPES = check_address_types()
+ BGP_CONVERGENCE = verify_bgp_convergence(tgen, topo)
+ assert BGP_CONVERGENCE is True, "setup_module :Failed \n Error: {}".format(
+ BGP_CONVERGENCE
+ )
+
+ step("Running setup_module() done")
+
+def teardown_module():
+ """Teardown the pytest environment"""
+
+ step("Running teardown_module to delete topology")
+
+ tgen = get_topogen()
+
+ # Stop toplogy and Remove tmp files
+ tgen.stop_topology()
+
+ step(
+ "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
+ )
+ step("=" * 40)
+
+
+#####################################################
+#
+# Testcases
+#
+#####################################################
+
+def test_bgp_vrf_tcp_mss(request):
+ tgen = get_topogen()
+ tc_name = request.node.name
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ step("Verify the router failures")
+ if tgen.routers_have_failure():
+ check_router_status(tgen)
+
+ step("Configuring 5 static Routes in Router R3 with NULL0 as Next hop")
+ for addr_type in ADDR_TYPES:
+ static_routes_input = {
+ "r3": {
+ "static_routes": [
+ {
+ "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ ]
+ }
+ }
+ result = create_static_routes(tgen, static_routes_input)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+
+ step("Verify the static Routes in R3 on default VRF")
+ for addr_type in ADDR_TYPES:
+ static_routes_input = {
+ "r3": {
+ "static_routes": [
+ {
+ "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ ]
+ }
+ }
+ dut = "r3"
+ result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input)
+ assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
+
+ step("Verify the static Routes in R2 on default VRF")
+ for addr_type in ADDR_TYPES:
+ static_routes_input = {
+ "r3": {
+ "static_routes": [
+ {
+ "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ {
+ "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ },
+ ]
+ }
+ }
+ dut = "r2"
+ result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input)
+ assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
+
+ step("importing default vrf on R2 under VRF RED Address Family")
+ for addr_type in ADDR_TYPES:
+ input_import_vrf = {
+ "r2": {
+ "bgp": [
+ {
+ "local_as": 200,
+ "vrf": "RED",
+ "address_family": {
+ addr_type: {"unicast": {"import": {"vrf": "default"}}}
+ },
+ }
+ ]
+ }
+ }
+ result = create_router_bgp(tgen, topo, input_import_vrf)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(
+ tc_name, result
+ )
+
+ step("Verify the static Routes in R2 on RED VRF")
+ for addr_type in ADDR_TYPES:
+ static_routes_input = {
+ "r3": {
+ "static_routes": [
+ {
+ "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ "vrf": "RED",
+ },
+ {
+ "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ "vrf": "RED",
+ },
+ {
+ "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ "vrf": "RED",
+ },
+ {
+ "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ "vrf": "RED",
+ },
+ {
+ "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ "vrf": "RED",
+ },
+ ]
+ }
+ }
+ dut = "r2"
+ result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input)
+ assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
+
+ step("Verify the static Routes in R1 on RED VRF")
+ for addr_type in ADDR_TYPES:
+ static_routes_input = {
+ "r3": {
+ "static_routes": [
+ {
+ "network": [NETWORK1_1[addr_type]] + [NETWORK1_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ "vrf": "RED",
+ },
+ {
+ "network": [NETWORK2_1[addr_type]] + [NETWORK2_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ "vrf": "RED",
+ },
+ {
+ "network": [NETWORK3_1[addr_type]] + [NETWORK3_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ "vrf": "RED",
+ },
+ {
+ "network": [NETWORK4_1[addr_type]] + [NETWORK4_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ "vrf": "RED",
+ },
+ {
+ "network": [NETWORK5_1[addr_type]] + [NETWORK5_2[addr_type]],
+ "next_hop": NEXT_HOP_IP[addr_type],
+ "vrf": "RED",
+ },
+ ]
+ }
+ }
+ dut = "r1"
+ result = verify_bgp_rib(tgen, addr_type, dut, static_routes_input)
+ assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result)
+
+ step("Enabling tcp-mss 150 on Router R1 in VRF RED")
+ TCP_MSS = 150
+ raw_config = {
+ "r1": {
+ "raw_config": [
+ "router bgp {} vrf {}".format(
+ topo["routers"]["r1"]["bgp"][0]["local_as"],
+ topo["routers"]["r1"]["bgp"][0]["vrf"],
+ ),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r1-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r1-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ },
+ }
+
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+ step("Clearing BGP on R1 and R2 ")
+ for addr_type in ADDR_TYPES:
+ clear_bgp(tgen, addr_type, "r1", vrf=topo["routers"]["r1"]["bgp"][0]["vrf"])
+ clear_bgp(tgen, addr_type, "r2", vrf=topo["routers"]["r2"]["bgp"][1]["vrf"])
+
+ step("Verify the BGP Convergence at R1 & R2 after Clear BGP")
+ r1_convergence = verify_bgp_convergence(tgen, topo, dut="r1")
+ assert (
+ r1_convergence is True
+ ), "BGP convergence after Clear BGP :Failed \n Error: {}".format(r1_convergence)
+ r2_convergence = verify_bgp_convergence(tgen, topo, dut="r2")
+ assert (
+ r2_convergence is True
+ ), "BGP convergence after Clear BGP :Failed \n Error: {}".format(r2_convergence)
+
+ step("Verify the TCP-MSS value on both Router R1 and R2")
+ for addr_type in ADDR_TYPES:
+ dut = "r1"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0],
+ TCP_MSS,
+ "RED",
+ )
+ assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
+ tcp_mss_result
+ )
+
+
+
+
+ step("Enabling tcp-mss 500 between R2 and R3 of VRF Default")
+ TCP_MSS = 500
+ raw_config = {
+ "r2": {
+ "raw_config": [
+ "router bgp {} ".format(topo["routers"]["r2"]["bgp"][0]["local_as"]),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ },
+ "r3": {
+ "raw_config": [
+ "router bgp {} ".format(topo["routers"]["r3"]["bgp"][0]["local_as"]),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ },
+ }
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+
+
+ step("Clear BGP at router R2 and R3")
+ for addr_type in ADDR_TYPES:
+ clear_bgp(tgen, topo, "r2", addr_type)
+ clear_bgp(tgen, topo, "r3", addr_type)
+
+ step("Verify the BGP Convergence at R2 & R3 after Clear BGP")
+ r1_convergence = verify_bgp_convergence(tgen, topo, dut="r2")
+ assert (
+ r1_convergence is True
+ ), "BGP convergence after Clear BGP :Failed \n Error: {}".format(r2_convergence)
+ r2_convergence = verify_bgp_convergence(tgen, topo, dut="r3")
+ assert (
+ r2_convergence is True
+ ), "BGP convergence after Clear BGP :Failed \n Error: {}".format(r2_convergence)
+
+ step("Verify the TCP-MSS value on both Router R2 and R3")
+ for addr_type in ADDR_TYPES:
+ dut = "r2"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ )
+ assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
+ tcp_mss_result
+ )
+
+ dut = "r3"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ )
+ assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
+ tcp_mss_result
+ )
+
+ step("Removing tcp-mss 150 between R1 and R2 of VRF RED ")
+ TCP_MSS = 150
+ raw_config = {
+ "r1": {
+ "raw_config": [
+ "router bgp {} vrf {}".format(
+ topo["routers"]["r1"]["bgp"][0]["local_as"],
+ topo["routers"]["r1"]["bgp"][0]["vrf"],
+ ),
+ "no neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r1-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "no neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r1-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ }
+ }
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+ raw_config = {
+ "r2": {
+ "raw_config": [
+ "router bgp {} vrf {}".format(
+ topo["routers"]["r2"]["bgp"][0]["local_as"],
+ topo["routers"]["r2"]["bgp"][1]["vrf"],
+ ),
+ "no neighbor {} tcp-mss {}".format(
+ topo["routers"]["r1"]["links"]["r2-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "no neighbor {} tcp-mss {}".format(
+ topo["routers"]["r1"]["links"]["r2-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ }
+ }
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+ step("Verify the TCP-MSS value cleared on both Router R1 and R2")
+ for addr_type in ADDR_TYPES:
+ dut = "r1"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r2"]["links"]["r1-link1"][addr_type].split("/")[0],
+ TCP_MSS,
+ "RED",
+ )
+ assert (
+ tcp_mss_result is not True
+ ), " TCP-MSS mismatch :Failed \n Error: {}".format(tcp_mss_result)
+
+ dut = "r2"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r1"]["links"]["r2-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ "RED",
+ )
+ assert (
+ tcp_mss_result is not True
+ ), " TCP-MSS mismatch :Failed \n Error: {}".format(tcp_mss_result)
+
+
+ step("Removing tcp-mss 500 between R2 and R3 of VRF Default ")
+ TCP_MSS = 500
+ raw_config = {
+ "r2": {
+ "raw_config": [
+ "router bgp {} ".format(topo["routers"]["r2"]["bgp"][0]["local_as"]),
+ "no neighbor {} tcp-mss {}".format(
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "no neighbor {} tcp-mss {}".format(
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ }
+ }
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+ raw_config = {
+ "r3": {
+ "raw_config": [
+ "router bgp {} ".format(topo["routers"]["r3"]["bgp"][0]["local_as"]),
+ "no neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "no neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ }
+ }
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+ step("Verify the TCP-MSS value got cleared on both Router R2 and R3")
+ for addr_type in ADDR_TYPES:
+ dut = "r2"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ )
+ assert (
+ tcp_mss_result is not True
+ ), " TCP-MSS mismatch :Failed \n Error: {}".format(tcp_mss_result)
+
+ dut = "r3"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ )
+ assert (
+ tcp_mss_result is not True
+ ), " TCP-MSS mismatch :Failed \n Error: {}".format(tcp_mss_result)
+
+ step("Configuring different TCP-MSS R2 and R3 ")
+ TCP_MSS = 500
+ raw_config = {
+ "r2": {
+ "raw_config": [
+ "router bgp {}".format(topo["routers"]["r2"]["bgp"][0]["local_as"]),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ }
+ }
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+ TCP_MSS = 300
+ raw_config = {
+ "r3": {
+ "raw_config": [
+ "router bgp {} ".format(topo["routers"]["r3"]["bgp"][0]["local_as"]),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ }
+ }
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+ step("Verify the TCP-MSS value on both Router R2 and R3")
+ for addr_type in ADDR_TYPES:
+ TCP_MSS = 500
+ dut = "r2"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ )
+ assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
+ tcp_mss_result
+ )
+
+ TCP_MSS = 300
+ dut = "r3"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ )
+ assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
+ tcp_mss_result
+ )
+
+ step("Configure TCP_MSS > MTU on R2 and R3 and it should be 1460 ")
+ TCP_MSS = 4096
+ REF_TCP_MSS = 1460
+ raw_config = {
+ "r2": {
+ "raw_config": [
+ "router bgp {} ".format(topo["routers"]["r2"]["bgp"][0]["local_as"]),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ }
+ }
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+ raw_config = {
+ "r3": {
+ "raw_config": [
+ "router bgp {} ".format(topo["routers"]["r3"]["bgp"][0]["local_as"]),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ ),
+ "neighbor {} tcp-mss {}".format(
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv6"].split("/")[0],
+ TCP_MSS,
+ ),
+ ]
+ }
+ }
+ result = apply_raw_config(tgen, raw_config)
+ assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
+
+ step("Restarting BGP Daemon on R3")
+
+ kill_router_daemons(tgen, "r3", ["bgpd"])
+ start_router_daemons(tgen, "r3", ["bgpd"])
+
+ step(
+ "Verify the configured TCP-MSS 4096 value on restarting both Daemon both Router R2 and R3 "
+ )
+ for addr_type in ADDR_TYPES:
+ TCP_MSS = 4096
+ dut = "r2"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r3"]["links"]["r2-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ )
+ assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
+ tcp_mss_result
+ )
+ dut = "r3"
+ tcp_mss_result = verify_tcp_mss(
+ tgen,
+ dut,
+ topo["routers"]["r2"]["links"]["r3-link1"]["ipv4"].split("/")[0],
+ TCP_MSS,
+ )
+ assert tcp_mss_result is True, " TCP-MSS mismatch :Failed \n Error: {}".format(
+ tcp_mss_result
+ )
+ write_test_footer(tc_name)
+
+
+if __name__ == "__main__":
+ args = ["-s"] + sys.argv[1:]
+ sys.exit(pytest.main(args))