From 88b7d2555c577a9ba947f3043a33cdf6b90776a7 Mon Sep 17 00:00:00 2001 From: Don Slice Date: Wed, 23 May 2018 08:09:59 -0400 Subject: [PATCH 1/2] bgpd: improve error message for neighbor not found Problem reported due to tab completion showing all possible peers in every vrf, but when neighbor in wrong vrf entered "no such neighbor" is the error message. Making it slightly more clear with "no such neighbor in the view/vrf" to clue the user that they may have specified the wrong vrf. Signed-off-by: Don Slice --- bgpd/bgp_vty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index f4f4e63264..a81a83edde 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10655,7 +10655,7 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, if (use_json) json_object_boolean_true_add(json, "bgpNoSuchNeighbor"); else - vty_out(vty, "%% No such neighbor\n"); + vty_out(vty, "%% No such neighbor in this view/vrf\n"); } if (use_json) { From 9e6e6f46eebb3c7d02643d53ceced6d08ba10db2 Mon Sep 17 00:00:00 2001 From: Don Slice Date: Thu, 24 May 2018 10:58:37 -0400 Subject: [PATCH 2/2] bgpd: additional neighbor message improvement Added improved error message text to other places that could also encounter the same condition. In testing found that in certain case, duplicate error messages were previously issued. This fix also removes the duplicates. Signed-off-by: Don Slice --- bgpd/bgp_route.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 004bdb2ef4..d0c2ff8186 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -9648,13 +9648,13 @@ static struct peer *peer_lookup_in_view(struct vty *vty, struct bgp *bgp, json_object *json_no = NULL; json_no = json_object_new_object(); json_object_string_add(json_no, "warning", - "No such neighbor"); + "No such neighbor in this view/vrf"); vty_out(vty, "%s\n", json_object_to_json_string_ext( json_no, JSON_C_TO_STRING_PRETTY)); json_object_free(json_no); } else - vty_out(vty, "No such neighbor\n"); + vty_out(vty, "No such neighbor in this view/vrf\n"); return NULL; } @@ -10752,10 +10752,8 @@ DEFUN (show_ip_bgp_neighbor_routes, peerstr = argv[++idx]->arg; peer = peer_lookup_in_view(vty, bgp, peerstr, uj); - if (!peer) { - vty_out(vty, "No such neighbor\n"); + if (!peer) return CMD_WARNING; - } if (argv_find(argv, argc, "flap-statistics", &idx)) sh_type = bgp_show_type_flap_neighbor;