Commit graph

33 commits

Author SHA1 Message Date
Philippe Guibert 27fa9ac4db lib, staticd, isisd: add B6.Encaps codepoint extensions
Add codepoint extensions for END.B6.Encaps instruction.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-04-11 09:36:29 +02:00
Carmine Scarpitta feff426771 lib: Add ifindex to SRv6 SID context
The uA behavior is associated with an interface and the IP address of
the nexthop. However, the current SID context data structure only
includes the IP address. It lacks the interface.

This commit extends the SID context data structure by adding the
ifindex. This extension allows daemons to allocate uA SIDs with
the required interface and IP address.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2025-02-26 07:19:51 +01:00
Philippe Guibert 53263b4b62 isisd, lib: add some codepoints usually shared with other vendors
Some codepoints can not be read by interoperating with CISCO.
This is because PSP/USP flavor are used by default, and the display of
the isis output has to be adapted.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2025-02-14 15:40:42 +01:00
Carmine Scarpitta 312f7b3f8c lib: Add sidStructure in SRv6 SIDs JSON output
The `show ipv6 route json` command displays the IPv6 routing table in
JSON format, including SRv6 SIDs. For each SRv6 SID, it provides
behavior and SID attributes. However, it does not include the SID
structure.

This commit adds the SID structure to the SRv6 SID JSON output.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2025-02-08 22:31:19 +01:00
Yuqing Zhao 7aefc15f64 lib, isisd: Move DEFAULT_SRV6_IFNAME to global srv6.h header
This commit moves DEFAULT_SRV6_IFNAME from isis_srv6.h to srv6.h
because there are other daemons that might want to use it (e.g. staticd).

Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
2025-01-18 10:28:49 +00:00
Yuqing Zhao 2025a0c617 lib: Add a function to print SRv6 Endpoint Behavior Codepoints
Signed-off-by: Yuqing Zhao <galadriel.zyq@alibaba-inc.com>
2025-01-18 10:28:49 +00:00
Carmine Scarpitta 04025514ed lib: Include SID structure in seg6local nexthop
Include SID structure information in seg6local nexthop data structure.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-09-15 17:23:34 +02:00
Carmine Scarpitta 075899dee0 lib: Fix compilation warning
Don't store unnecessary `len` returned by snprintf and snprintfrr function.

Fixes the following compilation warnings:

