--- /dev/null
+{
+ "locators":[
+ {
+ "name":"loc1",
+ "prefix":"2001:db8:3::/48",
+ "blockBitsLength":32,
+ "nodeBitsLength":16,
+ "functionBitsLength":16,
+ "argumentBitsLength":0,
+ "statusUp":true,
+ "chunks":[
+ {
+ "prefix":"2001:db8:3::/48",
+ "proto":"system"
+ }
+ ]
+ },
+ {
+ "name":"loc2",
+ "prefix":"2001:db8:3::/48",
+ "blockBitsLength":32,
+ "nodeBitsLength":16,
+ "functionBitsLength":0,
+ "argumentBitsLength":0,
+ "statusUp":true,
+ "chunks":[
+ {
+ "prefix":"2001:db8:3::/48",
+ "proto":"system"
+ }
+ ]
+ },
+ {
+ "name":"loc3",
+ "prefix":"2001:db8:3::/48",
+ "blockBitsLength":32,
+ "nodeBitsLength":16,
+ "functionBitsLength":16,
+ "argumentBitsLength":0,
+ "statusUp":true,
+ "chunks":[
+ {
+ "prefix":"2001:db8:3::/48",
+ "proto":"system"
+ }
+ ]
+ },
+ {
+ "name":"loc4",
+ "prefix":"2001:db8:3::/48",
+ "blockBitsLength":32,
+ "nodeBitsLength":16,
+ "functionBitsLength":0,
+ "argumentBitsLength":0,
+ "statusUp":true,
+ "chunks":[
+ {
+ "prefix":"2001:db8:3::/48",
+ "proto":"system"
+ }
+ ]
+ },
+ {
+ "name":"loc5",
+ "prefix":"2001:db8:3::/48",
+ "blockBitsLength":24,
+ "nodeBitsLength":24,
+ "functionBitsLength":16,
+ "argumentBitsLength":0,
+ "statusUp":true,
+ "chunks":[
+ {
+ "prefix":"2001:db8:3::/48",
+ "proto":"system"
+ }
+ ]
+ },
+ {
+ "name":"loc6",
+ "prefix":"2001:db8:3::/48",
+ "blockBitsLength":24,
+ "nodeBitsLength":24,
+ "functionBitsLength":0,
+ "argumentBitsLength":0,
+ "statusUp":true,
+ "chunks":[
+ {
+ "prefix":"2001:db8:3::/48",
+ "proto":"system"
+ }
+ ]
+ },
+ {
+ "name":"loc7",
+ "prefix":"2001:db8:3::/48",
+ "blockBitsLength":32,
+ "nodeBitsLength":16,
+ "functionBitsLength":10,
+ "argumentBitsLength":0,
+ "statusUp":true,
+ "chunks":[
+ {
+ "prefix":"2001:db8:3::/48",
+ "proto":"system"
+ }
+ ]
+ }
+ ]
+}
check_sharpd_chunk(router, "expected_chunks6.json")
+def test_srv6_locator_func_bits():
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+ router = tgen.gears["r1"]
+
+ def _check_srv6_locator(router, expected_locator_file):
+ logger.info("checking zebra locator status")
+ output = json.loads(router.vtysh_cmd("show segment-routing srv6 locator json"))
+ expected = open_json_file("{}/{}".format(CWD, expected_locator_file))
+ return topotest.json_cmp(output, expected)
+
+ def check_srv6_locator(router, expected_file):
+ func = functools.partial(_check_srv6_locator, router, expected_file)
+ _, result = topotest.run_and_expect(func, None, count=10, wait=0.5)
+ assert result is None, "Failed"
+
+ logger.info("Configure various locators with and without func-len")
+ router.vtysh_cmd(
+ """
+ configure terminal
+ segment-routing
+ srv6
+ locators
+ locator loc1
+ prefix 2001:db8:3::/48 block-len 32 node-len 16
+ locator loc2
+ prefix 2001:db8:3::/48 block-len 32 node-len 16 func-bits 0
+ locator loc3
+ prefix 2001:db8:3::/48 node-len 16
+ locator loc4
+ prefix 2001:db8:3::/48 node-len 16 func-bits 0
+ locator loc5
+ prefix 2001:db8:3::/48
+ locator loc6
+ prefix 2001:db8:3::/48 func-bits 0
+ locator loc7
+ prefix 2001:db8:3::/48 block-len 32 node-len 16 func-bits 10
+ """
+ )
+ check_srv6_locator(router, "expected_locators7.json")
+
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))
struct listnode *node = NULL;
uint8_t expected_prefixlen;
struct srv6_sid_format *format;
+ int idx = 0;
locator->prefix = *prefix;
- func_bit_len = func_bit_len ?: ZEBRA_SRV6_FUNCTION_LENGTH;
+ /* Only set default if func_bit_len was not provided in command */
+ if (func_bit_len == 0 && !argv_find(argv, argc, "func-bits", &idx))
+ func_bit_len = ZEBRA_SRV6_FUNCTION_LENGTH;
expected_prefixlen = prefix->prefixlen;
format = locator->sid_format;