Commit graph

38 commits

Author SHA1 Message Date
Mark Stapp 7c98a27f3e zebra: clean up -Wshadow compiler warnings
Clean up variable-shadowing compiler warnings.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-04-08 14:41:27 -04:00
Donald Sharp 24d293277f zebra: Convert the zrouter.client_list to a typesafe list
This list should just be a typesafe list.

Signed-off-by: Donald Sharp <donaldsharp72@gmail.com>
2025-03-19 13:27:36 -04:00
Carmine Scarpitta 13f3c7c679 zebra: Remove tests for srv6_locator_alloc failure
`srv6_locator_alloc` can never fail. Let's remove the tests for
allocation failure.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-12-22 09:01:59 +01:00
Carmine Scarpitta 354f9e9009 zebra: Fix compilation warning
Make sure the variable `srv6` is not NULL before dereferencing it.

Fixes the following compilation warnings:

```
error	15-Aug-2024 14:20:01	zebra/zebra_srv6_vty.c:974:8: warning: Access to field 'locators' results in a dereference of a null pointer (loaded from variable 'srv6') [core.NullDereference]
error	15-Aug-2024 14:20:01	                for (ALL_LIST_ELEMENTS_RO(srv6->locators, node, locator)) {
error	15-Aug-2024 14:20:01	                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error	15-Aug-2024 14:20:01	./lib/linklist.h:345:11: note: expanded from macro 'ALL_LIST_ELEMENTS_RO'
error	15-Aug-2024 14:20:01	        (node) = listhead(list), ((data) = NULL);                              \
error	15-Aug-2024 14:20:01	                 ^~~~~~~~~~~~~~
error	15-Aug-2024 14:20:01	./lib/linklist.h:63:22: note: expanded from macro 'listhead'
error	15-Aug-2024 14:20:01	#define listhead(X) ((X) ? ((X)->head) : NULL)
error	15-Aug-2024 14:20:01	                     ^
```

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-08-18 13:03:04 +02:00
Carmine Scarpitta 779d4c2702 zebra: CLI to specify format of an SRv6 locator
Add the CLI to choose the SID format of a locator. When the SID format
of a locator is changed, the SIDs allocated from that locator might no
longer be valid (for example, because the new format might involve a
different SID allocation schema). In such a case, it is necessary to
notify all the zclients so that they can withdraw/uninstall the old SIDs
that use the previous format and allocate/install/advertise the new SIDs
based on the new format.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Carmine Scarpitta bf10e4437e zebra: Add support for SRv6 SID blocks
An SRv6 block is an IPv6 prefix from which SIDs are allocated. This
commit adds support for SRv6 SID blocks. Specifically, it adds a data
structure to store information about an SRv6 block (e.g., its occupancy
status, which SIDs have been allocated and which are available, which
SID format is used for that block, etc.). It also adds some functions to
manage the block (allocate / free / lookup).

These functions will be used in the next commits to support the
allocation of SIDs from a block in the SID Manager.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Carmine Scarpitta 51d3cd8a00 zebra: CLI to override default SID format config
Add CLI commands to support overriding default configuration of the SID
format.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Carmine Scarpitta 1298867671 zebra: Add support for SRv6 SID formats
Add functionalities to manage SRv6 SID formats (register / unregister /
lookup) and create two SID formats upon SRv6 Manager initialization:
`uncompressed-f4024` and `usid-f3216`.

In future commits, we will add the CLI to allow the user to choose
between the two formats.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Philippe Guibert 890b67d7a9 zebra: display srv6 encapsulation source-address when configured
The 'show running-config' does not display the ipv6 source address
when a locator is not configured. Fix this by systematically displaying
the ipv6 source address.

Fixes: 6a0956169b ("zebra: Add encap source address to SRv6 config write function")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-06-04 09:55:21 +02:00
Carmine Scarpitta 6a0956169b zebra: Add encap source address to SRv6 config write function
When writing the SRv6 config from zebra, we must also include the source
address of outer encapsulating IPv6 header.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:58:35 +01:00
Carmine Scarpitta 0c9b491035 zebra: Add CLI command to verify SRv6 Manager
Add a new CLI command `show segment-routing srv6 manager [json]` to
verify the overall SRv6 state. The current output displays only the
configured source address of outer encapsulating IPv6 header. The output
can be extended in the future to show more information, including
summary SRv6 information and supported capabilities.

Example:

```
r1# show segment-routing srv6 manager
Parameters:
  Encapsulation:
    Source Address:
      Configured: fc00:0:1::1

r1# show segment-routing srv6 manager json
{
  "parameters":{
    "encapsulation":{
      "sourceAddress":{
        "configured":"fc00:0:1::1"
      }
    }
  }
}
```

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:58:35 +01:00
Carmine Scarpitta 69bff19c43 zebra, lib, vtysh: Add CLI cmd to set/unset SRv6 encap source address
- Add a new node `SRV6_ENCAP_NODE` to the CLI graph. This node allows
users to configure encapsulation parameters for SRv6, including the
source address of the outer encapsulating IPv6 header.

