]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd: Add func to remove SRv6 SID from dplane
authorCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Wed, 22 Feb 2023 10:19:28 +0000 (11:19 +0100)
committerCarmine Scarpitta <carmine.scarpitta@uniroma2.it>
Mon, 11 Sep 2023 15:35:06 +0000 (17:35 +0200)
Add a function to remove an SRv6 SID from the data plane through
zebra.

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

index 29fb238af2b751c64e0eaa65a035b167bd4853ff..aecf7f6e691eeefaf74388ee2bed88d40c7b6c78 100644 (file)
@@ -955,6 +955,62 @@ void isis_zebra_srv6_sid_install(struct isis_area *area,
                                 ifp->ifindex, action, &ctx);
 }
 
+/**
+ * Uninstall SRv6 SID from the forwarding plane through Zebra.
+ *
+ * @param area         IS-IS area
+ * @param sid          SRv6 SID
+ */
+void isis_zebra_srv6_sid_uninstall(struct isis_area *area,
+                                  struct isis_srv6_sid *sid)
+{
+       enum seg6local_action_t action = ZEBRA_SEG6_LOCAL_ACTION_UNSPEC;
+       struct interface *ifp;
+       uint16_t prefixlen = IPV6_MAX_BITLEN;
+
+       if (!area || !sid)
+               return;
+
+       sr_debug("ISIS-SRv6 (%s): delete SID %pI6", area->area_tag, &sid->sid);
+
+       switch (sid->behavior) {
+       case SRV6_ENDPOINT_BEHAVIOR_END:
+               prefixlen = IPV6_MAX_BITLEN;
+               break;
+       case SRV6_ENDPOINT_BEHAVIOR_END_NEXT_CSID:
+               prefixlen = sid->locator->block_bits_length +
+                           sid->locator->node_bits_length;
+               break;
+       case SRV6_ENDPOINT_BEHAVIOR_RESERVED:
+       case SRV6_ENDPOINT_BEHAVIOR_END_X:
+       case SRV6_ENDPOINT_BEHAVIOR_END_DT6:
+       case SRV6_ENDPOINT_BEHAVIOR_END_DT4:
+       case SRV6_ENDPOINT_BEHAVIOR_END_DT46:
+       case SRV6_ENDPOINT_BEHAVIOR_END_X_NEXT_CSID:
+       case SRV6_ENDPOINT_BEHAVIOR_END_DT6_USID:
+       case SRV6_ENDPOINT_BEHAVIOR_END_DT4_USID:
+       case SRV6_ENDPOINT_BEHAVIOR_END_DT46_USID:
+       case SRV6_ENDPOINT_BEHAVIOR_OPAQUE:
+       default:
+               zlog_err(
+                       "ISIS-SRv6 (%s): unsupported SRv6 endpoint behavior %u",
+                       area->area_tag, sid->behavior);
+               return;
+       }
+
+       /* The SID is attached to the SRv6 interface */
+       ifp = if_lookup_by_name(SRV6_IFNAME, VRF_DEFAULT);
+       if (!ifp) {
+               zlog_warn("%s interface not found: nothing to uninstall",
+                         SRV6_IFNAME);
+               return;
+       }
+
+       /* Send delete request to zebra */
+       isis_zebra_send_localsid(ZEBRA_ROUTE_DELETE, &sid->sid, prefixlen,
+                                ifp->ifindex, action, NULL);
+}
+
 /**
  * Callback to process an SRv6 locator chunk received from SRv6 Manager (zebra).
  *
index b4b9d22e81d20de20803dd0b0b8fcebdd7bcb3ba..af78274451f4451efff4a31971ce8cecf12e1a5a 100644 (file)
@@ -59,6 +59,8 @@ int isis_zebra_ls_register(bool up);
 
 extern void isis_zebra_srv6_sid_install(struct isis_area *area,
                                        struct isis_srv6_sid *sid);
+extern void isis_zebra_srv6_sid_uninstall(struct isis_area *area,
+                                         struct isis_srv6_sid *sid);
 extern int isis_zebra_srv6_manager_get_locator_chunk(const char *name);
 extern int isis_zebra_srv6_manager_release_locator_chunk(const char *name);