]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: Add test case to verify SRv6 SID modify
authorCarmine Scarpitta <cscarpit@cisco.com>
Sun, 23 Mar 2025 15:57:15 +0000 (16:57 +0100)
committerCarmine Scarpitta <cscarpit@cisco.com>
Sun, 23 Mar 2025 17:47:35 +0000 (18:47 +0100)
This commit adds a test case that modifies a SID and verifies that the
RIB is as expected.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
tests/topotests/static_srv6_sids/expected_srv6_sids_sid_modify.json [new file with mode: 0644]
tests/topotests/static_srv6_sids/r1/setup.sh
tests/topotests/static_srv6_sids/test_static_srv6_sids.py

diff --git a/tests/topotests/static_srv6_sids/expected_srv6_sids_sid_modify.json b/tests/topotests/static_srv6_sids/expected_srv6_sids_sid_modify.json
new file mode 100644 (file)
index 0000000..070b7ad
--- /dev/null
@@ -0,0 +1,201 @@
+{
+       "fcbb:bbbb:1::/48": [
+               {
+                       "prefix": "fcbb:bbbb:1::/48",
+                       "prefixLen": 48,
+                       "protocol": "static",
+                       "vrfId": 0,
+                       "vrfName": "default",
+                       "selected": true,
+                       "destSelected": true,
+                       "distance": 1,
+                       "metric": 0,
+                       "installed": true,
+                       "table": 254,
+                       "internalStatus": 16,
+                       "internalFlags": 9,
+                       "internalNextHopNum": 1,
+                       "internalNextHopActiveNum": 1,
+                       "nexthops": [
+                               {
+                                       "flags": 3,
+                                       "fib": true,
+                                       "directlyConnected": true,
+                                       "interfaceName": "sr0",
+                                       "active": true,
+                                       "weight": 1,
+                                       "seg6local": {
+                                               "action": "End",
+                                               "sidStructure": {
+                                                       "blockLen": 32,
+                                                       "nodeLen": 16,
+                                                       "funcLen": 0,
+                                                       "argLen": 0
+                                               }
+                                       },
+                                       "seg6localContext": {
+
+                                       }
+                               }
+                       ]
+               }
+       ],
+       "fcbb:bbbb:1:fe10::/64": [
+               {
+                       "prefix": "fcbb:bbbb:1:fe10::/64",
+                       "prefixLen": 64,
+                       "protocol": "static",
+                       "vrfId": 0,
+                       "vrfName": "default",
+                       "selected": true,
+                       "destSelected": true,
+                       "distance": 1,
+                       "metric": 0,
+                       "installed": true,
+                       "table": 254,
+                       "internalStatus": 16,
+                       "internalFlags": 9,
+                       "internalNextHopNum": 1,
+                       "internalNextHopActiveNum": 1,
+                       "nexthops": [
+                               {
+                                       "flags": 3,
+                                       "fib": true,
+                                       "directlyConnected": true,
+                                       "interfaceName": "Vrf10",
+                                       "active": true,
+                                       "weight": 1,
+                                       "seg6local": {
+                                               "action": "End.DT4",
+                                               "sidStructure": {
+                                                       "blockLen": 32,
+                                                       "nodeLen": 16,
+                                                       "funcLen": 16,
+                                                       "argLen": 0
+                                               }
+                                       },
+                                       "seg6localContext": {
+                                               "table": 10
+                                       }
+                               }
+                       ]
+               }
+       ],
+       "fcbb:bbbb:1:fe20::/64": [
+               {
+                       "prefix": "fcbb:bbbb:1:fe20::/64",
+                       "prefixLen": 64,
+                       "protocol": "static",
+                       "vrfId": 0,
+                       "vrfName": "default",
+                       "selected": true,
+                       "destSelected": true,
+                       "distance": 1,
+                       "metric": 0,
+                       "installed": true,
+                       "table": 254,
+                       "internalStatus": 16,
+                       "internalFlags": 9,
+                       "internalNextHopNum": 1,
+                       "internalNextHopActiveNum": 1,
+                       "nexthops": [
+                               {
+                                       "flags": 3,
+                                       "fib": true,
+                                       "directlyConnected": true,
+                                       "interfaceName": "Vrf40",
+                                       "active": true,
+                                       "weight": 1,
+                                       "seg6local": {
+                                               "action": "End.DT46",
+                                               "sidStructure": {
+                                                       "blockLen": 32,
+                                                       "nodeLen": 16,
+                                                       "funcLen": 16,
+                                                       "argLen": 0
+                                               }
+                                       },
+                                       "seg6localContext": {
+                                               "table": 40
+                                       }
+                               }
+                       ]
+               }
+       ],
+       "fcbb:bbbb:1:fe30::/64": [
+               {
+                       "prefix": "fcbb:bbbb:1:fe30::/64",
+                       "prefixLen": 64,
+                       "protocol": "static",
+                       "vrfId": 0,
+                       "vrfName": "default",
+                       "selected": true,
+                       "destSelected": true,
+                       "distance": 1,
+                       "metric": 0,
+                       "installed": true,
+                       "table": 254,
+                       "internalStatus": 16,
+                       "internalFlags": 9,
+                       "internalNextHopNum": 1,
+                       "internalNextHopActiveNum": 1,
+                       "nexthops": [
+                               {
+                                       "flags": 3,
+                                       "fib": true,
+                                       "directlyConnected": true,
+                                       "interfaceName": "Vrf30",
+                                       "active": true,
+                                       "weight": 1,
+                                       "seg6local": {
+                                               "action": "End.DT46",
+                                               "sidStructure": {
+                                                       "blockLen": 32,
+                                                       "nodeLen": 16,
+                                                       "funcLen": 16,
+                                                       "argLen": 0
+                                               }
+                                       },
+                                       "seg6localContext": {
+                                               "table": 30
+                                       }
+                               }
+                       ]
+               }
+       ],
+       "fcbb:bbbb:1:fe40::/64": [
+               {
+                       "prefix": "fcbb:bbbb:1:fe40::/64",
+                       "prefixLen": 64,
+                       "protocol": "static",
+                       "vrfId": 0,
+                       "vrfName": "default",
+                       "selected": true,
+                       "destSelected": true,
+                       "distance": 1,
+                       "metric": 0,
+                       "installed": true,
+                       "table": 254,
+                       "internalStatus": 16,
+                       "internalFlags": 9,
+                       "internalNextHopNum": 1,
+                       "internalNextHopActiveNum": 1,
+                       "nexthops": [
+                               {
+                                       "flags": 3,
+                                       "fib": true,
+                                       "directlyConnected": true,
+                                       "interfaceName": "sr0",
+                                       "active": true,
+                                       "weight": 1,
+                                       "seg6local": {
+                                               "action": "End.X"
+                                       },
+                                       "seg6localContext": {
+                                               "nh6": "2001::2"
+                                       }
+                               }
+                       ]
+               }
+       ]
+}
\ No newline at end of file
index 040be73914e267680c008697a1399c36732c6008..99cbdee2803c372e4775230f4560aaa8e40267ec 100644 (file)
@@ -10,4 +10,7 @@ ip link set Vrf20 up
 ip link add Vrf30 type vrf table 30
 ip link set Vrf30 up
 
