Commit graph

50 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
Rajasekar Raja 5a63cf4c0d zebra: ensure proper return for failure for Sid allocation
The functions alloc_srv6_sid_func_explicit/dynamic expect to return bool
but we have places where we return a -1 or NULL which the caller is
assuming as a True/Valid and ending up allocating Sid

Without Fix:
2025/03/10 21:44:04.295350 ZEBRA: [XWV20-TGK70] alloc_srv6_sid_func_explicit: trying to allocate explicit SID function 65088 from block fcbb:bbbb::/32
2025/03/10 21:44:04.295351 ZEBRA: [MM61M-TQZNP] alloc_srv6_sid_func_explicit: elib s 10000 e 20000 wlib s 1000 ewlib s 30000 e 1000 SID_FUNC 65088
2025/03/10 21:44:04.295352 ZEBRA: [QGHMB-SWNFW] alloc_srv6_sid_func_explicit: function 65088 is outside ELIB [10000/20000] and EWLIB alloc ranges [30000/1000]
2025/03/10 21:44:04.295367 ZEBRA: [H0GZA-NNSWJ] get_srv6_sid_explicit: allocated explicit SRv6 SID fcbb:bbbb:1:fe40:: for context End.X nh6 2001::2
2025/03/10 21:44:04.295368 ZEBRA: [XBBYD-T1Q7P] srv6_manager_get_sid_internal: got new SRv6 SID for ctx End.X nh6 2001::2: sid_value=fcbb:bbbb:1:fe40:: (func=65088) (proto=4, instance=0, sessionId=0), notifying all clients

With Fix:
2025/03/10 22:04:25.052235 ZEBRA: [MM61M-TQZNP] alloc_srv6_sid_func_explicit: elib s 30000 e 31000 wlib s 31000 ewlib s 30000 e 31000 SID_FUNC 65056
2025/03/10 22:04:25.052236 ZEBRA: [YHMRC-EMYNX] alloc_srv6_sid_func_explicit: function 65056 is outside ELIB [30000/31000] and EWLIB alloc ranges [30000/31000]
2025/03/10 22:04:25.052254 ZEBRA: [XSG8X-Q2XJX] get_srv6_sid_explicit: invalid SM request arguments: failed to allocate SID function 65056 from block fcbb:bbbb::/32
2025/03/10 22:04:25.052257 ZEBRA: [YC52T-427SJ] srv6_manager_get_sid_internal: not got SRv6 SID for ctx End.DT6 vrf_id 4, sid_value=fcbb:bbbb:1:fe20::, locator_name=MAIN
root@rajasekarr:/tmp/topotests/static_srv6_sids.test_static_srv6_sids/r1#

Ticket :#
Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2025-03-10 15:26:38 -07:00
Carmine Scarpitta ec5ff367b1 staticd: Extend static_zebra_request_srv6_sid to request SRv6 uA SIDs
In order to configure an SRv6 uA SID in staticd, staticd should request
SRv6 SID Manager to allocate a SID bound to the uA behavior.
Currently, `static_zebra_request_srv6_sid` does not support requesting
SIDs bound to the uA behavior.

This commit extends the `static_zebra_request_srv6_sid` function to
enable staticd to request SIDs bound to the uA behavior.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2025-02-26 07:19:51 +01:00
Carmine Scarpitta a879aebf69 zebra: Fix SRv6 SID Manager
The SRv6 SID Manager does not allow allocating an SRv6 End/uN function
even though it is already supported by staticd.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2025-01-30 19:28:34 +01:00
Carmine Scarpitta afd9d3f924 zebra: Fix wrong debug macro in release_srv6_sid_func_dynamic
`ZEBRA_DEBUG_SRV6` is not the correct macro to evaluate if SRv6 debug is enabled or not.

The correct macro is `IS_ZEBRA_DEBUG_SRV6`.

Fix this by replacing `ZEBRA_DEBUG_SRV6` with `IS_ZEBRA_DEBUG_SRV6`.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-03 08:45:03 +01:00
Carmine Scarpitta 69b1acf4e3 zebra: Fix wrong debug macro in release_srv6_sid_func_explicit
`ZEBRA_DEBUG_SRV6` is not the correct macro to evaluate if SRv6 debug is enabled or not.

