diff options
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; |
