]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: convert route-map to mgmtd
authorChristian Hopps <chopps@labn.net>
Wed, 24 Jan 2024 15:59:14 +0000 (10:59 -0500)
committerChristian Hopps <chopps@labn.net>
Fri, 26 Jan 2024 17:34:23 +0000 (12:34 -0500)
Signed-off-by: Christian Hopps <chopps@labn.net>
lib/routemap.c
lib/routemap.h
lib/routemap_northbound.c
mgmtd/mgmt_main.c
mgmtd/mgmt_vty.c
python/xref2vtysh.py
vtysh/vtysh.c
vtysh/vtysh.h

index e8a92cda0b08c71131b31952cbf3209412b20f1a..6b3f81b4d41b4cf689165c1b63f89ae2511cfc56 100644 (file)
@@ -3409,7 +3409,7 @@ DEFUN_HIDDEN(show_route_map_pfx_tbl, show_route_map_pfx_tbl_cmd,
 }
 
 /* Initialization of route map vector. */
-void route_map_init(void)
+void route_map_init_new(bool in_backend)
 {
        int i;
 
@@ -3424,7 +3424,10 @@ void route_map_init(void)
 
        UNSET_FLAG(rmap_debug, DEBUG_ROUTEMAP);
 
-       route_map_cli_init();
+       if (!in_backend) {
+               /* we do not want to handle config commands in the backend */
+               route_map_cli_init();
+       }
 
        /* Install route map top node. */
        install_node(&rmap_debug_node);
@@ -3444,3 +3447,8 @@ void route_map_init(void)
 
        install_element(ENABLE_NODE, &show_route_map_pfx_tbl_cmd);
 }
+
+void route_map_init(void)
+{
+       route_map_init_new(false);
+}
index 08e341221d8c4a0f11a613e160cbb25d583f4486..dfb84ced5bae40fb25d184fb57f1ff4334661f72 100644 (file)
@@ -401,6 +401,7 @@ enum ecommunity_lb_type {
 
 /* Prototypes. */
 extern void route_map_init(void);
+extern void route_map_init_new(bool in_backend);
 
 /*
  * This should only be called on shutdown
@@ -1024,6 +1025,7 @@ routemap_hook_context_insert(struct route_map_index *rmi);
 void routemap_hook_context_free(struct routemap_hook_context *rhc);
 
 extern const struct frr_yang_module_info frr_route_map_info;
+extern const struct frr_yang_module_info frr_route_map_cli_info;
 
 /* routemap_cli.c */
 extern int route_map_instance_cmp(const struct lyd_node *dnode1,
index a7a77cc23b5e15c1d894f736d7e35809c50afff8..1bba4dad47a637250b20bfa6f2d48901061a5299 100644 (file)
@@ -1550,3 +1550,45 @@ const struct frr_yang_module_info frr_route_map_info = {
                },
        }
 };
