From d39cdd933f499e94577e1888fd78123a6dfe2d44 Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Wed, 26 Apr 2017 15:53:35 +0000 Subject: [PATCH] BGP_ATTR_LABEL_INDEX fixes Signed-off-by: Daniel Walton - cleaned up the "show bgp ipv4 labeled-unicast x.x.x.x" output - fixed some json keys to use camelCase - bgp_attr_label_index() was clearing BGP_ATTR_LABEL_INDEX because it was comparing mp_update->afi against SAFI_LABELED_UNICAST instead of mp_update->safi - added BGP_ATTR_LABEL_INDEX to attr_str --- bgpd/bgp_attr.c | 5 +++-- bgpd/bgp_route.c | 15 +++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 6f4e797a94..a25ebf4772 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -78,7 +78,8 @@ static const struct message attr_str [] = #if ENABLE_BGP_VNC { BGP_ATTR_VNC, "VNC" }, #endif - { BGP_ATTR_LARGE_COMMUNITIES, "LARGE_COMMUNITY" } + { BGP_ATTR_LARGE_COMMUNITIES, "LARGE_COMMUNITY" }, + { BGP_ATTR_LABEL_INDEX, "LABEL_INDEX" } }; static const int attr_str_max = array_size(attr_str); @@ -2315,7 +2316,7 @@ bgp_attr_label_index (struct bgp_attr_parser_args *args, struct bgp_nlri *mp_upd * Ignore the Label index attribute unless received for labeled-unicast * SAFI. We reset the flag, though it is probably unnecesary. */ - if (!mp_update->length || mp_update->afi != SAFI_LABELED_UNICAST) + if (!mp_update->length || mp_update->safi != SAFI_LABELED_UNICAST) { attr->extra->label_index = BGP_INVALID_LABEL_INDEX; attr->flag &= ~ATTR_FLAG_BIT(BGP_ATTR_LABEL_INDEX); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 140003cef0..88147e2b68 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7653,33 +7653,28 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, if (binfo->extra && binfo->extra->damp_info) bgp_damp_info_vty (vty, binfo, json_path); + /* Label information */ if ((bgp_labeled_safi(safi) && binfo->extra) || (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LABEL_INDEX)))) { - if (!json_paths) - vty_out (vty, "%s ", VTY_NEWLINE); - if (bgp_labeled_safi(safi) && binfo->extra) { uint32_t label = label_pton(binfo->extra->tag); if (json_paths) - json_object_int_add(json_path, "remote-label", label); + json_object_int_add(json_path, "remoteLabel", label); else - vty_out(vty, "Remote label: %d, ", label); + vty_out(vty, " Remote label: %d%s", label, VTY_NEWLINE); } if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LABEL_INDEX))) { if (json_paths) - json_object_int_add(json_path, "label-index", attr->extra->label_index); + json_object_int_add(json_path, "labelIndex", attr->extra->label_index); else - vty_out(vty, "Label Index: %d", attr->extra->label_index); + vty_out(vty, " Label Index: %d%s", attr->extra->label_index, VTY_NEWLINE); } } - if (!json_paths) - vty_out (vty, "%s", VTY_NEWLINE); - /* Line 8 display Addpath IDs */ if (binfo->addpath_rx_id || binfo->addpath_tx_id) { -- 2.39.5