diff options
| -rw-r--r-- | isisd/isis_te.c | 24 | ||||
| -rw-r--r-- | staticd/static_vty.c | 2 | ||||
| -rw-r--r-- | tests/topotests/static_srv6_sids/expected_srv6_sids_srv6_disable.json | 1 | ||||
| -rwxr-xr-x | tests/topotests/static_srv6_sids/test_static_srv6_sids.py | 83 | 
4 files changed, 90 insertions, 20 deletions
diff --git a/isisd/isis_te.c b/isisd/isis_te.c index c9af39ce5a..32492ae0c0 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -1193,32 +1193,18 @@ static int lsp_to_edge_cb(const uint8_t *id, uint32_t metric, bool old_metric,  			"    |- Link Edge (Unknown) to destination vertex (%s)",  			print_sys_hostname(id)); +	/* Then search if there is a reverse Edge to link them */  	dst = ls_find_edge_by_destination(args->ted, edge->attributes);  	if (dst) {  		/* Attach remote link if not set */ -		if (edge->source && dst->destination == NULL) { -			vertex = edge->source; -			if (vertex->incoming_edges) -				listnode_add_sort_nodup(vertex->incoming_edges, -							dst); +		if (dst->destination == NULL) { +			listnode_add_sort_nodup(vertex->incoming_edges, dst);  			dst->destination = vertex;  		}  		/* and destination vertex to this edge if not set */ -		if (dst->source && edge->destination == NULL) { -			vertex = dst->source; -			if (vertex->incoming_edges) -				listnode_add_sort_nodup(vertex->incoming_edges, -							edge); -			edge->destination = vertex; -		} -	} else { -		/* Search dst. Vertex by Extended Reach. ID if not found */  		if (edge->destination == NULL) { -			vertex = ls_find_vertex_by_key(args->ted, -						       sysid_to_key(id)); -			if (vertex && vertex->incoming_edges) -				listnode_add_sort_nodup(vertex->incoming_edges, -							edge); +			vertex = dst->source; +			listnode_add_sort_nodup(vertex->incoming_edges, edge);  			edge->destination = vertex;  		}  	} diff --git a/staticd/static_vty.c b/staticd/static_vty.c index 13a61e52c7..a6b4415e28 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -1159,7 +1159,7 @@ DEFUN_NOSH (static_srv6, static_srv6_cmd,  	return CMD_SUCCESS;  } -DEFUN_YANG_NOSH (no_static_srv6, no_static_srv6_cmd, +DEFUN_YANG (no_static_srv6, no_static_srv6_cmd,        "no srv6",        NO_STR        "Segment Routing SRv6\n") diff --git a/tests/topotests/static_srv6_sids/expected_srv6_sids_srv6_disable.json b/tests/topotests/static_srv6_sids/expected_srv6_sids_srv6_disable.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/tests/topotests/static_srv6_sids/expected_srv6_sids_srv6_disable.json @@ -0,0 +1 @@ +{}
\ No newline at end of file diff --git a/tests/topotests/static_srv6_sids/test_static_srv6_sids.py b/tests/topotests/static_srv6_sids/test_static_srv6_sids.py index 4bed5bf788..565b38f625 100755 --- a/tests/topotests/static_srv6_sids/test_static_srv6_sids.py +++ b/tests/topotests/static_srv6_sids/test_static_srv6_sids.py @@ -251,6 +251,89 @@ def test_srv6_static_sids_sid_readd_all():      check_srv6_static_sids(router, "expected_srv6_sids.json") +def test_srv6_static_sids_srv6_disable(): +    """ +    Disable SRv6 +    """ +    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, exact=True) + +    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 +          no srv6 +        """ +    ) + +    # 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_srv6_disable.json") + + +def test_srv6_static_sids_srv6_reenable(): +    """ +    Re-enable SRv6 +    """ +    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 +           locators +            locator MAIN +             prefix fcbb:bbbb:1::/48 block-len 32 node-len 16 func-bits 16 +            ! +           ! +           static-sids +            sid fcbb:bbbb:1::/48 locator MAIN behavior uN +            sid fcbb:bbbb:1:fe10::/64 locator MAIN behavior uDT4 vrf Vrf10 +            sid fcbb:bbbb:1:fe20::/64 locator MAIN behavior uDT6 vrf Vrf20 +            sid fcbb:bbbb:1:fe30::/64 locator MAIN behavior uDT46 vrf Vrf30 +            sid fcbb:bbbb:1:fe40::/64 locator MAIN behavior uA interface sr0 nexthop 2001::2 +        """ +    ) + +    # 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.json") + +  if __name__ == "__main__":      args = ["-s"] + sys.argv[1:]      sys.exit(pytest.main(args))  | 