+
+const struct frr_yang_module_info frr_route_map_cli_info = {
+       .name = "frr-route-map",
+       .ignore_cfg_cbs = true,
+       .nodes = {
+               {
+                       .xpath = "/frr-route-map:lib/route-map/optimization-disabled",
+                       .cbs.cli_show = route_map_optimization_disabled_show,
+               },
+               {
+                       .xpath = "/frr-route-map:lib/route-map/entry",
+                       .cbs = {
+                               .cli_cmp = route_map_instance_cmp,
+                               .cli_show = route_map_instance_show,
+                               .cli_show_end = route_map_instance_show_end,
+                       }
+               },
+               {
+                       .xpath = "/frr-route-map:lib/route-map/entry/description",
+                       .cbs.cli_show = route_map_description_show,
+               },
+               {
+                       .xpath = "/frr-route-map:lib/route-map/entry/call",
+                       .cbs.cli_show = route_map_call_show,
+               },
+               {
+                       .xpath = "/frr-route-map:lib/route-map/entry/exit-policy",
+                       .cbs.cli_show = route_map_exit_policy_show,
+               },
+               {
+                       .xpath = "/frr-route-map:lib/route-map/entry/match-condition",
+                       .cbs.cli_show = route_map_condition_show,
+               },
+               {
+                       .xpath = "/frr-route-map:lib/route-map/entry/set-action",
+                       .cbs.cli_show = route_map_action_show,
+               },
+               {
+                       .xpath = NULL,
+               },
+       }
+};
index 743091e5c47b49ca438fbc4e15a15b2f64fbf2b1..9340d3d10746723c0ebb47689019b9baa76df54c 100644 (file)
@@ -172,7 +172,7 @@ const struct frr_yang_module_info zebra_route_map_info = {
 static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
        &frr_filter_info,
        &frr_interface_info,
-       &frr_route_map_info,
+       &frr_route_map_cli_info,
        &frr_routing_info,
        &frr_vrf_info,
 
index f4b24acf3ace129afcfdc59195a4cc0d96ddac04..5aca6a8ef6d3a69464b483c4044e7afb60167146 100644 (file)
@@ -12,6 +12,7 @@
 #include "json.h"
 #include "network.h"
 #include "northbound_cli.h"
+#include "routemap.h"
 
 #include "mgmtd/mgmt.h"
 #include "mgmtd/mgmt_be_adapter.h"
@@ -560,6 +561,11 @@ static struct cmd_node mgmtd_node = {
 
 void mgmt_vty_init(void)
 {
+       /*
+        * Library based CLI handlers
+        */
+       route_map_cli_init();
+
        /*
         * Initialize command handling from VTYSH connection.
         * Call command initialization routines defined by
index 75fff8ddd9c399695979d49bfc042dea85e35fb8..36e37e3230336ac4c09759f9ca0fe10b11426176 100644 (file)
@@ -37,14 +37,14 @@ daemon_flags = {
     "lib/filter_cli.c": "VTYSH_ACL",
     "lib/if.c": "VTYSH_INTERFACE",
     "lib/keychain.c": "VTYSH_KEYS",
-    "lib/mgmt_be_client.c": "VTYSH_STATICD|VTYSH_ZEBRA",
-    "lib/mgmt_fe_client.c": "VTYSH_MGMTD",
+    "lib/mgmt_be_client.c": "VTYSH_MGMT_BACKEND",
+    "lib/mgmt_fe_client.c": "VTYSH_MGMT_FRONTEND",
     "lib/lib_vty.c": "VTYSH_ALL",
     "lib/log_vty.c": "VTYSH_ALL",
     "lib/nexthop_group.c": "VTYSH_NH_GROUP",
     "lib/resolver.c": "VTYSH_NHRPD|VTYSH_BGPD",
-    "lib/routemap.c": "VTYSH_RMAP",
-    "lib/routemap_cli.c": "VTYSH_RMAP",
+    "lib/routemap.c": "VTYSH_RMAP_SHOW",
+    "lib/routemap_cli.c": "VTYSH_RMAP_CONFIG",
     "lib/spf_backoff.c": "VTYSH_ISISD",
     "lib/event.c": "VTYSH_ALL",
     "lib/vrf.c": "VTYSH_VRF",
index 3109f1510d971f3954a4a70bbc6e1def63882e1b..e86eeeb2870ec41ebefefb370c6e492e29a1d7af 100644 (file)
@@ -2303,7 +2303,7 @@ DEFUNSH(VTYSH_AFFMAP, no_affinity_map, vtysh_no_affinity_map_cmd,
        return CMD_SUCCESS;
 }
 
-DEFUNSH(VTYSH_RMAP, vtysh_route_map, vtysh_route_map_cmd,
+DEFUNSH(VTYSH_RMAP_CONFIG, vtysh_route_map, vtysh_route_map_cmd,
        "route-map RMAP_NAME <deny|permit> (1-65535)",
        "Create route-map or enter route-map command mode\n"
        "Route map tag\n"
@@ -2572,13 +2572,13 @@ DEFUNSH(VTYSH_RIPNGD, vtysh_quit_ripngd, vtysh_quit_ripngd_cmd, "quit",
 }
 #endif /* HAVE_RIPNGD */
 
-DEFUNSH(VTYSH_RMAP, vtysh_exit_rmap, vtysh_exit_rmap_cmd, "exit",
+DEFUNSH(VTYSH_RMAP_CONFIG, vtysh_exit_rmap, vtysh_exit_rmap_cmd, "exit",
        "Exit current mode and down to previous mode\n")
 {
        return vtysh_exit(vty);
 }
 
-DEFUNSH(VTYSH_RMAP, vtysh_quit_rmap, vtysh_quit_rmap_cmd, "quit",
+DEFUNSH(VTYSH_RMAP_CONFIG, vtysh_quit_rmap, vtysh_quit_rmap_cmd, "quit",
        "Exit current mode and down to previous mode\n")
 {
        return vtysh_exit_rmap(self, vty, argc, argv);
@@ -3455,7 +3455,7 @@ static void show_route_map_send(const char *route_map, bool json)
                const struct vtysh_client *client = &vtysh_client[i];
                bool is_connected = true;
 
-               if (!CHECK_FLAG(client->flag, VTYSH_RMAP))
+               if (!CHECK_FLAG(client->flag, VTYSH_RMAP_SHOW))
                        continue;
 
                for (; client; client = client->next)
index 6bc0c5e2c5f8f8d0f8b69af1f56058e36a150866..9081cab763e2316f3f61e4d284a181c6b8b7c77e 100644 (file)
@@ -51,7 +51,14 @@ extern struct event_loop *master;
                VTYSH_FABRICD | VTYSH_VRRPD | VTYSH_PATHD | VTYSH_MGMTD
 #define VTYSH_ACL         VTYSH_BFDD|VTYSH_BABELD|VTYSH_BGPD|VTYSH_EIGRPD|VTYSH_ISISD|VTYSH_FABRICD|VTYSH_LDPD|VTYSH_NHRPD|VTYSH_OSPF6D|VTYSH_OSPFD|VTYSH_PBRD|VTYSH_PIMD|VTYSH_PIM6D|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_VRRPD|VTYSH_ZEBRA
 #define VTYSH_AFFMAP VTYSH_ZEBRA | VTYSH_ISISD
-#define VTYSH_RMAP       VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD|VTYSH_EIGRPD|VTYSH_FABRICD
+#define VTYSH_RMAP_CONFIG                                                      \
+       VTYSH_ZEBRA | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | VTYSH_BGPD | \
+               VTYSH_ISISD | VTYSH_PIMD | VTYSH_EIGRPD | VTYSH_FABRICD |      \
+               VTYSH_MGMTD
+#define VTYSH_RMAP_SHOW                                                        \
+       VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | \
+               VTYSH_BGPD | VTYSH_ISISD | VTYSH_PIMD | VTYSH_EIGRPD |         \
+               VTYSH_FABRICD
 #define VTYSH_INTERFACE_SUBSET                                                 \
        VTYSH_ZEBRA | VTYSH_RIPD | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | \
                VTYSH_ISISD | VTYSH_PIMD | VTYSH_PIM6D | VTYSH_NHRPD |         \
@@ -64,6 +71,8 @@ extern struct event_loop *master;
 #define VTYSH_NH_GROUP    VTYSH_PBRD|VTYSH_SHARPD
 #define VTYSH_SR          VTYSH_ZEBRA|VTYSH_PATHD
 #define VTYSH_DPDK VTYSH_ZEBRA
+#define VTYSH_MGMT_BACKEND  VTYSH_RIPD | VTYSH_STATICD | VTYSH_ZEBRA
+#define VTYSH_MGMT_FRONTEND VTYSH_MGMTD
 
 enum vtysh_write_integrated {
        WRITE_INTEGRATED_UNSPECIFIED,