summaryrefslogtreecommitdiff
path: root/lib/srv6.h
AgeCommit message (Collapse)Author
2024-10-23lib: Include SID structure in seg6local nexthopCarmine Scarpitta
Include SID structure information in seg6local nexthop data structure. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2023-11-30bgpd: Free Memory for SRv6 Functions and Locator ChunksKeelan10
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> (cherry picked from commit 8e7044ba3b806d286ed964746f4e88004035be09)
2023-09-20bgpd,lib,sharpd,zebra: srv6 introduce multiple segs/SIDs in nexthopDmytro Shytyi
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-11lib: Define default values for SRv6 flavors attrsCarmine Scarpitta
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-11lib: Add SRv6 flavors manipulation macrosCarmine Scarpitta
`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-11lib: Add SRv6 flavors info to `seg6local` nexthopCarmine Scarpitta
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-11lib: Add new enum for seg6local flavor operationsCarmine Scarpitta
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-11lib: Add SRv6 behavior codepoints needed for IS-ISCarmine Scarpitta
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-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-11-14Merge pull request #12219 from cscarpitta/feature/srv6-usid-behavior-supportDonatas Abraitis
bgpd, zebra: Add support for SRv6 uSID Behaviors
2022-11-08lib: Add support for SRv6 Behavior codepointsCarmine Scarpitta
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-10-29lib, bgpd: Enhance `srv6_locator_chunk_free()` APICarmine Scarpitta
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-29lib: Add `SRV6_LOCATOR_USID` flag to SRv6 locatorCarmine Scarpitta
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-29lib: Add support for flags to the SRv6 locatorCarmine Scarpitta
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-18zebra, lib: add support for SRv6 End.DT46 behaviorCarmine Scarpitta
This commit enables zebra to install End.DT46 nexthops into the Linux kernel. Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2021-11-28zebra: Add support for json output in srv6 locator detail commandYamato Sugawara
Signed-off-by: Yamato Sugawara <yamato.sugawara@linecorp.com>
2021-06-02lib,sharpd,zebra: update nexthop object with nh_srv6Hiroki Shirokura
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02zebra: add zapi_srv6_locator_chunk_{en,de}codeHiroki Shirokura
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02lib: add new structures for srv6-locator (step2)Hiroki Shirokura
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-02lib: refactor func prototype seg6local_context2str (step1)Hiroki Shirokura
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>
2020-01-15bgpd: prefix-sid srv6 l3vpn service tlvHiroki Shirokura
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>