```
error	15-Aug-2024 13:54:10	In file included from lib/bfd.c:16:
error	15-Aug-2024 13:54:10	In file included from ./lib/zclient.h:22:
error	15-Aug-2024 13:54:10	In file included from ./lib/nexthop.h:14:
error	15-Aug-2024 13:54:10	./lib/srv6.h:338:3: warning: Value stored to 'len' is never read [deadcode.DeadStores]
error	15-Aug-2024 13:54:10	                len += snprintf(str + len, size - len, " USP");
error	15-Aug-2024 13:54:10	                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error	15-Aug-2024 13:54:10	./lib/srv6.h:343:3: warning: Value stored to 'len' is never read [deadcode.DeadStores]
error	15-Aug-2024 13:54:10	                len += snprintfrr(str + len, size - len, " nh6 %pI6", &ctx->nh6);
error	15-Aug-2024 13:54:10	                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error	15-Aug-2024 13:54:10	./lib/srv6.h:347:3: warning: Value stored to 'len' is never read [deadcode.DeadStores]
error	15-Aug-2024 13:54:10	                len += snprintfrr(str + len, size - len, " nh4 %pI4", &ctx->nh4);
error	15-Aug-2024 13:54:10	                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error	15-Aug-2024 13:54:10	./lib/srv6.h:354:3: warning: Value stored to 'len' is never read [deadcode.DeadStores]
error	15-Aug-2024 13:54:10	                len += snprintf(str + len, size - len, " vrf_id %u",
error	15-Aug-2024 13:54:10	                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error	15-Aug-2024 13:54:10	./lib/srv6.h:367:3: warning: Value stored to 'len' is never read [deadcode.DeadStores]
error	15-Aug-2024 13:54:10	                len += snprintf(str + len, size - len, " unknown(%s)", __func__);
error	15-Aug-2024 13:54:10	                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-08-18 13:03:04 +02:00
Philippe Guibert 5d027fc791 lib: add seg6localContext json attribute in nexthop information
Some srv6 behaviors have a context attached that is visible if
no json is requested:

> # show ipv6 route
> [..]
> B>* 2001:db8:1:1:100::/128 [20/0] is directly connected, vrf10, seg6local End.DT6 table 10, weight 1, 00:00:14
> B>* 2001:db8:1:1:200::/128 [20/0] is directly connected, vrf20, seg6local End.DT6 table 20, weight 1, 00:00:14
>

The json does not dump this attribute:
> # show ipv6 route 2001:db8:1:1:100::/128 json
> [..]
>      "nexthops":[
>        {
>          "flags":3,
>          "fib":true,
>          "directlyConnected":true,
>          "interfaceIndex":6,
>          "interfaceName":"vrf10",
>          "active":true,
>          "weight":1,
>          "seg6local":{
>            "action":"End.DT6"
>          },
>        }
>

Add the json support for this.

>      "nexthops":[
>        {
>          "flags":3,
>          "fib":true,
>          "directlyConnected":true,
>          "interfaceIndex":6,
>          "interfaceName":"vrf10",
>          "active":true,
>          "weight":1,
>          "seg6local":{
>            "action":"End.DT6"
>          },
>          "seg6localContext":{
>            "table":10
>          }
>        }
>

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-08-08 11:36:01 +02:00
Carmine Scarpitta 3cb88e6984 lib: Add support for SRv6 SIDs
Add a data structure to represent an SRv6 SID context and the related
management functions (allocate/free).

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +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 f00554ed56 lib: Add function to copy an SRv6 locator
Add a new function to copy an SRv6 locator.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Carmine Scarpitta 021386a34e lib: Add support for SRv6 SID formats
Add functionalities to manage SRv6 SID formats (allocate / free).

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Keelan10 8e7044ba3b bgpd: Free Memory for SRv6 Functions and Locator Chunks
Implement proper memory cleanup for SRv6 functions and locator chunks to prevent potential memory leaks.
The list callback deletion functions have been set.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.asan.bgpd.4180

=================================================================
==4180==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 544 byte(s) in 2 object(s) allocated from:
    #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f8d1709f238 in qcalloc lib/memory.c:105
    #2 0x55d5dba6ee75 in sid_register bgpd/bgp_mplsvpn.c:591
    #3 0x55d5dba6ee75 in alloc_new_sid bgpd/bgp_mplsvpn.c:712
    #4 0x55d5dba6f3ce in ensure_vrf_tovpn_sid_per_af bgpd/bgp_mplsvpn.c:758
    #5 0x55d5dba6fb94 in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:849
    #6 0x55d5dba7f975 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:299
    #7 0x55d5dba7f975 in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3704
    #8 0x55d5dbbb6c66 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3164
    #9 0x7f8d1716f08a in zclient_read lib/zclient.c:4459
    #10 0x7f8d1713f034 in event_call lib/event.c:1974
    #11 0x7f8d1708242b in frr_run lib/libfrr.c:1214
    #12 0x55d5db99d19d in main bgpd/bgp_main.c:510
    #13 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Direct leak of 296 byte(s) in 1 object(s) allocated from:
    #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f8d1709f238 in qcalloc lib/memory.c:105
    #2 0x7f8d170b1d5f in srv6_locator_chunk_alloc lib/srv6.c:135
    #3 0x55d5dbbb6a19 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3144
    #4 0x7f8d1716f08a in zclient_read lib/zclient.c:4459
    #5 0x7f8d1713f034 in event_call lib/event.c:1974
    #6 0x7f8d1708242b in frr_run lib/libfrr.c:1214
    #7 0x55d5db99d19d in main bgpd/bgp_main.c:510
    #8 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
***********************************************************************************

```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
2023-11-29 18:38:49 +04:00
Dmytro Shytyi f20cf1457d bgpd,lib,sharpd,zebra: srv6 introduce multiple segs/SIDs in nexthop
Append zebra and lib to use muliple SRv6 segs SIDs, and keep one
seg SID for bgpd and sharpd.

