diff options
| author | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2022-07-23 00:29:08 +0200 |
|---|---|---|
| committer | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2022-10-18 15:37:25 +0200 |
| commit | 5e04508c92fa62c7ac7a371d5ac49451b41ea85a (patch) | |
| tree | c34ef3843648604aea6db83502136e8f752f3eec /zebra/zebra_srv6_vty.c | |
| parent | 272c6d5db128ff7450fe9fcd16c046160594deb3 (diff) | |
zebra: add new CLI args "block-len" and "node-len"
In the current implementation, an SRv6 locator only supports the
following structure:
* node-len = 24
* block-len = prefix-len - 24
* function-len = <configurable>
* argument-len = 0
This commit adds two optional arguments to the locator_prefix CLI
command: "node-len" and "block-len". These arguments allows an user to
configure the block length and node length of a SRv6 locator according
to the following logic:
* the node-len + block-len = prefix-len constraint must always be
satisfied;
* if node-len and block-len are both omitted, they are calculated as in
the current implementation (for backward compatibility reasons)
* if node-len is omitted, its value is computed as
prefix-len - block-len
* if block-len is omitted, its value is computed as
prefix-len - node-len
Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
Diffstat (limited to 'zebra/zebra_srv6_vty.c')
| -rw-r--r-- | zebra/zebra_srv6_vty.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c index daac4cade0..b9ad3821a1 100644 --- a/zebra/zebra_srv6_vty.c +++ b/zebra/zebra_srv6_vty.c @@ -271,42 +271,44 @@ DEFUN (no_srv6_locator, DEFPY (locator_prefix, locator_prefix_cmd, - "prefix X:X::X:X/M$prefix [func-bits (0-64)$func_bit_len]", + "prefix X:X::X:X/M$prefix [func-bits (0-64)$func_bit_len] \ + [block-len (16-64)$block_bit_len] [node-len (16-64)$node_bit_len]", "Configure SRv6 locator prefix\n" "Specify SRv6 locator prefix\n" "Configure SRv6 locator function length in bits\n" - "Specify SRv6 locator function length in bits\n") + "Specify SRv6 locator function length in bits\n" + "Configure SRv6 locator block length in bits\n" + "Specify SRv6 locator block length in bits\n" + "Configure SRv6 locator node length in bits\n" + "Specify SRv6 locator node length in bits\n") { VTY_DECLVAR_CONTEXT(srv6_locator, locator); struct srv6_locator_chunk *chunk = NULL; struct listnode *node = NULL; - if (prefix->prefixlen != 64) { - vty_out(vty, - "%% Invalid argument: Unsupported locator format\n"); - return CMD_WARNING_CONFIG_FAILED; - } - locator->prefix = *prefix; func_bit_len = func_bit_len ?: ZEBRA_SRV6_FUNCTION_LENGTH; - /* - * TODO(slankdev): please support variable node-bit-length. - * In draft-ietf-bess-srv6-services-05#section-3.2.1. - * Locator block length and Locator node length are defined. - * Which are defined as "locator-len == block-len + node-len". - * In current implementation, node bits length is hardcoded as 24. - * It should be supported various val. - * - * Cisco IOS-XR support only following pattern. - * (1) Teh locator length should be 64-bits long. - * (2) The SID block portion (MSBs) cannot exceed 40 bits. - * If this value is less than 40 bits, - * user should use a pattern of zeros as a filler. - * (3) The Node Id portion (LSBs) cannot exceed 24 bits. - */ - locator->block_bits_length = ZEBRA_SRV6_LOCATOR_BLOCK_LENGTH; - locator->node_bits_length = ZEBRA_SRV6_LOCATOR_NODE_LENGTH; + /* Resolve optional arguments */ + if (block_bit_len == 0 && node_bit_len == 0) { + block_bit_len = + prefix->prefixlen - ZEBRA_SRV6_LOCATOR_NODE_LENGTH; + node_bit_len = ZEBRA_SRV6_LOCATOR_NODE_LENGTH; + } else if (block_bit_len == 0) { + block_bit_len = prefix->prefixlen - node_bit_len; + } else if (node_bit_len == 0) { + node_bit_len = prefix->prefixlen - block_bit_len; + } else { + if (block_bit_len + node_bit_len != prefix->prefixlen) { + vty_out(vty, + "%% block-len + node-len must be equal to the selected prefix length %d\n", + prefix->prefixlen); + return CMD_WARNING_CONFIG_FAILED; + } + } + + locator->block_bits_length = block_bit_len; + locator->node_bits_length = node_bit_len; locator->function_bits_length = func_bit_len; locator->argument_bits_length = 0; |