- Install a new CLI command `source-address` under the
`SRV6_ENCAP_NODE` node. This command is used to configure the source
address of the outer encapsulating IPv6 header.

- Install a new CLI command `no source-address` under the
`SRV6_ENCAP_NODE` node. This command is used to unset the
source address of the outer encapsulating IPv6 header and restore the
default source address.

Examples:

```
router# segment-routing
router(sr)# srv6
router(srv6)# encapsulation
router(srv6-encap)# source-address fc00:0:1::1
```

```
router# segment-routing
router(sr)# srv6
router(srv6)# encapsulation
router(srv6-encap)# no source-address
```

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-12-14 14:58:33 +01:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Carmine Scarpitta dd8b193e8d zebra: Add missing newline in SRv6 config write
The `behavior usid` command is installed under the SRv6 Locator node in
the zebra VTY. However, in the SRv6 config write function this command
is wrongly put on the same line as the `prefix X:X::X:X/M` command.
This causes a failure when an SRv6 uSID locator is configured in zebra
and  `frr-reload.py` is used to reload the FRR configuration.

This commit prepends a newline character to the  `behavior usid` command
in the SRv6 config write function. The output of `show running-config`
before and after this commit is shown below.

Before:

```
Building configuration...

Current configuration:
!
frr version 8.5-dev
!
segment-routing
 srv6
  locators
   locator loc1
    prefix fc00:0:1::/48 block-len 32 node-len 16    behavior usid
   exit
   !
  exit
  !
 exit
 !
exit
!
end
```

After:

```
Building configuration...

Current configuration:
!
segment-routing
 srv6
  locators
   locator loc1
    prefix fc00:0:1::/48 block-len 32 node-len 16
    behavior usid
   exit
   !
  exit
  !
 exit
 !
exit
!
end
```

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-12-05 10:22:06 +01:00
Ryoga Saito 3afb06d324 bgpd: Fix the other of SR locator parameters
The latest FRR's frr-reload.py is broken and we can't reload FRR
gracefully with segment routing locator configuration (if we
execute frr-reload.py, FRR will stop suddenly).

The root cause of this issue is very simple. FRR will display the
current configuration like this (the below is the result of
"show running-configuration").

``
segment-routing
 srv6
  locators
   locator default
    prefix fd00:1:0:1::/64 block-len 40 node-len 24 func-bits 16
   exit
   !
  exit
  !
 exit
 !
exit
```

However, FRR doesn't accept segment routing locator parameters
if we specify block-len and node-len earlier than func-bits.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2022-11-22 22:59:46 +09:00
Donatas Abraitis 84f784fafa
Merge pull request #12219 from cscarpitta/feature/srv6-usid-behavior-support
bgpd, zebra: Add support for SRv6 uSID Behaviors
2022-11-14 16:13:39 +02:00
Carmine Scarpitta 3a7e1f656e zebra: Add behavior usid command to VTY
Install a new command `behavior usid` into the `SRV6_LOC_NODE` CLI node.

This command allows the user to set/unset the `SRV6_LOCATOR_USID` flag
for an SRv6 locator. The `SRV6_LOCATOR_USID` flag indicates whether a
locator is a uSID locator or not. When the flag is set, the routing
daemons (e.g., bgpd) will install SRv6 behaviors with the uSID in the
dataplane.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-11-08 22:44:24 +01:00
Carmine Scarpitta a3ff3dff3f lib,zebra: Add SRv6 uSID info to VTY output
In this commit, we extend to print the `SRV6_LOCATOR_USID` flag.
The output appears as follows:

```
{
  "locators":[
    {
      "name":"loc1",
      "prefix":"fc00:0:1::/48",
      "blockBitsLength":32,
      "nodeBitsLength":16,
      "functionBitsLength":16,
      "argumentBitsLength":0,
      "uSID":true,
      "statusUp":true,
      "chunks":[
        {
          "prefix":"fc00:0:1::/48",
          "proto":"bgp"
        }
      ]
    }
  ]
}
```

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-11-08 22:44:23 +01:00
David Lamparter 89cb86aeb0 build, vtysh: extract vtysh commands from .xref
Rather than running selected source files through the preprocessor and a
bunch of perl regex'ing to get the list of all DEFUNs, use the data
collected in frr.xref.

This not only eliminates issues we've been having with preprocessor
failures due to nonexistent header files, but is also much faster.
Where extract.pl would take 5s, this now finishes in 0.2s.  And since
this is a non-parallelizable build step towards the end of the build
(dependent on a lot of other things being done already), the speedup is
actually noticeable.

Also files containing CLI no longer need to be listed in `vtysh_scan`
since the .xref data covers everything.  `#ifndef VTYSH_EXTRACT_PL`
checks are equally obsolete.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-26 17:12:34 +01:00
Carmine Scarpitta 537b8b13f9 zebra: Do not allow SRv6 func_bit_len > 20
Currently, the SID transposition algorithm implemented in bgpd handles
incorrectly the SRv6 locators with function length greater than 20 bits.
To prevent issues, we currently limit the function length to 20 bits.