Note: bgpd and sharpd compilation relies on the lib and zebra files,
i.e if we separate this: lib or zebra or bgpd or sharpd in different
commits - this will not compile.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2023-09-20 15:07:15 +02:00
Carmine Scarpitta 79e37f0ded lib: Define default values for SRv6 flavors attrs
When installing a local SID in the Linux kernel, `lcblock_len` and
`lcnode_fn_len` Netlink attributes are optional. When omitted, the
kernel uses the default values: lcblock_len=32 and lcnode_fn_len=16.
Let's use the same default values in FRR.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:03 +02:00
Carmine Scarpitta f26becb27a lib: Add SRv6 flavors manipulation macros
`struct seg6local_context` contains a `struct seg6local_flavors_info`
that carries SRv6 flavors information. The `seg6local_flavors_info`
data structure contains a field `flv_ops` that indicates which flavors
are enabled for the `seg6local` nexthop. `flv_ops` is a bit-map where
each bit indicates if a particular SRv6 flavor is enabled (bit set to
1) or not (bit set to 0).

This commit defines some macros that can be used to manipulate the SRv6
flavors bit-map:
* CHECK_SRV6_FLV_OP(OPS,OP) - check if a particular flavor is enabled;
* SET_SRV6_FLV_OP(OPS,OP) - enable a particular flavor (OP);
* UNSET_SRV6_FLV_OP(OPS,OP) - disable a particular flavor (OP);
* RESET_SRV6_FLV_OP(OPS) - disable all SRv6 flavors.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:02 +02:00
Carmine Scarpitta 164bcddab7 lib: Add SRv6 flavors info to seg6local nexthop
The RFC 8986 defines the SRv6 Network Programming concept and specifies
the base set of SRv6 behaviors that enables the creation of
interoperable overlays with underlay optimization. In addition, the RFC
8986 introduces the concept of "flavors", additional operations that can
modify or extend the existing SRv6 behaviors.

In the Linux kernel and in FRR, an SRv6 SID is implemented as a route
associated with a `seg6local` nexthop. A `seg6local` nexthop represents
an SRv6 behavior bound to a SID.

The Linux kernel already supports the ability to add a set of flavors
to a `seg6local` nexthop to modify or extend the associated behavior.

This commit aligns the `seg6local` nexthop implementation of FRR to the
Linux kernel. It extends the `seg6local` nexthop implementation by
adding a struct `seg6local_flavors_info` that encodes the SRv6
flavors information.

Currently, the `seg6local_flavors_info` data structure has three
members:
- `tlv_ops` indicates which flavors are enabled for the `seg6local`
  nexthop;
- `lcblock_len`is the length of the Locator-Block part of the SID;
- `lcnode_func_len` is the length of the combined Node and Function
  parts of the SID.

`lcblock_len` and `lcnode_func_len` define the SID structure. They are
required for some behaviors (e.g. NEXT-C-SID and REPLACE-C-SID). For
other flavors (e.g. PSP, USP, USD) these parameters are not required and
can be omitted.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:02 +02:00
Carmine Scarpitta bf386acb93 lib: Add new enum for seg6local flavor operations
The RFC 8986 defines the SRv6 Network Programming concept and specifies
the base set of SRv6 behaviors that enables the creation of
interoperable overlays with underlay optimization. In addition, the RFC
8986 introduces the concept of "flavors", additional operations that can
modify or extend the existing SRv6 behaviors.

