mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
zebra: SRv6 Allow func-bits length 0
In current code, when a user inputs function length as 0 for a locator, the code treats it as a "not configured" value and assigned default (16) value to it. This is wrong since the locator default is only to be used when the function-bits (0-64) is not specified in the locator prefix config. Fix is to use default value only when the user has not specified the func-bits Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
This commit is contained in:
parent
3dd4d417be
commit
73fa09bfb2
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue