From 5ce77b2b1e6a4ce110f86180da4371a21dadb56e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 2 May 2017 10:20:10 -0400 Subject: [PATCH 1/4] bgpd: Fix 'show bgp ... summary json' to have empty {} When we have no output for a json command we should have an empty {} displayed. Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 361ab33962..a30721715c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -6759,6 +6759,7 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, int afi_wildcard = (afi == AFI_MAX); int safi_wildcard = (safi == SAFI_MAX); int is_wildcard = (afi_wildcard || safi_wildcard); + bool json_output = false; if (use_json && is_wildcard) vty_out (vty, "{%s", VTY_NEWLINE); @@ -6772,6 +6773,7 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, { if (bgp_show_summary_afi_safi_peer_exists (bgp, afi, safi)) { + json_output = true; if (is_wildcard) { /* @@ -6812,7 +6814,8 @@ bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, if (use_json && is_wildcard) vty_out (vty, "}%s", VTY_NEWLINE); - + else if (use_json && !json_output) + vty_out (vty, "{}%s", VTY_NEWLINE); } static void From 0ce5d20e460e416c4cffd4f0aa97b8c6a539416a Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 2 May 2017 21:48:46 -0400 Subject: [PATCH 2/4] bgpd: When receiving a route set the label to invalid When we are receiving a route the attr->extra->label_index is being set to 0. This should be BGP_INVALID_LABEL_INDEX instead since we cannot rely on 0 to be correct for labels. I believe that there are probably other spots that need this type of fix, but I will let testing snuggle-bump them out. Signed-off-by: Donald Sharp --- bgpd/bgp_packet.c | 1 + 1 file changed, 1 insertion(+) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 3b13055604..0800dd74ba 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1391,6 +1391,7 @@ bgp_update_receive (struct peer *peer, bgp_size_t size) /* Set initial values. */ memset (&attr, 0, sizeof (struct attr)); memset (&extra, 0, sizeof (struct attr_extra)); + extra.label_index = BGP_INVALID_LABEL_INDEX; memset (&nlris, 0, sizeof (nlris)); attr.extra = &extra; memset (peer->rcvd_attr_str, 0, BUFSIZ); From 9402b9f6487e34e7cfa0c090b0406083cc560082 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 2 May 2017 22:14:24 -0400 Subject: [PATCH 3/4] bgpd: Fix crash associated with aggregate command The cli rework created this issue Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 3e51831d18..3f4f1324f8 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -5860,9 +5860,8 @@ DEFUN (aggregate_address_mask, { int idx = 0; argv_find (argv, argc, "A.B.C.D", &idx); - char *prefix = argv[idx++]->arg; - argv_find (argv, argc, "A.B.C.D", &idx); - char *mask = argv[idx]->arg; + char *prefix = argv[idx]->arg; + char *mask = argv[idx+1]->arg; int as_set = argv_find (argv, argc, "as-set", &idx) ? AGGREGATE_AS_SET : 0; idx = 0; int summary_only = argv_find (argv, argc, "summary-only", &idx) ? AGGREGATE_SUMMARY_ONLY : 0; @@ -5910,9 +5909,8 @@ DEFUN (no_aggregate_address_mask, { int idx = 0; argv_find (argv, argc, "A.B.C.D", &idx); - char *prefix = argv[idx++]->arg; - argv_find (argv, argc, "A.B.C.D", &idx); - char *mask = argv[idx]->arg; + char *prefix = argv[idx]->arg; + char *mask = argv[idx++]->arg; char prefix_str[BUFSIZ]; int ret = netmask_str2prefix_str (prefix, mask, prefix_str); From 090ba7ca157df9478f9e9c220f5457ff3db82e7f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 3 May 2017 10:24:04 -0400 Subject: [PATCH 4/4] vtysh: Fix _ instead of - usage for labeled_unicast Signed-off-by: Donald Sharp --- vtysh/vtysh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index e90228b424..1d16f11375 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1210,7 +1210,7 @@ DEFUNSH (VTYSH_BGPD, DEFUNSH (VTYSH_BGPD, address_family_ipv4_labeled_unicast, address_family_ipv4_labeled_unicast_cmd, - "address-family ipv4 labeled_unicast", + "address-family ipv4 labeled-unicast", "Enter Address Family command mode\n" "Address Family\n" "Address Family modifier\n") @@ -1258,7 +1258,7 @@ DEFUNSH (VTYSH_BGPD, DEFUNSH (VTYSH_BGPD, address_family_ipv6_labeled_unicast, address_family_ipv6_labeled_unicast_cmd, - "address-family ipv6 labeled_unicast", + "address-family ipv6 labeled-unicast", "Enter Address Family command mode\n" "Address Family\n" "Address Family modifier\n")