summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_srv6.c
diff options
context:
space:
mode:
authorCarmine Scarpitta <cscarpit@cisco.com>2024-05-02 13:39:49 +0200
committerCarmine Scarpitta <cscarpit@cisco.com>2024-06-13 14:54:16 +0200
commitefa830e89ca39c93eeddef40ed7c959ba36b1fc1 (patch)
tree16f7a06f9295c20953b150a926d7c1154c7e51fa /zebra/zebra_srv6.c
parentlib: Add ZAPI command `ZEBRA_SRV6_SID_NOTIFY` (diff)
downloadfrr-efa830e89ca39c93eeddef40ed7c959ba36b1fc1.tar.xz
frr-efa830e89ca39c93eeddef40ed7c959ba36b1fc1.zip
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>
Diffstat (limited to '')
-rw-r--r--zebra/zebra_srv6.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/zebra/zebra_srv6.c b/zebra/zebra_srv6.c
index d93f09f1b..663afa2f8 100644
--- a/zebra/zebra_srv6.c
+++ b/zebra/zebra_srv6.c
@@ -2279,6 +2279,8 @@ static int srv6_manager_get_sid_internal(struct zebra_srv6_sid **sid,
const char *locator_name)
{
int ret = -1;
+ struct listnode *node;
+ struct zserv *c;
char buf[256];
if (IS_ZEBRA_DEBUG_PACKET)
@@ -2291,6 +2293,10 @@ static int srv6_manager_get_sid_internal(struct zebra_srv6_sid **sid,
zlog_warn("%s: not got SRv6 SID for ctx %s, sid_value=%pI6, locator_name=%s",
__func__, srv6_sid_ctx2str(buf, sizeof(buf), ctx),
sid_value, locator_name);
+
+ /* Notify client about SID alloc failure */
+ zsend_srv6_sid_notify(client, ctx, NULL, 0, 0,
+ ZAPI_SRV6_SID_FAIL_ALLOC);
} else if (ret == 0) {
if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug("%s: got existing SRv6 SID for ctx %s: sid_value=%pI6 (func=%u) (proto=%u, instance=%u, sessionId=%u), notify client",
@@ -2300,6 +2306,10 @@ static int srv6_manager_get_sid_internal(struct zebra_srv6_sid **sid,
client->instance, client->session_id);
if (!listnode_lookup((*sid)->client_list, client))
listnode_add((*sid)->client_list, client);
+
+ zsend_srv6_sid_notify(client, ctx, &(*sid)->value, (*sid)->func,
+ (*sid)->wide_func,
+ ZAPI_SRV6_SID_ALLOCATED);
} else {
if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug("%s: got new SRv6 SID for ctx %s: sid_value=%pI6 (func=%u) (proto=%u, instance=%u, sessionId=%u), notifying all clients",
@@ -2309,6 +2319,11 @@ static int srv6_manager_get_sid_internal(struct zebra_srv6_sid **sid,
client->instance, client->session_id);
if (!listnode_lookup((*sid)->client_list, client))
listnode_add((*sid)->client_list, client);
+
+ for (ALL_LIST_ELEMENTS_RO((*sid)->client_list, node, c))
+ zsend_srv6_sid_notify(c, ctx, &(*sid)->value,
+ (*sid)->func, (*sid)->wide_func,
+ ZAPI_SRV6_SID_ALLOCATED);
}
return ret;
@@ -2382,6 +2397,13 @@ static int srv6_manager_release_sid_internal(struct zserv *client,
zlog_debug("%s: no SID associated with ctx %s", __func__,
srv6_sid_ctx2str(buf, sizeof(buf), ctx));
+ if (ret == 0)
+ zsend_srv6_sid_notify(client, ctx, NULL, 0, 0,
+ ZAPI_SRV6_SID_RELEASED);
+ else
+ zsend_srv6_sid_notify(client, ctx, NULL, 0, 0,
+ ZAPI_SRV6_SID_FAIL_RELEASE);
+
return ret;
}