From 0e37c258a3f238ae532ee4e0b4cd308556da8bae Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 27 Jan 2017 04:57:44 -0500 Subject: [PATCH] bgpd: Fix possible crash and some minor CR issues This fix addresses these things: 1) Clean up documentation as requested 2) Fix a wrong search for "exact-match" 3) Fix possible crash. Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 15 ++++++++++++--- bgpd/bgp_vty.c | 3 +++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 657cd076e7..573fc76655 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8120,7 +8120,7 @@ DEFUN (show_ip_bgp, if (argv_find(argv, argc, "community-list", &idx)) { const char *clist_number_or_name = argv[++idx]->arg; - if (++idx < argc && strmatch (argv[idx]->arg, "exact-match")) + if (++idx < argc && strmatch (argv[idx]->text, "exact-match")) exact_match = 1; return bgp_show_community_list (vty, bgp, clist_number_or_name, exact_match, afi, safi); } @@ -8179,7 +8179,10 @@ DEFUN (show_ip_bgp_route, } } else - bgp = NULL; + { + vty_out (vty, "Specified 'all' vrf's but this command currently only works per view/vrf%s", VTY_NEWLINE); + return CMD_WARNING; + } /* */ if (argv_find (argv, argc, "A.B.C.D", &idx) || argv_find (argv, argc, "X:X::X:X", &idx)) @@ -9034,9 +9037,15 @@ DEFUN (show_ip_bgp_vpn_all_route_prefix, { int idx = 0; char *network = NULL; + struct bgp *bgp = bgp_get_default(); + if (!bgp) + { + vty_out (vty, "Can't find default instance%s", VTY_NEWLINE); + return CMD_WARNING; + } network = argv_find (argv, argc, "A.B.C.D", &idx) ? argv[idx]->arg : NULL; network = argv_find (argv, argc, "A.B.C.D/M", &idx) ? argv[idx]->arg : NULL; - return bgp_show_route (vty, NULL, network, AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); + return bgp_show_route (vty, bgp, network, AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } #endif /* KEEP_OLD_VPN_COMMANDS */ diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 59af567800..208dd54460 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -227,6 +227,9 @@ argv_find_and_parse_safi (struct cmd_token **argv, int argc, int *index, safi_t * * The function returns the correct location in the parse tree for the * last token found. + * + * Returns 0 for failure to parse correctly, else the idx position of where + * it found the last token. */ int bgp_vty_find_and_parse_afi_safi_vrf (struct vty *vty, struct cmd_token **argv, int argc, int idx, -- 2.39.5