This commit is contained in:
Rajasekar Raja 2025-04-29 22:23:20 +00:00 committed by GitHub
commit f8757a26da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 155 additions and 1 deletions

View file

@ -0,0 +1,109 @@
{
"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"
}
]
}
]
}

View file

@ -142,6 +142,49 @@ def test_srv6():
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))

View file

@ -803,7 +803,9 @@ DEFPY (locator_prefix,
struct srv6_sid_format *format;
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 && !strstr(vty->buf, "func-bits"))
func_bit_len = ZEBRA_SRV6_FUNCTION_LENGTH;
expected_prefixlen = prefix->prefixlen;
format = locator->sid_format;