The correct macro is `IS_ZEBRA_DEBUG_SRV6`.

Fix this by replacing `ZEBRA_DEBUG_SRV6` with `IS_ZEBRA_DEBUG_SRV6`.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-03 08:44:41 +01:00
Carmine Scarpitta d1810d5c7f zebra: Fix wrong debug macro in alloc_srv6_sid_func_dynamic
`ZEBRA_DEBUG_SRV6` is not the correct macro to evaluate if SRv6 debug is enabled or not.

The correct macro is `IS_ZEBRA_DEBUG_SRV6`.

Fix this by replacing `ZEBRA_DEBUG_SRV6` with `IS_ZEBRA_DEBUG_SRV6`.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-03 08:44:23 +01:00
Carmine Scarpitta 58fd136f44 zebra: Fix wrong debug macro in alloc_srv6_sid_func_explicit
`ZEBRA_DEBUG_SRV6` is not the correct macro to evaluate if SRv6 debug is enabled or not.

The correct macro is `IS_ZEBRA_DEBUG_SRV6`.

Fix this by replacing `ZEBRA_DEBUG_SRV6` with `IS_ZEBRA_DEBUG_SRV6`.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-03 08:43:55 +01:00
Carmine Scarpitta a56e790b07 zebra: Fix wrong debug macro in release_srv6_sid_func_dynamic
`ZEBRA_DEBUG_SRV6` is not the correct macro to evaluate if SRv6 debug is enabled or not.

The correct macro is `IS_ZEBRA_DEBUG_SRV6`.

Fix this by replacing `ZEBRA_DEBUG_SRV6` with `IS_ZEBRA_DEBUG_SRV6`.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-03 08:43:38 +01:00
Carmine Scarpitta 8e96fcece2 zebra: Fix wrong debug macro in release_srv6_sid_func_explicit
`ZEBRA_DEBUG_SRV6` is not the correct macro to evaluate if SRv6 debug is enabled or not.

The correct macro is `IS_ZEBRA_DEBUG_SRV6`.

Fix this by replacing `ZEBRA_DEBUG_SRV6` with `IS_ZEBRA_DEBUG_SRV6`.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-03 08:43:17 +01:00
Carmine Scarpitta 4710baa7bb zebra: Fix wrong debug macro in alloc_srv6_sid_func_dynamic
`ZEBRA_DEBUG_SRV6` is not the correct macro to evaluate if SRv6 debug is enabled or not.

The correct macro is `IS_ZEBRA_DEBUG_SRV6`.

Fix this by replacing `ZEBRA_DEBUG_SRV6` with `IS_ZEBRA_DEBUG_SRV6`.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-03 08:42:58 +01:00
Carmine Scarpitta 973c4750e1 zebra: Fix wrong debug macro in alloc_srv6_sid_func_explicit
`ZEBRA_DEBUG_SRV6` is not the correct macro to evaluate if SRv6 debug is enabled or not.

The correct macro is `IS_ZEBRA_DEBUG_SRV6`.

Fix this by replacing `ZEBRA_DEBUG_SRV6` with `IS_ZEBRA_DEBUG_SRV6`.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-11-03 08:42:36 +01:00
Donald Sharp 5f6200d334 zebra: Deconfuse clang-sa about possible NULL pointer
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-10-29 16:05:15 -04:00
Philippe Guibert a7fec9c387 zebra: add 'debug zebra srv6' command
Add a specific debug command to handle srv6 troubleshooting.
Move the srv6 traces that initially were under 'debug zebra packet'
debug.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-10-28 16:40:33 +01:00
Carmine Scarpitta 8b206b0cd7 zebra: Remove duplicate #include <stdio.h>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:39:34 +02:00
Carmine Scarpitta 4ca8332922 zebra: Remove duplicate #include <string.h>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:39:14 +02:00
Carmine Scarpitta 22aa0ffb81 zebra: Remove duplicate #include <stdlib.h>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:38:55 +02:00
Carmine Scarpitta c432aa0bb4 zebra: Remove duplicate #include <arpa/inet.h>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:38:27 +02:00
Carmine Scarpitta 0a68626e48 zebra: Remove duplicate #include <netinet/in.h>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-07-24 23:38:04 +02:00
Carmine Scarpitta df97a9d133 zebra: Fix NULL pointer dereference
The `locator` pointer is dereferenced before ensuring it is not NULL.
Fix the issue by checking that the pointer is not NULL before
dereferencing it.

