diff options
| author | Igor Ryzhov <iryzhov@nfware.com> | 2021-12-03 21:00:01 +0300 |
|---|---|---|
| committer | Igor Ryzhov <iryzhov@nfware.com> | 2021-12-03 21:00:01 +0300 |
| commit | fb2e99ef9c18fd6786fcb1e670f1bd46257e791b (patch) | |
| tree | 08885d4c3f2f3581b858ba0246dbe33f7c75a1a6 /lib/routemap_cli.c | |
| parent | 22108570e3ba034c855aff140bababf231a66837 (diff) | |
lib: routemap config output cleanup
Just a small cleanup to unify the code and remove duplication.
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Diffstat (limited to 'lib/routemap_cli.c')
| -rw-r--r-- | lib/routemap_cli.c | 125 |
1 files changed, 38 insertions, 87 deletions
diff --git a/lib/routemap_cli.c b/lib/routemap_cli.c index 52fcaaba53..2685bd2d79 100644 --- a/lib/routemap_cli.c +++ b/lib/routemap_cli.c @@ -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( |
