summaryrefslogtreecommitdiff
path: root/isisd/isis_zebra.c
diff options
context:
space:
mode:
authorCarmine Scarpitta <cscarpit@cisco.com>2024-05-09 11:23:53 +0200
committerCarmine Scarpitta <cscarpit@cisco.com>2024-06-18 18:33:29 +0200
commit3fce2928e293c59bb63ef76455525dca602385dd (patch)
treed9f2a8fc128f0d1d4c5b113d8d151a9979b7fbe4 /isisd/isis_zebra.c
parent73bfc5865f4ded8297096bbdb3cc67b1ba54600f (diff)
isisd: Add API to get/release SRv6 SIDs
Add an API to get/release SRv6 SIDs through the SRv6 SID Manager. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
Diffstat (limited to 'isisd/isis_zebra.c')
-rw-r--r--isisd/isis_zebra.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c
index f5b3f712be..226ee56796 100644
--- a/isisd/isis_zebra.c
+++ b/isisd/isis_zebra.c
@@ -645,6 +645,40 @@ int isis_zebra_request_label_range(uint32_t base, uint32_t chunk_size)
}
/**
+ * Request an End.X SID for an IS-IS adjacency.
+ *
+ * @param adj IS-IS Adjacency
+ */
+void isis_zebra_request_srv6_sid_endx(struct isis_adjacency *adj)
+{
+ struct isis_circuit *circuit = adj->circuit;
+ struct isis_area *area = circuit->area;
+ struct in6_addr nexthop;
+ struct srv6_sid_ctx ctx = {};
+ struct in6_addr sid_value = {};
+ bool ret;
+
+ if (!area || !area->srv6db.srv6_locator)
+ return;
+
+ /* Determine nexthop IP address */
+ if (!circuit->ipv6_router || !adj->ll_ipv6_count)
+ return;
+
+ nexthop = adj->ll_ipv6_addrs[0];
+
+ ctx.behavior = ZEBRA_SEG6_LOCAL_ACTION_END_X;
+ ctx.nh6 = nexthop;
+ ret = isis_zebra_request_srv6_sid(&ctx, &sid_value,
+ area->srv6db.config.srv6_locator_name);
+ if (!ret) {
+ zlog_err("%s: not allocated new End.X SID for IS-IS area %s",
+ __func__, area->area_tag);
+ return;
+ }
+}
+
+/**
* Release Label Range to the Label Manager.
*
* @param start start of label range to release
@@ -1386,6 +1420,69 @@ int isis_zebra_srv6_manager_get_locator(const char *name)
return srv6_manager_get_locator(zclient, name);
}
+/**
+ * Ask the SRv6 Manager (zebra) to allocate a SID.
+ *
+ * Optionally, it is possible to provide an IPv6 address (sid_value parameter).
+ *
+ * When sid_value is provided, the SRv6 Manager allocates the requested SID
+ * address, if the request can be satisfied (explicit allocation).
+ *
+ * When sid_value is not provided, the SRv6 Manager allocates any available SID
+ * from the provided locator (dynamic allocation).
+ *
+ * @param ctx Context to be associated with the request SID
+ * @param sid_value IPv6 address to be associated with the requested SID (optional)
+ * @param locator_name Name of the locator from which the SID must be allocated
+ */
+bool isis_zebra_request_srv6_sid(const struct srv6_sid_ctx *ctx,
+ struct in6_addr *sid_value,
+ const char *locator_name)
+{
+ int ret;
+
+ if (!ctx || !locator_name)
+ return false;
+
+ /*
+ * Send the Get SRv6 SID request to the SRv6 Manager and check the
+ * result
+ */
+ ret = srv6_manager_get_sid(zclient, ctx, sid_value, locator_name, NULL);
+ if (ret < 0) {
+ zlog_warn("%s: error getting SRv6 SID!", __func__);
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Ask the SRv6 Manager (zebra) to release a previously allocated SID.
+ *
+ * This function is used to tell the SRv6 Manager that IS-IS no longer intends
+ * to use the SID.
+ *
+ * @param ctx Context to be associated with the SID to be released
+ */
+void isis_zebra_release_srv6_sid(const struct srv6_sid_ctx *ctx)
+{
+ int ret;
+
+ if (!ctx)
+ return;
+
+ /*
+ * Send the Release SRv6 SID request to the SRv6 Manager and check the
+ * result
+ */
+ ret = srv6_manager_release_sid(zclient, ctx);
+ if (ret < 0) {
+ zlog_warn("%s: error releasing SRv6 SID!", __func__);
+ return;
+ }
+}
+
static zclient_handler *const isis_handlers[] = {
[ZEBRA_ROUTER_ID_UPDATE] = isis_router_id_update_zebra,
[ZEBRA_INTERFACE_ADDRESS_ADD] = isis_zebra_if_address_add,