Fixes 1594013

** CID 1594013:  Null pointer dereferences  (REVERSE_INULL)
/zebra/zebra_srv6.c: 961 in zebra_srv6_sid_compose()

________________________________________________________________________________________________________
*** CID 1594013:  Null pointer dereferences  (REVERSE_INULL)
/zebra/zebra_srv6.c: 961 in zebra_srv6_sid_compose()
955     				   struct srv6_locator *locator,
956     				   uint32_t sid_func)
957     {
958     	uint8_t offset, func_len;
959     	struct srv6_sid_format *format = locator->sid_format;
960
     CID 1594013:  Null pointer dereferences  (REVERSE_INULL)
     Null-checking "locator" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
961     	if (!sid_value || !locator)
962     		return false;
963
964     	if (format) {
965     		offset = format->block_len + format->node_len;
966     		func_len = format->function_len;

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-24 10:44:14 +02:00
Carmine Scarpitta 375a02d2a3 zebra: Fix wrong variable used in for loop
The `for` loop starting at line 1848 searches the `func_allocated` array
for a pointer that points to a specific `sid_wide_func` element.

The loop should iterate over all the elements of the `func_allocated`
array and dereference each element to see if it is the one we are
looking for.

Currently, the loop is using the wrong variable to iterate over the
array.

Let's fix this issue by using the correct variable in the loop.

Fixes CID 1594014
Fixes CID 1594016

** CID 1594014:  Null pointer dereferences  (FORWARD_NULL)
/zebra/zebra_srv6.c: 1860 in release_srv6_sid_func_explicit()

________________________________________________________________________________________________________
*** CID 1594014:  Null pointer dereferences  (FORWARD_NULL)
/zebra/zebra_srv6.c: 1860 in release_srv6_sid_func_explicit()
1854
1855     				/* Lookup SID function in the functions allocated list of EWLIB range */
1856     				for (ALL_LIST_ELEMENTS_RO(block->u.usid
1857     								  .wide_lib[sid_func]
1858     								  .func_allocated,
1859     							  node, sid_func_ptr))
     CID 1594014:  Null pointer dereferences  (FORWARD_NULL)
     Dereferencing null pointer "sid_wide_func_ptr".
1860     					if (*sid_wide_func_ptr == sid_wide_func)
1861     						break;
1862
1863     				/* Ensure that the SID function is allocated */
1864     				if (!sid_wide_func_ptr) {
1865     					zlog_warn("%s: failed to release wide SID function %u, function is not allocated",

** CID 1594016:  Possible Control flow issues  (DEADCODE)
/zebra/zebra_srv6.c: 1871 in release_srv6_sid_func_explicit()

________________________________________________________________________________________________________
*** CID 1594016:  Possible Control flow issues  (DEADCODE)
/zebra/zebra_srv6.c: 1871 in release_srv6_sid_func_explicit()
1865     					zlog_warn("%s: failed to release wide SID function %u, function is not allocated",
1866     						  __func__, sid_wide_func);
1867     					return -1;
1868     				}
1869
1870     				/* Release the SID function from the EWLIB range */
     CID 1594016:  Possible Control flow issues  (DEADCODE)
     Execution cannot reach this statement: "listnode_delete(block->u.us...".
1871     				listnode_delete(block->u.usid.wide_lib[sid_func]
1872     							.func_allocated,
1873     						sid_wide_func_ptr);
1874     				zebra_srv6_sid_func_free(sid_wide_func_ptr);
1875     			} else {
1876     				zlog_warn("%s: function %u is outside ELIB [%u/%u] and EWLIB alloc ranges [%u/%u]",

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-24 10:44:14 +02:00
Carmine Scarpitta fdb89ab51a zebra: Remove dead SRv6 code
At line 1736, `alloc_mode` is set to `SRV6_SID_ALLOC_MODE_EXPLICIT` or
`SRV6_SID_ALLOC_MODE_DYNAMIC` depending on the `sid_value` variable.

There will never be a case where alloc_mode will be `SRV6_SID_ALLOC_MODE_MAX`
or `SRV6_SID_ALLOC_MODE_UNSPEC`.

Let's replace the `switch(alloc_mode) {...}` with an if-else.

Fixes CID 1594015.

** CID 1594015:    (DEADCODE)
/zebra/zebra_srv6.c: 1782 in get_srv6_sid()
/zebra/zebra_srv6.c: 1781 in get_srv6_sid()

________________________________________________________________________________________________________
*** CID 1594015:    (DEADCODE)
/zebra/zebra_srv6.c: 1782 in get_srv6_sid()
1776     		}
1777
1778     		ret = get_srv6_sid_dynamic(sid, ctx, locator);
1779
1780     		break;
1781     	case SRV6_SID_ALLOC_MODE_MAX:
     CID 1594015:    (DEADCODE)
     Execution cannot reach this statement: "case SRV6_SID_ALLOC_MODE_UN...".
1782     	case SRV6_SID_ALLOC_MODE_UNSPEC:
1783     	default:
1784     		flog_err(EC_ZEBRA_SM_CANNOT_ASSIGN_SID,
1785     			 "%s: SRv6 Manager: Unrecognized alloc mode %u",
1786     			 __func__, alloc_mode);
1787     		/* We should never arrive here */
/zebra/zebra_srv6.c: 1781 in get_srv6_sid()
1775     			return -1;
1776     		}
1777
1778     		ret = get_srv6_sid_dynamic(sid, ctx, locator);
1779
1780     		break;
     CID 1594015:    (DEADCODE)
     Execution cannot reach this statement: "case SRV6_SID_ALLOC_MODE_MAX:".
1781     	case SRV6_SID_ALLOC_MODE_MAX:
1782     	case SRV6_SID_ALLOC_MODE_UNSPEC:
1783     	default:
1784     		flog_err(EC_ZEBRA_SM_CANNOT_ASSIGN_SID,
1785     			 "%s: SRv6 Manager: Unrecognized alloc mode %u",
1786     			 __func__, alloc_mode);

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-24 10:43:00 +02:00
Philippe Guibert 36a310cc9f zebra, lib: add locator name in sid notify messages
In the near future, some daemons may only register SIDs. This may be
the case for the pathd daemon when creating SRv6 binding SIDs.

When a locator is getting deleted at ZEBRA level, the daemon may have
an easy way to find out the SIds to unregister to.

This commit proposes to add the locator name to the SID_SRV6_NOTIFY
message whenever possible. Only case when an allocation failure happens,
the locator will not be present. In all other places, the notify API
at procol levels has the locator name extra-parameter.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-17 17:09:45 +02:00
Philippe Guibert 209223dae2 zebra: fix sid allocation should be different with 2 isis instances
With 2 ISIS SRv6 instances, the second ISIS instance always gets
the same End SID as the first one.

> router isis 1
> segment-routing srv6
> locator loc1
> exit
> exit
> router isis 2
> segment-routing srv6
> locator loc2
> end
> segment-routing
> srv6
> locators
> locator loc1
> prefix 2001::1/64
> exit
> locator loc2
> prefix 3001::1/64
>

output:
> 2024/06/11 17:30:15 ISIS: [N6PCR-FQ5ZA] SRv6 locator (locator loc1, prefix 2001::1/64) set for IS-IS area 1
> 2024/06/11 17:30:15 ISIS: [V4RBG-TYW5S] Requesting SRv6 SIDs for IS-IS area 1
> 2024/06/11 17:30:15 ISIS: [ZRHYM-6RMYK] isis_zebra_srv6_sid_notify: received SRv6 SID notify: ctx End USP sid_value 2001::1 sid_func 0 note ZAPI_SRV6_SID_ALLOCATED
> [..]
> 2024/06/11 17:36:49 ISIS: [N6PCR-FQ5ZA] SRv6 locator (locator loc2, prefix 3001::1/64) set for IS-IS area 2
> 2024/06/11 17:36:49 ISIS: [V4RBG-TYW5S] Requesting SRv6 SIDs for IS-IS area 2
> 2024/06/11 17:36:49 ISIS: [ZRHYM-6RMYK] isis_zebra_srv6_sid_notify: received SRv6 SID notify: ctx End USP sid_value 2001::1 sid_func 0 note ZAPI_SRV6_SID_ALLOCATED

Actually, at the second request, ZEBRA always gives an existing dynamic
SID of the first available locator, because the locator name is never
checked.

> 2024/06/11 17:36:49 ZEBRA: [XMBTQ-GE6EY] get_srv6_sid: received SRv6 SID alloc request: SID ctx End USP ((null)), mode=dynamic
> 2024/06/11 17:36:49 ZEBRA: [R61Q3-QWR23] get_srv6_sid_dynamic: returning existing SID End USP 2001::1
> 2024/06/11 17:36:49 ZEBRA: [J1GMY-B6CAK] srv6_manager_get_sid_internal: got existing SRv6 SID for ctx End USP: sid_value=2001::1 (func=0) (proto=9, instance=0, sessionId=0), notify client

Fix this by checking the locator of the existing SID.

Fixes: b771bf8ce687 ("zebra: Add functions to alloc/release SRv6 SIDs")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-06-13 14:54:17 +02:00
Philippe Guibert 35a87b6acd zebra: fix display explicit sid refused
> 2024/06/07 15:09:43 ZEBRA: [MZYPC-GBDGR] srv6_manager_get_sid_internal: getting SRv6 SID for ctx End.DT4 vrf vrf1, sid_value=1003::4, locator_name=
> [..]
> 2024/06/07 15:09:43 ZEBRA: [QGJBT-YJ11W] zsend_srv6_sid_notify: notifying ZEBRA_SRV6_SID_NOTIFY ctx End.DT4 vrf vrf2, sid (null) note ZAPI_SRV6_SID_FAIL_ALLOC (proto=30, instance=0, sessionId=0)

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-06-13 14:54:16 +02:00
Philippe Guibert 708f20e58a zebra: fix display srv6 address only for explicit-sid
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-06-13 14:54:16 +02:00
Carmine Scarpitta 5365c56614 zebra: Notify all daemons about locator delete
Currently, when a locator is deleted in zebra, zebra notifies only the
zclient that owns the locator.

With the introduction of SID Manager, the locator is no longer owned by
any client. Instead, the locator is owned by Zebra, and clients can
allocate and release SIDs from the locator using the ZAPI
ZEBRA_SRV6_MANAGER_GET_SID and ZEBRA_SRV6_MANAGER_RELEASE_SID.

Therefore, when a locator is removed in Zebra, we need to notify all
daemons so that they can release/uninstall the SIDs allocated by that
locator.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Carmine Scarpitta efa830e89c zebra: Notify daemons about SIDs
Send asynchronous notifications to zclients when an SRv6 SID is
allocated/released and when a SID alloc/release operation fails.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Carmine Scarpitta 84dd482cb9 zebra: Alloc/Release SIDs to daemons upon request
Previous commits introduced two new ZAPI operations,
`ZEBRA_SRV6_MANAGER_GET_SRV6_SID` and
`ZEBRA_SRV6_MANAGER_RELEASE_SRV6_SID`. These operations allow a daemon
to interact with the SRv6 SID Manager to get and release an SRv6 SID,
respectively.

This commit extends the SID Manager by adding logic to process the
requests `ZEBRA_SRV6_MANAGER_GET_SRV6_SID` and
`ZEBRA_SRV6_MANAGER_RELEASE_SRV6_SID`, and allocate/release SIDs to
requesting daemons.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Carmine Scarpitta c570d2bcae zebra: Add functions to alloc/release SRv6 SIDs
Add functions to allocate/release SRv6 SIDs. SIDs can be allocated
either explicitly (allocate a specific SID) or dynamically (allocate any
available SID).

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Carmine Scarpitta f8da4a29e5 zebra: Repond to GET_LOCATOR ZAPI request
The previous commits introduced a new operation,
`ZEBRA_SRV6_MANAGER_GET_LOCATOR`, allowing a daemon to request
information about a specific SRv6 locator from the SRv6 SID Manager.

This commit extends the SID Manager to respond to a
`ZEBRA_SRV6_MANAGER_GET_LOCATOR` request and provide the requested
locator information.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-06-13 14:54:16 +02:00
Carmine Scarpitta 8b3f378546 zebra: 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 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 35f4bedfa3 lib: Add CLI nodes to support SRv6 SID format
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
Carmine Scarpitta 223d4534cd zebra: Fetch actual SRv6 encap src addr on startup
When zebra is started, someone may have configured an SRv6 encap source
address different from the default address ( :: ) in the kernel.

On startup, zebra should not assume that the actual SRv6 encap source
address is the default address ( :: ), but should retrieve the actual
source address from the kernel and put it in zebra configuration. In
other words, on startup we expect the actual SRv6 encap source
address and the configured one to be the same.

This commit makes the necessary changes to support the above.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
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
Donald Sharp 9393d36690 zebra: On shutdown, free up srv6 list data
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-12-12 12:04:14 -05: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 7e975421bd zebra: Add helpers to notify locator add/delete
In this commit, we add two helper functions
`zebra_notify_srv6_locator_add` and `zebra_notify_srv6_locator_delete`.
These functions are used to notify locator additions/deletions to
zclients.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-11-08 22:44:23 +01:00
Carmine Scarpitta 0a58467251 zebra: Fix memory leak in SRv6 locator delete
Running `srv6_locator` topotest with `--valgrind-memleaks` gives several
memory leak errors. This is due to the way SRv6 locators are deleted:
when an SRv6 locator is deleted, it is removed from the SRv6 locators
list (`srv6->locators`), but the memory allocated for the SRv6 locator
is not freed.

This patch adds a call to the `srv6_locator_free()` function to properly
free the allocated memory when an SRv6 locator is removed.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 08:38:22 +02:00
Hiroki Shirokura f6e52a81dc zebra: elliminate srv6 locator auto allocation by zlicnet request
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-09-07 12:54:39 +00:00
Hiroki Shirokura f5ca329b2d zebra: implement srv6 locator add/delete notification via ZAPI
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-09-07 12:54:37 +00:00
Mark Stapp f502d7af0f zebra: srv6 cleanup
Use NO_PROTO consistently in tests; make sure zapi client
instance and session are used for srv6 'chunks'.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2021-06-07 14:26:25 -04:00
Hiroki Shirokura 1d5f59a235 zebra: fix Dereference of null pointer
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 6e68a08484 zebra: ZAPI add new api to manipulate srv6-locator (step2)
This commit is a part of #5853 works that add new ZAPI to
configure SRv6 locator which manages chunk prefix for
SRv6 SID IPv6 address for each routing protocol daemons.

NEW-ZAPIs:
* ZEBRA_SRV6_LOCATOR_ADD
* ZEBRA_SRV6_LOCATOR_DELETE
* ZEBRA_SRV6_MANAGER_CONNECT
* ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK
* ZEBRA_SRV6_MANAGER_RELEASE_LOCATOR_CHUNK

Zclient can connect to zebra's srv6-manager with
ZEBRA_SRV6_MANAGER_CONNECT api like a label-manager.
Then zclient uses ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK to
allocated dedicated locator chunk for it's routing protocol.
Zebra works for only prefix reservation and distribute
the ownership of the locator chunks for zcliens.

Then, zclient installs SRv6 function with
ZEBRA_ROUTE_ADD api with nh_seg6local_* fields.
This feature is already implemented by another PR(#7680).

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