]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: convert filters to mgmtd
authorChristian Hopps <chopps@labn.net>
Wed, 24 Jan 2024 16:35:19 +0000 (11:35 -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/filter.c
lib/filter.h
lib/filter_nb.c
mgmtd/mgmt_main.c
mgmtd/mgmt_vty.c
python/xref2vtysh.py
vtysh/vtysh.h

index f86adab5d606575eecdc67d9923a45d1e26feea0..a0adff0e35dc36ba12bb4f3cbe573fe2a82bce84 100644 (file)
@@ -885,7 +885,7 @@ static void access_list_init_ipv6(void)
        install_element(ENABLE_NODE, &show_ipv6_access_list_name_cmd);
 }
 
-void access_list_init(void)
+void access_list_init_new(bool in_backend)
 {
        cmd_variable_handler_register(access_list_handlers);
 
@@ -893,7 +893,15 @@ void access_list_init(void)
        access_list_init_ipv6();
        access_list_init_mac();
 
-       filter_cli_init();
+       if (!in_backend) {
+               /* we do not want to handle config commands in the backend */
+               filter_cli_init();
+       }
+}
+
+void access_list_init(void)
+{
+       access_list_init_new(false);
 }
 
 void access_list_reset(void)
index e092f0771acc99939b50149505a0c61aa12819c3..bd9e22d38416a5019f80d763013217be14e5d0e4 100644 (file)
@@ -114,6 +114,7 @@ struct access_master {
 
 /* Prototypes for access-list. */
 extern void access_list_init(void);
+extern void access_list_init_new(bool in_backend);
 extern void access_list_reset(void);
 extern void access_list_add_hook(void (*func)(struct access_list *));
 extern void access_list_delete_hook(void (*func)(struct access_list *));
@@ -124,13 +125,13 @@ extern enum filter_type access_list_apply(struct access_list *access,
 struct access_list *access_list_get(afi_t afi, const char *name);
 void access_list_delete(struct access_list *access);
 struct filter *filter_new(void);
-void access_list_filter_add(struct access_list *access,
-                           struct filter *filter);
+void access_list_filter_add(struct access_list *access, struct filter *filter);
 void access_list_filter_delete(struct access_list *access,
                               struct filter *filter);
 int64_t filter_new_seq_get(struct access_list *access);
 
 extern const struct frr_yang_module_info frr_filter_info;
+extern const struct frr_yang_module_info frr_filter_cli_info;
 
 
 /* filter_nb.c */
index 1c436cc6f10a4bf987c831db7c7a4a336b7a361a..eba4e421c050a64f9b7f6fba32559138e36869a2 100644 (file)
@@ -1785,3 +1785,35 @@ const struct frr_yang_module_info frr_filter_info = {
                },
        }
 };
+
+const struct frr_yang_module_info frr_filter_cli_info = {
+       .name = "frr-filter",
+       .ignore_cfg_cbs = true,
+       .nodes = {
+               {
+                       .xpath = "/frr-filter:lib/access-list/remark",
+                       .cbs.cli_show = access_list_remark_show,
+               },
+               {
+                       .xpath = "/frr-filter:lib/access-list/entry",
+                       .cbs = {
+                               .cli_cmp = access_list_cmp,
+                               .cli_show = access_list_show,
+                       }
+               },
+               {
+                       .xpath = "/frr-filter:lib/prefix-list/remark",
+                       .cbs.cli_show = prefix_list_remark_show,
+               },
+               {
+                       .xpath = "/frr-filter:lib/prefix-list/entry",
+                       .cbs = {
+                               .cli_cmp = prefix_list_cmp,
+                               .cli_show = prefix_list_show,
+                       }
+               },
+               {
+                       .xpath = NULL,
+               },
+       }
+};
index 9340d3d10746723c0ebb47689019b9baa76df54c..bd0a9895c2949cf500caa7d86bd7aa270571f151 100644 (file)
@@ -170,7 +170,7 @@ const struct frr_yang_module_info zebra_route_map_info = {
  * MGMTd.
  */
 static const struct frr_yang_module_info *const mgmt_yang_modules[] = {
-       &frr_filter_info,
+       &frr_filter_cli_info,
        &frr_interface_info,
        &frr_route_map_cli_info,
        &frr_routing_info,
index 5aca6a8ef6d3a69464b483c4044e7afb60167146..5dd7be657af8347ab8d6e3f102fdf800ac2b5d05 100644 (file)
@@ -564,6 +564,7 @@ void mgmt_vty_init(void)
        /*
         * Library based CLI handlers
         */
+       filter_cli_init();
        route_map_cli_init();
 
        /*
index 36e37e3230336ac4c09759f9ca0fe10b11426176..edaa2945cec0bb40063c0e85603ffb709460b751 100644 (file)
@@ -33,8 +33,8 @@ frr_top_src = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 
 daemon_flags = {
     "lib/agentx.c": "VTYSH_ISISD|VTYSH_RIPD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD|VTYSH_ZEBRA",
-    "lib/filter.c": "VTYSH_ACL",
-    "lib/filter_cli.c": "VTYSH_ACL",
+    "lib/filter.c": "VTYSH_ACL_SHOW",
+    "lib/filter_cli.c": "VTYSH_ACL_CONFIG",
     "lib/if.c": "VTYSH_INTERFACE",
     "lib/keychain.c": "VTYSH_KEYS",
     "lib/mgmt_be_client.c": "VTYSH_MGMT_BACKEND",
index 9081cab763e2316f3f61e4d284a181c6b8b7c77e..7671609e3a482908ad6ee0aea169df34d2bd81da 100644 (file)
@@ -49,7 +49,17 @@ extern struct event_loop *master;
                VTYSH_PIM6D | VTYSH_NHRPD | VTYSH_EIGRPD | VTYSH_BABELD |      \
                VTYSH_SHARPD | VTYSH_PBRD | VTYSH_STATICD | VTYSH_BFDD |       \
                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_ACL_CONFIG                                                       \
+       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_RIPNGD | VTYSH_VRRPD | VTYSH_ZEBRA | VTYSH_MGMTD
+#define VTYSH_ACL_SHOW                                                         \
+       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_CONFIG                                                      \
        VTYSH_ZEBRA | VTYSH_RIPNGD | VTYSH_OSPFD | VTYSH_OSPF6D | VTYSH_BGPD | \