]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: convert if_rmap config output to northbound
authorIgor Ryzhov <iryzhov@nfware.com>
Wed, 12 Apr 2023 14:17:03 +0000 (17:17 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 12 Apr 2023 14:17:03 +0000 (17:17 +0300)
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
lib/if_rmap.c
lib/if_rmap.h
ripd/rip_nb.c
ripd/ripd.c
ripngd/ripng_nb.c
ripngd/ripngd.c

index 5895924a5e90072e554624e84ea42ad6392263a0..42e162072ff3d98ac9d87c7d9364fff0dbbc8121 100644 (file)
@@ -240,6 +240,18 @@ DEFPY_YANG(no_if_ipv6_route_map, no_if_ipv6_route_map_cmd,
                                    route_map);
 }
 
+void cli_show_if_route_map(struct vty *vty, const struct lyd_node *dnode,
+                          bool show_defaults)
+{
+       if (yang_dnode_exists(dnode, "./in-route-map"))
+               vty_out(vty, " route-map %s in %s\n",
+                       yang_dnode_get_string(dnode, "./in-route-map"),
+                       yang_dnode_get_string(dnode, "./interface"));
+       if (yang_dnode_exists(dnode, "./out-route-map"))
+               vty_out(vty, " route-map %s out %s\n",
+                       yang_dnode_get_string(dnode, "./out-route-map"),
+                       yang_dnode_get_string(dnode, "./interface"));
+}
 
 void if_rmap_yang_modify_cb(struct if_rmap_ctx *ctx,
                            const struct lyd_node *dnode,
@@ -263,38 +275,6 @@ void if_rmap_yang_destroy_cb(struct if_rmap_ctx *ctx,
        if_rmap_unset(ctx, ifname, IF_RMAP_OUT);
 }
 
-
-/* Configuration write function. */
-int config_write_if_rmap(struct vty *vty, struct if_rmap_ctx *ctx)
-{
-       unsigned int i;
-       struct hash_bucket *mp;
-       int write = 0;
-       struct hash *ifrmaphash = ctx->ifrmaphash;
-
-       for (i = 0; i < ifrmaphash->size; i++)
-               for (mp = ifrmaphash->index[i]; mp; mp = mp->next) {
-                       struct if_rmap *if_rmap;
-
-                       if_rmap = mp->data;
-
-                       if (if_rmap->routemap[IF_RMAP_IN]) {
-                               vty_out(vty, " route-map %s in %s\n",
-                                       if_rmap->routemap[IF_RMAP_IN],
-                                       if_rmap->ifname);
-                               write++;
-                       }
-
-                       if (if_rmap->routemap[IF_RMAP_OUT]) {
-                               vty_out(vty, " route-map %s out %s\n",
-                                       if_rmap->routemap[IF_RMAP_OUT],
-                                       if_rmap->ifname);
-                               write++;
-                       }
-               }
-       return write;
-}
-
 void if_rmap_ctx_delete(struct if_rmap_ctx *ctx)
 {
        hash_clean_and_free(&ctx->ifrmaphash, (void (*)(void *))if_rmap_free);
index 6f5fb578f00267a9d913c78203ddb3c35f8499a9..a9f811e2210c788c0abc437899480d4c2ee770af 100644 (file)
@@ -56,6 +56,8 @@ extern void if_rmap_yang_modify_cb(struct if_rmap_ctx *ctx,
 extern void if_rmap_yang_destroy_cb(struct if_rmap_ctx *ctx,
                                    const struct lyd_node *dnode);
 extern int config_write_if_rmap(struct vty *, struct if_rmap_ctx *ctx);
+void cli_show_if_route_map(struct vty *vty, const struct lyd_node *dnode,
+                          bool show_defaults);
 
 #ifdef __cplusplus
 }
index 1a7b34adde484d405fc12b6940d37aa6408ef4ca..fa6652faf4043131c612846480390224adb7a190 100644 (file)
@@ -10,6 +10,7 @@
 #include "libfrr.h"
 
 #include "ripd/rip_nb.h"
+#include "lib/if_rmap.h"
 
 /* clang-format off */
 const struct frr_yang_module_info frr_ripd_info = {
@@ -170,6 +171,7 @@ const struct frr_yang_module_info frr_ripd_info = {
                        .cbs = {
                                .create = ripd_instance_if_route_maps_if_route_map_create,
                                .destroy = ripd_instance_if_route_maps_if_route_map_destroy,
+                               .cli_show = cli_show_if_route_map,
                        }
                },
                {
index 7dbe2bbccf7d696bf0f127bc5049fa8e5e307670..fb3d574aaa70b71459875455c989610ef1233e7b 100644 (file)
@@ -3204,9 +3204,6 @@ static int config_write_rip(struct vty *vty)
                /* Distribute configuration. */
                config_write_distribute(vty, rip->distribute_ctx);
 
-               /* Interface routemap configuration */
-               config_write_if_rmap(vty, rip->if_rmap_ctx);
-
                vty_out(vty, "exit\n");
 
                write = 1;
index 2f412e5197e639161d50a7e1c4362b42b35435a1..1c6d7191a3a8a13e13bcf7b2d92f8c1139aa9b19 100644 (file)
@@ -10,6 +10,7 @@
 #include "libfrr.h"
 
 #include "ripngd/ripng_nb.h"
+#include "lib/if_rmap.h"
 
 /* clang-format off */
 const struct frr_yang_module_info frr_ripngd_info = {
@@ -119,6 +120,7 @@ const struct frr_yang_module_info frr_ripngd_info = {
                        .cbs = {
                                .create = ripngd_instance_if_route_maps_if_route_map_create,
                                .destroy = ripngd_instance_if_route_maps_if_route_map_destroy,
+                               .cli_show = cli_show_if_route_map,
                        }
                },
                {
index 79e8871f6a5f5dc35e0a3beceafcc987987b558c..2f6409a70d31d6ddf5cb55dadc91161bafe46a5b 100644 (file)
@@ -2231,7 +2231,6 @@ static int ripng_config_write(struct vty *vty)
                nb_cli_show_dnode_cmds(vty, dnode, false);
 
                config_write_distribute(vty, ripng->distribute_ctx);
-               config_write_if_rmap(vty, ripng->if_rmap_ctx);
 
                vty_out(vty, "exit\n");