+ip link add Vrf40 type vrf table 40
+ip link set Vrf40 up
+
 sysctl -w net.vrf.strict_mode=1
index 565b38f625b7c33a1a02298523c03573110ad8e8..1ea94c8c070c4c793deeeebbaa98a8637be1d76b 100755 (executable)
@@ -172,6 +172,44 @@ def test_srv6_static_sids_sid_readd():
     check_srv6_static_sids(router, "expected_srv6_sids.json")
 
 
+def test_srv6_static_sids_sid_modify():
+    """
+    Modify the static SIDs and verify the routing table
+    """
+    tgen = get_topogen()
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+    router = tgen.gears["r1"]
+
+    def _check_srv6_static_sids(router, expected_route_file):
+        logger.info("checking zebra srv6 static sids")
+        output = json.loads(router.vtysh_cmd("show ipv6 route static json"))
+        expected = open_json_file("{}/{}".format(CWD, expected_route_file))
+        return topotest.json_cmp(output, expected)
+
+    def check_srv6_static_sids(router, expected_file):
+        func = functools.partial(_check_srv6_static_sids, router, expected_file)
+        _, result = topotest.run_and_expect(func, None, count=15, wait=1)
+        assert result is None, "Failed"
+
+    router.vtysh_cmd(
+        """
+        configure terminal
+         segment-routing
+          srv6
+           static-sids
+            sid fcbb:bbbb:1:fe20::/64 locator MAIN behavior uDT46 vrf Vrf40
+        """
+    )
+
+    # FOR DEVELOPER:
+    # If you want to stop some specific line and start interactive shell,
+    # please use tgen.mininet_cli() to start it.
+
+    logger.info("Test for srv6 sids configuration")
+    check_srv6_static_sids(router, "expected_srv6_sids_sid_modify.json")
+
+
 def test_srv6_static_sids_sid_delete_all():
     """
     Remove all static SIDs and verify they get removed