This limit will be removed when the bgpd SID transposition is fixed.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-18 16:08:24 +02:00
Carmine Scarpitta 34e3711fb4 zebra: Ensure SRv6 SID length does not exceed 128
According to RFC 8986, the SRv6 SID length cannot exceed 128 bits. This
commit ensures that the condition
`block_len + node_len + function_len + arg_len <= 128` is satisfied when
a new SRv6 locator is created.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-18 16:08:24 +02:00
Carmine Scarpitta d9d3179942 zebra: add missing bits len to SRv6 locator detail
This commit adds SRv6 locator's block length, node length and argument
length to the output of the command
"show segment-routing srv6 locator NAME detail [json]".

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-18 15:37:26 +02:00
Carmine Scarpitta 780c13eb8d zebra: add block/node/arg len to zebra sr config
This commit adds the SRv6 locator's block length, node length and
argument length to the SRv6 configuration.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-18 15:37:25 +02:00
Carmine Scarpitta 5e04508c92 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>
2022-10-18 15:37:25 +02:00
Ryoga Saito 8bcda259ec zebra: expand func-bits
In order to set function length of SID freely, this PR relieves the
lower limitation of `func-bits`.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2022-10-07 18:26:52 +09:00
Ryoga Saito 85521aaabd zebra: add default SRv6 Function length
Add default SRv6 Function Length for usecases like SRv6 L3VPN. The
default value (16) comes from the default Function length for SRv6
L3VPN in BGPd.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2022-10-07 11:34:20 +09:00
Nobuhiro MIKI fbd01eaa41 zebra: output optional param "func-bits" for SRv6
Signed-off-by: Nobuhiro MIKI <nmiki@yahoo-corp.jp>
2022-03-28 17:37:45 +09:00
Donatas Abraitis e69ae079b7
Merge pull request #9899 from Drumato/zebra-srv6-locator-detail-json-support
zebra: Add support for json output in srv6 locator detail command
2021-12-14 09:11:36 +02:00
Yamato Sugawara 559f4b2f2a zebra: Add support for json output in srv6 locator detail command
Signed-off-by: Yamato Sugawara <yamato.sugawara@linecorp.com>
2021-11-28 23:53:41 +00:00
Donatas Abraitis 962af8a8cd zebra: Convert vty_out to vty_json for JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:49:46 +02:00
Hiroki Shirokura 0a735cd523 zebra: add srv6's no commands
CURRENT_CONFIGURATION:
configure terminal
 segment-routing
  srv6
   locators
    locator loc1
    locator loc2
    locator loc3

CMD1: delete single locator
configure terminal
 segment-routing
  srv6
   locators
    no locator loc1

CMD2: delete srv6 whole config (== delete all locators)
configure terminal
 segment-routing
  no srv6

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-09-07 12:54:39 +00:00
Igor Ryzhov 07679ad98a *: explicitly print "exit" at the end of every node config
There is a possibility that the same line can be matched as a command in
some node and its parent node. In this case, when reading the config,
this line is always executed as a command of the child node.

For example, with the following config:
```
router ospf
 network 193.168.0.0/16 area 0
!
mpls ldp
 discovery hello interval 111
!
```
Line `mpls ldp` is processed as command `mpls ldp-sync` inside the
`router ospf` node. This leads to a complete loss of `mpls ldp` node
configuration.

To eliminate this issue and all possible similar issues, let's print an
explicit "exit" at the end of every node config.

This commit also changes indentation for a couple of existing exit
commands so that all existing commands are on the same level as their
corresponding node-entering commands.

Fixes #9206.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-23 22:08:20 +03:00
Hiroki Shirokura f29aed7480 *: fix code format accourding to checkpatch
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura ac6a9479af zebra: add zapi_srv6_locator_chunk_{en,de}code
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura daedb8b3cf zebra: rewrite locator_prefix_cmd with DEFPY
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura 4df9d8592b *: fix code format accourding to checkpatch
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura 0097897734 zebra: add new CLI to manipulate srv6-locator (step2)
This commit is a part of #5853 works that add new clis to
configure SRv6 locator and its show commands.
Following clis are added on this commit.

vtysh -c 'conf te' \
  -c 'segment-routing' \
  -c ' srv6' \
  -c '  locators' \
  -c '   locator LOC1' \
  -c '    prefix A::/64'

- "show segment-routing srv6 sid [json]"
- "show segment-routing srv6 locator [json]"
- "show segment-routing srv6 locator NAME detail [json]"
- "show runnning-config" (make it to print srv6 configuration)

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00
Hiroki Shirokura 6c0a7c0941 *: new cli-nodes for SRv6 manager (step2)
This commit is a part of #5853 that add new cmd-node for SRv6 configuration.
This commit just add cmd-node and moving node cli only, acutual SRv6 config
command isn't added. (that is added later commit. of this branch)

new cli nodes:
* SRv6
* SRv6-locators
* SRv6-locator

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00