diff options
| author | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2023-03-10 23:50:46 +0100 | 
|---|---|---|
| committer | Carmine Scarpitta <carmine.scarpitta@uniroma2.it> | 2023-09-11 17:34:55 +0200 | 
| commit | f49937e340a9ddca0c7fc12ab3b45e83850dcf5c (patch) | |
| tree | 3d16096df3a69dceef901732565640bd5d11f35a /isisd/isis_srv6.c | |
| parent | d223a8167e471c9297a6b33cd97fec37e97ca3c5 (diff) | |
isisd: Add func to unset the SRv6 locator
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>
Diffstat (limited to 'isisd/isis_srv6.c')
| -rw-r--r-- | isisd/isis_srv6.c | 49 | 
1 files changed, 49 insertions, 0 deletions
diff --git a/isisd/isis_srv6.c b/isisd/isis_srv6.c index b08609d360..0e6e36e9a8 100644 --- a/isisd/isis_srv6.c +++ b/isisd/isis_srv6.c @@ -15,6 +15,55 @@  #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.  | 
