]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: routemap config output cleanup 10170/head
authorIgor Ryzhov <iryzhov@nfware.com>
Fri, 3 Dec 2021 18:00:01 +0000 (21:00 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Fri, 3 Dec 2021 18:00:01 +0000 (21:00 +0300)
Just a small cleanup to unify the code and remove duplication.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
lib/routemap_cli.c

index 52fcaaba53afd738f73c526287a08291c7013653..2685bd2d79978b2606a944bb592f55e4e8f747f7 100644 (file)
@@ -550,23 +550,18 @@ void route_map_condition_show(struct vty *vty, const struct lyd_node *dnode,
                vty_out(vty, " match interface %s\n",
                        yang_dnode_get_string(
                                dnode, "./rmap-match-condition/interface"));
-       } else if (IS_MATCH_IPv4_ADDRESS_LIST(condition)
-                  || IS_MATCH_IPv6_NEXTHOP_LIST(condition)
-                  || IS_MATCH_IPv4_NEXTHOP_LIST(condition)) {
-               acl = NULL;
-               if ((ln = yang_dnode_get(dnode,
-                                        "./rmap-match-condition/list-name"))
-                   != NULL)
-                       acl = yang_dnode_get_string(ln, NULL);
-
-               assert(acl);
-
-               if (IS_MATCH_IPv4_ADDRESS_LIST(condition))
-                       vty_out(vty, " match ip address %s\n", acl);
-               else if (IS_MATCH_IPv4_NEXTHOP_LIST(condition))
-                       vty_out(vty, " match ip next-hop %s\n", acl);
-               else
-                       vty_out(vty, " match ipv6 next-hop %s\n", acl);
+       } else if (IS_MATCH_IPv4_ADDRESS_LIST(condition)) {
+               vty_out(vty, " match ip address %s\n",
+                       yang_dnode_get_string(
+                               dnode, "./rmap-match-condition/list-name"));
+       } else if (IS_MATCH_IPv4_NEXTHOP_LIST(condition)) {
+               vty_out(vty, " match ip next-hop %s\n",
+                       yang_dnode_get_string(
+                               dnode, "./rmap-match-condition/list-name"));
+       } else if (IS_MATCH_IPv6_NEXTHOP_LIST(condition)) {
+               vty_out(vty, " match ipv6 next-hop %s\n",
+                       yang_dnode_get_string(
+                               dnode, "./rmap-match-condition/list-name"));
        } else if (IS_MATCH_IPv4_PREFIX_LIST(condition)) {
                vty_out(vty, " match ip address prefix-list %s\n",
                        yang_dnode_get_string(
@@ -719,84 +714,40 @@ void route_map_condition_show(struct vty *vty, const struct lyd_node *dnode,
                                dnode,
                                "./rmap-match-condition/frr-bgp-route-map:list-name"));
        } else if (IS_MATCH_ROUTE_SRC(condition)) {
-               acl = NULL;
-               if ((ln = yang_dnode_get(
-                            dnode,
-                            "./rmap-match-condition/frr-bgp-route-map:list-name"))
-                   != NULL)
-                       acl = yang_dnode_get_string(ln, NULL);
-
-               assert(acl);
-
-               vty_out(vty, " match ip route-source %s\n", acl);
+               vty_out(vty, " match ip route-source %s\n",
+                       yang_dnode_get_string(
+                               dnode,
+                               "./rmap-match-condition/frr-bgp-route-map:list-name"));
        } else if (IS_MATCH_ROUTE_SRC_PL(condition)) {
                vty_out(vty, " match ip route-source prefix-list %s\n",
                        yang_dnode_get_string(
                                dnode,
                                "./rmap-match-condition/frr-bgp-route-map:list-name"));
-       } else if (IS_MATCH_ROUTE_SRC(condition)) {
-               acl = NULL;
-               if ((ln = yang_dnode_get(
-                            dnode,
-                            "./rmap-match-condition/frr-bgp-route-map:list-name"))
-                   != NULL)
-                       acl = yang_dnode_get_string(ln, NULL);
-
-               assert(acl);
-
-               vty_out(vty, " match ip route-source %s\n", acl);
        } else if (IS_MATCH_COMMUNITY(condition)) {
-               acl = NULL;
-               if ((ln = yang_dnode_get(
-                                dnode,
-                                "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"))
-                       != NULL) {
-                       acl = yang_dnode_get_string(ln, NULL);
-
-                       if (true
-                           == yang_dnode_get_bool(
-                                   dnode,
-                                   "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
-                               vty_out(vty,
-                                       " match community %s exact-match\n",
-                                       acl);
-                       else
-                               vty_out(vty, " match community %s\n", acl);
-               }
-
-               assert(acl);
+               vty_out(vty, " match community %s",
+                       yang_dnode_get_string(
+                               dnode,
+                               "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
+               if (yang_dnode_get_bool(
+                           dnode,
+                           "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
+                       vty_out(vty, " exact-match");
+               vty_out(vty, "\n");
        } else if (IS_MATCH_LCOMMUNITY(condition)) {
-               acl = NULL;
-               if ((ln = yang_dnode_get(
-                                dnode,
-                                "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"))
-                       != NULL) {
-                       acl = yang_dnode_get_string(ln, NULL);
-
-                       if (true
-                           == yang_dnode_get_bool(
-                                   dnode,
-                                   "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
-                               vty_out(vty,
-                                       " match large-community %s exact-match\n",
-                                       acl);
-                       else
-                               vty_out(vty, " match large-community %s\n",
-                                       acl);
-               }
-
-               assert(acl);
+               vty_out(vty, " match large-community %s",
+                       yang_dnode_get_string(
+                               dnode,
+                               "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
+               if (yang_dnode_get_bool(
+                           dnode,
+                           "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name-exact-match"))
+                       vty_out(vty, " exact-match");
+               vty_out(vty, "\n");
        } else if (IS_MATCH_EXTCOMMUNITY(condition)) {
-               acl = NULL;
-               if ((ln = yang_dnode_get(
-                                dnode,
-                                "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"))
-                       != NULL)
-                       acl = yang_dnode_get_string(ln, NULL);
-
-               assert(acl);
-
-               vty_out(vty, " match extcommunity %s\n", acl);
+               vty_out(vty, " match extcommunity %s\n",
+                       yang_dnode_get_string(
+                               dnode,
+                               "./rmap-match-condition/frr-bgp-route-map:comm-list/comm-list-name"));
        } else if (IS_MATCH_IPV4_NH(condition)) {
                vty_out(vty, " match ip next-hop address %s\n",
                        yang_dnode_get_string(