]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: add new CLI args "block-len" and "node-len"
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Fri, 22 Jul 2022 22:29:08 +0000 (00:29 +0200)
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Tue, 18 Oct 2022 13:37:25 +0000 (15:37 +0200)
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>
zebra/zebra_srv6_vty.c

index daac4cade0902a58cf104c187b19419712dc1ce4..b9ad3821a140582142521c355693c40751c7d702 100644 (file)
@@ -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;