]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Add ZAPI operation get SRv6 locator
authorCarmine Scarpitta <cscarpit@cisco.com>
Sat, 23 Mar 2024 14:49:43 +0000 (15:49 +0100)
committerCarmine Scarpitta <cscarpit@cisco.com>
Thu, 13 Jun 2024 12:54:16 +0000 (14:54 +0200)
Add a new ZAPI operation, ZEBRA_SRV6_MANAGER_GET_LOCATOR, which allows a
daemon to request information about a specific locator from the SRv6 SID
Manager.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
lib/log.c
lib/zclient.c
lib/zclient.h

index 969ca7925660d9c9288b8bb2b52fa82739af62cb..427e72703c1696bb5020989b888f4ff141fdae50 100644 (file)
--- a/lib/log.c
+++ b/lib/log.c
@@ -436,6 +436,7 @@ static const struct zebra_desc_table command_types[] = {
        DESC_ENTRY(ZEBRA_SRV6_LOCATOR_DELETE),
        DESC_ENTRY(ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK),
        DESC_ENTRY(ZEBRA_SRV6_MANAGER_RELEASE_LOCATOR_CHUNK),
+       DESC_ENTRY(ZEBRA_SRV6_MANAGER_GET_LOCATOR),
        DESC_ENTRY(ZEBRA_ERROR),
        DESC_ENTRY(ZEBRA_CLIENT_CAPABILITIES),
        DESC_ENTRY(ZEBRA_OPAQUE_MESSAGE),
index 1aab7b48ba8f4187dd22311d08c7c2f82753111e..90ec0241556198e8c2a926b4e959f9fa75de30e3 100644 (file)
@@ -3268,6 +3268,47 @@ int srv6_manager_release_locator_chunk(struct zclient *zclient,
        return zclient_send_message(zclient);
 }
 
+/**
+ * Function to request a SRv6 locator in an asynchronous way
+ *
+ * @param zclient The zclient used to connect to SRv6 Manager (zebra)
+ * @param locator_name Name of SRv6 locator
+ * @return 0 on success, -1 otherwise
+ */
+int srv6_manager_get_locator(struct zclient *zclient, const char *locator_name)
+{
+       struct stream *s;
+       size_t len;
+
+       if (!locator_name)
+               return -1;
+
+       if (zclient->sock < 0) {
+               flog_err(EC_LIB_ZAPI_SOCKET, "%s: invalid zclient socket",
+                        __func__);
+               return -1;
+       }
+
+       if (zclient_debug)
+               zlog_debug("Getting SRv6 Locator %s", locator_name);
+
+       len = strlen(locator_name);
+
+       /* Send request */
+       s = zclient->obuf;
+       stream_reset(s);
+       zclient_create_header(s, ZEBRA_SRV6_MANAGER_GET_LOCATOR, VRF_DEFAULT);
+
+       /* Locator name */
+       stream_putw(s, len);
+       stream_put(s, locator_name, len);
+
+       /* Put length at the first point of the stream. */
+       stream_putw_at(s, 0, stream_get_endp(s));
+
+       return zclient_send_message(zclient);
+}
+
 /*
  * Asynchronous label chunk request
  *
index 3759f94542ea6248074dcf379539ac1c9b694e15..87617003d8f26d31ea2ba2bdf0b956887c575019 100644 (file)
@@ -209,6 +209,7 @@ typedef enum {
        ZEBRA_SRV6_LOCATOR_DELETE,
        ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK,
        ZEBRA_SRV6_MANAGER_RELEASE_LOCATOR_CHUNK,
+       ZEBRA_SRV6_MANAGER_GET_LOCATOR,
        ZEBRA_ERROR,
        ZEBRA_CLIENT_CAPABILITIES,
        ZEBRA_OPAQUE_MESSAGE,
@@ -1074,6 +1075,8 @@ extern int srv6_manager_get_locator_chunk(struct zclient *zclient,
                                          const char *locator_name);
 extern int srv6_manager_release_locator_chunk(struct zclient *zclient,
                                              const char *locator_name);
+extern int srv6_manager_get_locator(struct zclient *zclient,
+                                   const char *locator_name);
 
 extern enum zclient_send_status zebra_send_sr_policy(struct zclient *zclient,
                                                     int cmd,