]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd: Add func to unset the SRv6 locator
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Fri, 10 Mar 2023 22:50:46 +0000 (23:50 +0100)
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Mon, 11 Sep 2023 15:34:55 +0000 (17:34 +0200)
Add a function to unset the SRv6 locator for a specific IS-IS area.

This function calls `isis_zebra_srv6_manager_release_locator_chunk()` to
ask zebra to release the locator chunk owned by IS-IS and removes the
chunk from the area's chunks list.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
isisd/isis_srv6.c
isisd/isis_srv6.h

index b08609d360ed0f73031e6bfb7b0c737e3ace7193..0e6e36e9a80ab17899cf7e7c2a21f92f39a2a1f8 100644 (file)
 #include "isisd/isisd.h"
 #include "isisd/isis_misc.h"
 #include "isisd/isis_srv6.h"
+#include "isisd/isis_zebra.h"
+
+/**
+ * Unset the SRv6 locator for a given IS-IS area.
+ *
+ * @param area IS-IS area
+ *
+ * @result True on success, False otherwise
+ */
+bool isis_srv6_locator_unset(struct isis_area *area)
+{
+       int ret;
+       struct listnode *node, *nnode;
+       struct srv6_locator_chunk *chunk;
+
+       if (strncmp(area->srv6db.config.srv6_locator_name, "",
+                   sizeof(area->srv6db.config.srv6_locator_name)) == 0) {
+               sr_debug("SRv6 locator not set");
+               return true;
+       }
+
+       /* Inform Zebra that we are releasing the SRv6 locator */
+       ret = isis_zebra_srv6_manager_release_locator_chunk(
+               area->srv6db.config.srv6_locator_name);
+       if (ret < 0)
+               return false;
+
+       /* Delete chunks */
+       for (ALL_LIST_ELEMENTS(area->srv6db.srv6_locator_chunks, node, nnode,
+                              chunk)) {
+               sr_debug(
+                       "Releasing chunk of locator %s (prefix %pFX) for IS-IS area %s",
+                       area->srv6db.config.srv6_locator_name, &chunk->prefix,
+                       area->area_tag);
+
+               listnode_delete(area->srv6db.srv6_locator_chunks, chunk);
+               srv6_locator_chunk_free(&chunk);
+       }
+
+       /* Clear locator name */
+       memset(area->srv6db.config.srv6_locator_name, 0,
+              sizeof(area->srv6db.config.srv6_locator_name));
+
+       /* Regenerate LSPs to advertise that the SRv6 locator no longer exists
+        */
+       lsp_regenerate_schedule(area, area->is_type, 0);
+
+       return true;
+}
 
 /**
  * Show Segment Routing over IPv6 (SRv6) Node.
index b0e92c8a5b98fb523ed2d4e44f1f063351f01e4c..40a0faaa99025282b22216217bc8f568d216f3b2 100644 (file)
@@ -44,6 +44,8 @@ struct isis_srv6_db {
        } config;
 };
 
+bool isis_srv6_locator_unset(struct isis_area *area);
+
 extern void isis_srv6_area_init(struct isis_area *area);
 extern void isis_srv6_area_term(struct isis_area *area);