Commit Graph

26 Commits

Author SHA1 Message Date
Jafar Al-Gharaibeh
6cfea1aa87
Merge pull request #18146 from FRRouting/mergify/bp/dev/10.3/pr-18023
lib: fix false context information for SRv6 route (backport #18023)
2025-02-13 19:04:18 -06:00
Carmine Scarpitta
2a23344123 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>
(cherry picked from commit 312f7b3f8c)
2025-02-13 18:38:17 +00:00
Philippe Guibert
1f0845ad29 lib: fix false context information for SRv6 route
The seg6local route dumped by 'show ipv6 route' makes think that the USP
flavor is supported, whereas it is not the case. This information is a
context information, and for End, the context information should be
empty.

> # show ipv6 route
> [..]
> I>* fc00:0:4::/128 [115/0] is directly connected, sr0, seg6local End USP, weight 1, 00:49:01

Fix this by suppressing the USP information from the output.

Fixes: e496b42030 ("bgpd: prefix-sid srv6 l3vpn service tlv")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
(cherry picked from commit 658bf0281d)
2025-02-13 17:58:27 +00: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
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
Philippe Guibert
6f45349197 lib: add srv6 bsid to seg6local_context2str
Add SRv6 Binding SID END.B6.Encaps nh6 str to lib.
It is used to display nh6 when one uses 'show ipv6 route'.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-04-03 21:03:26 +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
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
Donald Sharp
1fec35c3c7 lib: Fix free function
The list delete function on creation was set to srv6_locator_chunk_free
Which takes a double pointer and dereferences it to free the data.
When list_delete is called it calls the delete function like this:
                if (*list->del)
                        (*list->del)(node->data);

The data is not passed in by reference and as such we do not have
a double pointer.  Fortunately this list_delete is only really
called on shutdown when the locator was deleted and we do not
have a fun situation where we were suddenly freeing 'something'.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:15:33 -05: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
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
mobash-rasool
6863cf6a5a
Merge pull request #12230 from cscarpitta/fix/replace-inet-top-in-srv6-lib
lib: Use `%pI6`/`%pI4` to print SRv6 seg6local ctx
2022-10-31 12:04:26 +05:30
Carmine Scarpitta
84410eb0fe lib: Use %pI6/%pI4 to print SRv6 seg6local ctx
This commit changes `seg6local_context2str()` to use `%pI6`/`%pI4`
instead of `inet_ntop` to print the SRv6 seg6local context information.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-30 09:15:06 +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
696f43700e lib: add block/node/arg len to SRv6 locator JSON
This commit adds the SRv6 locator's block length, node length and
argument length to the output of the command
"show segment-routing srv6 locator json"

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-18 15:37:26 +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
Donatas Abraitis
a6c8642429 lib: Replace prefix2str for JSON to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:31:08 +02:00
Mark Stapp
4b220ad052 lib: add dtor for srv6 locator chunk list
Add a delete function for the chunk list in an srv6
locator.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-06-07 09:52:33 -04:00
Hiroki Shirokura
326591dcdb lib: fix json style to camel-case instead of underscores
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
David Lamparter
7309092bf4 *: fix first header
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:52:41 +02: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