summaryrefslogtreecommitdiffstats
path: root/isisd
diff options
context:
space:
mode:
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>2023-01-27 16:04:49 +0100
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>2023-09-11 17:34:55 +0200
commit95096e9585e254f6b56578fb159ffb2495384f9e (patch)
tree29cf35576cc5da5f2a0245546a55401843d42f66 /isisd
parentyang: Add SRv6 locator to the IS-IS YANG model (diff)
downloadfrr-95096e9585e254f6b56578fb159ffb2495384f9e.tar.xz
frr-95096e9585e254f6b56578fb159ffb2495384f9e.zip
isisd: Add nb command to configure an SRv6 locator
Add a northbound command to configure an SRv6 locator for a specific IS-IS area. After configuring a locator, `isis_zebra_srv6_manager_get_locator_chunk` is called to ask zebra to allocate a chunk from the configured locator. The allocated chunk will be owned by IS-IS. IS-IS can allocate SIDs from its chunk. Currently, we support only one locator per-area. Therefore, before configuring a locator we unset the previously configured locator, if there was any. Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
Diffstat (limited to 'isisd')
-rw-r--r--isisd/isis_nb.c6
-rw-r--r--isisd/isis_nb.h2
-rw-r--r--isisd/isis_nb_config.c50
3 files changed, 58 insertions, 0 deletions
diff --git a/isisd/isis_nb.c b/isisd/isis_nb.c
index 4c42d18eb..4fae0836b 100644
--- a/isisd/isis_nb.c
+++ b/isisd/isis_nb.c
@@ -868,6 +868,12 @@ const struct frr_yang_module_info frr_isisd_info = {
},
},
{
+ .xpath = "/frr-isisd:isis/instance/segment-routing-srv6/locator",
+ .cbs = {
+ .modify = isis_instance_segment_routing_srv6_locator_modify,
+ },
+ },
+ {
.xpath = "/frr-isisd:isis/instance/mpls/ldp-sync",
.cbs = {
.cli_show = cli_show_isis_mpls_ldp_sync,
diff --git a/isisd/isis_nb.h b/isisd/isis_nb.h
index 728967700..657c8fb2d 100644
--- a/isisd/isis_nb.h
+++ b/isisd/isis_nb.h
@@ -326,6 +326,8 @@ int isis_instance_segment_routing_srv6_enabled_modify(
struct nb_cb_modify_args *args);
void cli_show_isis_srv6_enabled(struct vty *vty, const struct lyd_node *dnode,
bool show_defaults);
+int isis_instance_segment_routing_srv6_locator_modify(
+ struct nb_cb_modify_args *args);
int isis_instance_mpls_ldp_sync_destroy(struct nb_cb_destroy_args *args);
int isis_instance_mpls_ldp_sync_create(struct nb_cb_create_args *args);
int isis_instance_mpls_ldp_sync_holddown_modify(struct nb_cb_modify_args *args);
diff --git a/isisd/isis_nb_config.c b/isisd/isis_nb_config.c
index 3a56c78de..5ec17f393 100644
--- a/isisd/isis_nb_config.c
+++ b/isisd/isis_nb_config.c
@@ -35,6 +35,7 @@
#include "isisd/isis_adjacency.h"
#include "isisd/isis_spf.h"
#include "isisd/isis_spf_private.h"
+#include "isisd/isis_srv6.h"
#include "isisd/isis_te.h"
#include "isisd/isis_mt.h"
#include "isisd/isis_redist.h"
@@ -3478,6 +3479,55 @@ int isis_instance_segment_routing_srv6_enabled_modify(
}
/*
+ * XPath: /frr-isisd:isis/instance/segment-routing-srv6/locator
+ */
+int isis_instance_segment_routing_srv6_locator_modify(
+ struct nb_cb_modify_args *args)
+{
+ struct isis_area *area;
+ const char *loc_name;
+
+ if (args->event != NB_EV_APPLY)
+ return NB_OK;
+
+ area = nb_running_get_entry(lyd_parent(lyd_parent(args->dnode)), NULL,
+ true);
+
+ loc_name = yang_dnode_get_string(args->dnode, NULL);
+
+ if (strncmp(loc_name, area->srv6db.config.srv6_locator_name,
+ sizeof(area->srv6db.config.srv6_locator_name)) == 0) {
+ snprintf(args->errmsg, args->errmsg_len,
+ "SRv6 locator %s is already configured", loc_name);
+ return NB_ERR_NO_CHANGES;
+ }
+
+ /* Remove previously configured locator */
+ if (strncmp(area->srv6db.config.srv6_locator_name, "",
+ sizeof(area->srv6db.config.srv6_locator_name)) != 0) {
+ sr_debug("Unsetting previously configured SRv6 locator");
+ if (!isis_srv6_locator_unset(area)) {
+ zlog_warn("Failed to unset SRv6 locator");
+ return NB_ERR;
+ }
+ }
+
+ strlcpy(area->srv6db.config.srv6_locator_name, loc_name,
+ sizeof(area->srv6db.config.srv6_locator_name));
+
+ sr_debug("Configured SRv6 locator %s for IS-IS area %s", loc_name,
+ area->area_tag);
+
+ sr_debug("Trying to get a chunk from locator %s for IS-IS area %s",
+ loc_name, area->area_tag);
+
+ if (isis_zebra_srv6_manager_get_locator_chunk(loc_name) < 0)
+ return NB_ERR;
+
+ return NB_OK;
+}
+
+/*
* XPath: /frr-isisd:isis/instance/mpls/ldp-sync
*/
int isis_instance_mpls_ldp_sync_create(struct nb_cb_create_args *args)