]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra, lib: add locator name in sid notify messages
authorPhilippe Guibert <philippe.guibert@6wind.com>
Sat, 8 Jun 2024 05:15:47 +0000 (07:15 +0200)
committerCarmine Scarpitta <cscarpit@cisco.com>
Mon, 17 Jun 2024 15:09:45 +0000 (17:09 +0200)
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>
lib/zclient.c
lib/zclient.h
zebra/zapi_msg.c
zebra/zapi_msg.h
zebra/zebra_srv6.c

index a1386e501a72c194e7a89fab8f608a82d0ab9bb2..586ee9c2cbe520999f62a3db724133e262089ba8 100644 (file)
@@ -2136,9 +2136,12 @@ stream_failure:
 bool zapi_srv6_sid_notify_decode(struct stream *s, struct srv6_sid_ctx *ctx,
                                 struct in6_addr *sid_value, uint32_t *func,
                                 uint32_t *wide_func,
-                                enum zapi_srv6_sid_notify *note)
+                                enum zapi_srv6_sid_notify *note,
+                                char **p_locator_name)
 {
        uint32_t f, wf;
+       uint16_t len;
+       static char locator_name[SRV6_LOCNAME_SIZE] = {};
 
        STREAM_GET(note, s, sizeof(*note));
        STREAM_GET(ctx, s, sizeof(struct srv6_sid_ctx));
@@ -2151,6 +2154,19 @@ bool zapi_srv6_sid_notify_decode(struct stream *s, struct srv6_sid_ctx *ctx,
        if (wide_func)
                *wide_func = wf;
 
+       STREAM_GETW(s, len);
+       if (len > SRV6_LOCNAME_SIZE) {
+               *p_locator_name = NULL;
+               return false;
+       }
+       if (p_locator_name) {
+               if (len == 0)
+                       *p_locator_name = NULL;
+               else {
+                       STREAM_GET(locator_name, s, len);
+                       *p_locator_name = locator_name;
+               }
+       }
        return true;
 
 stream_failure:
index bfe955b7acc758d4ea1c8cb1a37ff71b06a76e0e..2877b347d8d0eff1562804528f8e5f18136da670 100644 (file)
@@ -1177,7 +1177,8 @@ bool zapi_ipset_notify_decode(struct stream *s,
 bool zapi_srv6_sid_notify_decode(struct stream *s, struct srv6_sid_ctx *ctx,
                                 struct in6_addr *sid_value, uint32_t *func,
                                 uint32_t *wide_func,
-                                enum zapi_srv6_sid_notify *note);
+                                enum zapi_srv6_sid_notify *note,
+                                char **locator_name);
 
 /* Nexthop-group message apis */
 extern enum zclient_send_status
index 164c0dd6872398929fe473005166123c5702b5ba..2a1eea9594ee04aa4ee2a834fb3f7454bfebd68d 100644 (file)
@@ -1001,7 +1001,9 @@ void zsend_neighbor_notify(int cmd, struct interface *ifp,
 
 void zsend_srv6_sid_notify(struct zserv *client, const struct srv6_sid_ctx *ctx,
                           struct in6_addr *sid_value, uint32_t func,
-                          uint32_t wide_func, enum zapi_srv6_sid_notify note)
+                          uint32_t wide_func, const char *locator_name,
+                          enum zapi_srv6_sid_notify note)
+
 {
        struct stream *s;
        uint16_t cmd = ZEBRA_SRV6_SID_NOTIFY;
@@ -1027,6 +1029,13 @@ void zsend_srv6_sid_notify(struct zserv *client, const struct srv6_sid_ctx *ctx,
        stream_putl(s, func);
        /* SRv6 wide SID function */
        stream_putl(s, wide_func);
+       /* SRv6 locator name optional */
+       if (locator_name) {
+               stream_putw(s, strlen(locator_name));
+               stream_put(s, locator_name, strlen(locator_name));
+       } else
+               stream_putw(s, 0);
+
        stream_putw_at(s, 0, stream_get_endp(s));
 
        zserv_send_message(client, s);
index 3505bc0dc4e3ca93b1e5e71a6d7393b518ee3e6c..9e3ea6fb6ecdb241e05a45e3cc48ebd9741803d1 100644 (file)
@@ -97,7 +97,7 @@ extern void zsend_neighbor_notify(int cmd, struct interface *ifp,
 extern void zsend_srv6_sid_notify(struct zserv *client,
                                  const struct srv6_sid_ctx *ctx,
                                  struct in6_addr *sid_value, uint32_t func,
-                                 uint32_t wide_func,
+                                 uint32_t wide_func, const char *locator_name,
                                  enum zapi_srv6_sid_notify note);
 
 extern int zsend_client_close_notify(struct zserv *client,
index a6db66bbccea55afb5b496629d6ad90195d57ecb..0ca77a49740c5c3d88d7b043a4dd5fe3037a30ff 100644 (file)
@@ -2280,7 +2280,7 @@ static int srv6_manager_get_sid_internal(struct zebra_srv6_sid **sid,
                          sid_value ? sid_value : &in6addr_any, locator_name);
 
                /* Notify client about SID alloc failure */
-               zsend_srv6_sid_notify(client, ctx, sid_value, 0, 0,
+               zsend_srv6_sid_notify(client, ctx, sid_value, 0, 0, NULL,
                                      ZAPI_SRV6_SID_FAIL_ALLOC);
        } else if (ret == 0) {
                if (IS_ZEBRA_DEBUG_PACKET)
@@ -2294,6 +2294,8 @@ static int srv6_manager_get_sid_internal(struct zebra_srv6_sid **sid,
 
                zsend_srv6_sid_notify(client, ctx, &(*sid)->value, (*sid)->func,
                                      (*sid)->wide_func,
+                                     (*sid)->locator ? (*sid)->locator->name
+                                                     : NULL,
                                      ZAPI_SRV6_SID_ALLOCATED);
        } else {
                if (IS_ZEBRA_DEBUG_PACKET)
@@ -2308,6 +2310,9 @@ static int srv6_manager_get_sid_internal(struct zebra_srv6_sid **sid,
                for (ALL_LIST_ELEMENTS_RO((*sid)->client_list, node, c))
                        zsend_srv6_sid_notify(c, ctx, &(*sid)->value,
                                              (*sid)->func, (*sid)->wide_func,
+                                             (*sid)->locator
+                                                     ? (*sid)->locator->name
+                                                     : NULL,
                                              ZAPI_SRV6_SID_ALLOCATED);
        }
 
@@ -2366,6 +2371,7 @@ static int srv6_manager_release_sid_internal(struct zserv *client,
        struct zebra_srv6_sid_ctx *zctx;
        struct listnode *node, *nnode;
        char buf[256];
+       const char *locator_name = NULL;
 
        if (IS_ZEBRA_DEBUG_PACKET)
                zlog_debug("%s: releasing SRv6 SID associated with ctx %s",
@@ -2374,6 +2380,9 @@ static int srv6_manager_release_sid_internal(struct zserv *client,
        /* Lookup Zebra SID context and release it */
        for (ALL_LIST_ELEMENTS(srv6->sids, node, nnode, zctx))
                if (memcmp(&zctx->ctx, ctx, sizeof(struct srv6_sid_ctx)) == 0) {
+                       if (zctx->sid && zctx->sid->locator)
+                               locator_name =
+                                       (const char *)zctx->sid->locator->name;
                        ret = release_srv6_sid(client, zctx);
                        break;
                }
@@ -2383,10 +2392,10 @@ static int srv6_manager_release_sid_internal(struct zserv *client,
                           srv6_sid_ctx2str(buf, sizeof(buf), ctx));
 
        if (ret == 0)
-               zsend_srv6_sid_notify(client, ctx, NULL, 0, 0,
+               zsend_srv6_sid_notify(client, ctx, NULL, 0, 0, locator_name,
                                      ZAPI_SRV6_SID_RELEASED);
        else
-               zsend_srv6_sid_notify(client, ctx, NULL, 0, 0,
+               zsend_srv6_sid_notify(client, ctx, NULL, 0, 0, locator_name,
                                      ZAPI_SRV6_SID_FAIL_RELEASE);
 
        return ret;