This commit adds a new enum type `seg6local_flavor_op` to represent the
SRv6 flavors operations. Currently we define the following flavor
operations:
- PSP (defined in RFC 8986 section #4.16.1)
- USP (defined in RFC 8986 section #4.16.2)
- USD (defined in RFC 8986 section #4.16.3)
- NEXT-C-SID (defined in draft-ietf-spring-srv6-srh-compression-03 #4.1)

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:01 +02:00
Carmine Scarpitta d48f265e15 lib: Add SRv6 behavior codepoints needed for IS-IS
Add more SRv6 endpoint behaviors that are required for implementing
IS-IS SRv6 extensions (RFC 9352).

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2023-09-11 17:35:01 +02: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
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 0494782554 lib: Add support for SRv6 Behavior codepoints
In this commit, we introduce a new enumeration to encode the SRv6
Endpoint Behaviors codepoints defined in the IANA SRv6 Endpoint
Behaviors Registry
(https://www.iana.org/assignments/segment-routing/segment-routing.xhtml).

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-11-08 22:44:23 +01:00
Carmine Scarpitta 6946731314 lib, bgpd: Enhance srv6_locator_chunk_free() API
A programmer can use the `srv6_locator_chunk_free()` function to free
the memory allocated for a `struct srv6_locator_chunk`.

The programmer invokes `srv6_locator_chunk_free()` by passing a single
pointer to the `struct srv6_locator_chunk` to be freed.
`srv6_locator_chunk_free()` uses `XFREE()` to free the memory.
It is the responsibility of the programmer to set the
`struct srv6_locator_chunk` pointer to NULL after freeing memory with
`srv6_locator_chunk_free()`.

This commit modifies the `srv6_locator_chunk_free()` function to take a
double pointer instead of a single pointer. In this way, setting the
`struct srv6_locator_chunk` pointer to NULL is no longer the
programmer's responsibility but is the responsibility of
`srv6_locator_chunk_free()`. This prevents programmers from making
mistakes such as forgetting to set the pointer to NULL after invoking
`srv6_locator_chunk_free()`.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-29 17:04:35 +02:00
Carmine Scarpitta 02b1544a5c lib: Add SRV6_LOCATOR_USID flag to SRv6 locator
In this commit, we add support for a new flag called
`SRV6_LOCATOR_USID`. When the `SRV6_LOCATOR_USID` flag is set, the
routing protocols will install SRv6 behaviors with the uSID in the
dataplane.

This flag is used to specify a locator as a uSID locator. When a locator
is specified as a uSID locator, all the SRv6 SIDs allocated from the
locator by the routing protocols (like BGP) are bound to the SRv6 uSID
behaviors and use the SRv6 uSID codepoints in the BGP update message.

We extend the SRv6 locator implementation to add support for a `usid`
flag. When the `usid` flag is set, the bgpd will install SRv6 behaviors
with the uSID in the dataplane and use the proper SRv6 Endpoint Behavior
codepoint in the BGP advertisement.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-29 02:04:57 +02:00
Carmine Scarpitta 9b7491e1fc lib: Add support for flags to the SRv6 locator
In this commit, we introduce the ability to specify flags for an SRv6
locator. Flags can be used to specify the properties of the locator.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-29 01:31:59 +02:00
Carmine Scarpitta 8bea07e49f zebra, lib: add support for SRv6 End.DT46 behavior
This commit enables zebra to install End.DT46 nexthops into the Linux kernel.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-18 15:37:25 +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
Hiroki Shirokura eab0f8f0a2 lib,sharpd,zebra: update nexthop object with nh_srv6
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 f2867068e6 lib: add new structures for srv6-locator (step2)
This commit is a part of #5853 works that add new structures for
SRv6-locator. This structure will be used by zebra and another
routing daemon and its ZAPI messaging to manage SRv6-locator.
Encoder/decoder for ZAPI stream is also added by this commit.

Real configuration mechanism isn't implemented at this commit.
later commit add real configure implementation. This commit add only
SRv6-locator's structures and misc functions.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00
Hiroki Shirokura 7a4b49bdd1 lib: refactor func prototype seg6local_context2str (step1)
Make seg6local_context2str function's prototype better.
This function is added on commit e496b4203, and function
interface's considering wasn't enough.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:47 -04:00
Hiroki Shirokura e496b42030 bgpd: prefix-sid srv6 l3vpn service tlv
bgpd already supports BGP Prefix-SID path attribute and
there are some sub-types of Prefix-SID path attribute.
This commits makes bgpd to support additional sub-types.
sub-Type-4 and sub-Type-5 for construct the VPNv4 SRv6 backend
with vpnv4-unicast address family.
This path attributes is already supported by Ciscos IOS-XR and NX-OS.

Prefix-SID sub-Type-4 and sub-Type-5 is defined on following
IETF-drafts.

Supports(A-part-of):
- https://tools.ietf.org/html/draft-dawra-idr-srv6-vpn-04
- https://tools.ietf.org/html/draft-dawra-idr-srv6-vpn-05

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2020-01-15 18:20:35 +09:00