]> git.puffer.fish Git - mirror/frr.git/commitdiff
staticd: Add `no` form for `static-sids` command
authorCarmine Scarpitta <cscarpit@cisco.com>
Wed, 26 Feb 2025 14:34:19 +0000 (15:34 +0100)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Fri, 28 Feb 2025 14:16:15 +0000 (14:16 +0000)
Currently, when the user tries to delete all static SIDs with the
`no static-sids` command, staticd returns an error.

```
router# config
router(config)# segment-routing
router(sr)# srv6
router(srv6)# no static-sids
% Unknown command: no  static-sids
```

The problem is the `static-sids` command does not support the `no` form.

This PR enables the `no` form for the `static-sids` command.

```
router# config
router(config)# segment-routing
router(sr)# srv6
router(srv6)# no static-sids
```

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
(cherry picked from commit ab7a7541a669ebe586d8de8015e7eb68c0365c2b)

staticd/static_nb.h
staticd/static_vty.c

index aa11f340212ba02d7b55c6a4beecc7ccf77ed236..4902327b954e3c2f08fa79299e8447f027d9aa75 100644 (file)
@@ -172,6 +172,10 @@ int routing_control_plane_protocols_name_validate(
        "frr-staticd:staticd/segment-routing/srv6"
 
 /* srv6/static-sids */
+#define FRR_STATIC_SRV6_STATIC_SIDS_XPATH                                                          \
+       FRR_STATIC_SRV6_INFO_KEY_XPATH                                                             \
+       "/static-sids"
+
 #define FRR_STATIC_SRV6_SID_KEY_XPATH                                                              \
        FRR_STATIC_SRV6_INFO_KEY_XPATH                                                             \
        "/static-sids/"                                                                            \
index a6bf53e5237daab112cf16473b8f1654e31a7525..13a61e52c797304c4adf07561b0b2763af661505 100644 (file)
@@ -1174,10 +1174,22 @@ DEFUN_YANG_NOSH (no_static_srv6, no_static_srv6_cmd,
        return nb_cli_apply_changes(vty, "%s", xpath);
 }
 
-DEFPY_NOSH (static_srv6_sids, static_srv6_sids_cmd,
-      "static-sids",
+DEFPY_YANG_NOSH (static_srv6_sids, static_srv6_sids_cmd,
+      "[no] static-sids",
+         NO_STR
       "Segment Routing SRv6 SIDs\n")
 {
+       char xpath[XPATH_MAXLEN];
+
+       if (no) {
+               snprintf(xpath, sizeof(xpath), FRR_STATIC_SRV6_STATIC_SIDS_XPATH,
+                        "frr-staticd:staticd", "staticd", VRF_DEFAULT_NAME);
+
+               nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+
+               return nb_cli_apply_changes(vty, "%s", xpath);
+       }
+
        VTY_PUSH_CONTEXT_NULL(SRV6_SIDS_NODE);
        return CMD_SUCCESS;
 }