From 4e5c876fcbaabab958d4f5ceb3a509c9c5c75644 Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Fri, 9 Feb 2018 09:29:39 -0800 Subject: [PATCH 1/5] bgpd: json route table brace counting --- bgpd/bgp_route.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 36e0c92482a8..ea2c4aea9768 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7872,7 +7872,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_table *table, enum bgp_show_type type, void *output_arg, u_char use_json, char *rd, int is_last, - unsigned long *output_cum, unsigned long *total_cum) + unsigned long *output_cum, unsigned long *total_cum, + unsigned long *json_header_depth) { struct bgp_info *ri; struct bgp_node *rn; @@ -7889,7 +7890,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, if (output_cum && *output_cum != 0) header = 0; - if (use_json && header) { + if (use_json && !*json_header_depth) { vty_out(vty, "{\n \"vrfId\": %d,\n \"vrfName\": \"%s\",\n \"tableVersion\": %" PRId64 ",\n \"routerId\": \"%s\",\n \"routes\": { ", @@ -7897,8 +7898,11 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? "Default" : bgp->name, table->version, inet_ntoa(bgp->router_id)); - if (rd) + *json_header_depth = 2; + if (rd) { vty_out(vty, " \"routeDistinguishers\" : {"); + ++*json_header_depth; + } json_paths = json_object_new_object(); } @@ -8131,10 +8135,14 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, if (use_json) { if (json_paths) json_object_free(json_paths); - if (is_last) - vty_out(vty, " } }\n"); - else - vty_out(vty, " }, "); + if (rd) { + vty_out(vty, " }%s ", (is_last? "": ",")); + } + if (is_last) { + unsigned long i; + for (i = 0; i < *json_header_depth; ++i) + vty_out(vty, " } "); + } } else { if (is_last) { /* No route is displayed */ @@ -8161,6 +8169,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_node *rn, *next; unsigned long output_cum = 0; unsigned long total_cum = 0; + unsigned long json_header_depth = 0; bool show_msg; show_msg = (!use_json && type == bgp_show_type_normal); @@ -8178,7 +8187,8 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, bgp_show_table(vty, bgp, safi, rn->info, type, output_arg, use_json, rd, next == NULL, - &output_cum, &total_cum); + &output_cum, &total_cum, + &json_header_depth); if (next == NULL) show_msg = false; } @@ -8192,14 +8202,13 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, "\nDisplayed %ld routes and %ld total paths\n", output_cum, total_cum); } - if (use_json) - vty_out(vty, " } }"); return CMD_SUCCESS; } static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, enum bgp_show_type type, void *output_arg, u_char use_json) { struct bgp_table *table; + unsigned long json_header_depth = 0; if (bgp == NULL) { bgp = bgp_get_default(); @@ -8224,7 +8233,7 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, safi = SAFI_UNICAST; return bgp_show_table(vty, bgp, safi, table, type, output_arg, use_json, - NULL, 1, NULL, NULL); + NULL, 1, NULL, NULL, &json_header_depth); } static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi, From 9386b58830660dc0c686ed9c7b0026f4fc94a35b Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Fri, 9 Feb 2018 09:29:39 -0800 Subject: [PATCH 2/5] bgpd: json route table brace counting Signed-off-by: G. Paul Ziemba --- bgpd/bgp_route.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 36e0c92482a8..ea2c4aea9768 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7872,7 +7872,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_table *table, enum bgp_show_type type, void *output_arg, u_char use_json, char *rd, int is_last, - unsigned long *output_cum, unsigned long *total_cum) + unsigned long *output_cum, unsigned long *total_cum, + unsigned long *json_header_depth) { struct bgp_info *ri; struct bgp_node *rn; @@ -7889,7 +7890,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, if (output_cum && *output_cum != 0) header = 0; - if (use_json && header) { + if (use_json && !*json_header_depth) { vty_out(vty, "{\n \"vrfId\": %d,\n \"vrfName\": \"%s\",\n \"tableVersion\": %" PRId64 ",\n \"routerId\": \"%s\",\n \"routes\": { ", @@ -7897,8 +7898,11 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT ? "Default" : bgp->name, table->version, inet_ntoa(bgp->router_id)); - if (rd) + *json_header_depth = 2; + if (rd) { vty_out(vty, " \"routeDistinguishers\" : {"); + ++*json_header_depth; + } json_paths = json_object_new_object(); } @@ -8131,10 +8135,14 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, if (use_json) { if (json_paths) json_object_free(json_paths); - if (is_last) - vty_out(vty, " } }\n"); - else - vty_out(vty, " }, "); + if (rd) { + vty_out(vty, " }%s ", (is_last? "": ",")); + } + if (is_last) { + unsigned long i; + for (i = 0; i < *json_header_depth; ++i) + vty_out(vty, " } "); + } } else { if (is_last) { /* No route is displayed */ @@ -8161,6 +8169,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_node *rn, *next; unsigned long output_cum = 0; unsigned long total_cum = 0; + unsigned long json_header_depth = 0; bool show_msg; show_msg = (!use_json && type == bgp_show_type_normal); @@ -8178,7 +8187,8 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, bgp_show_table(vty, bgp, safi, rn->info, type, output_arg, use_json, rd, next == NULL, - &output_cum, &total_cum); + &output_cum, &total_cum, + &json_header_depth); if (next == NULL) show_msg = false; } @@ -8192,14 +8202,13 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, "\nDisplayed %ld routes and %ld total paths\n", output_cum, total_cum); } - if (use_json) - vty_out(vty, " } }"); return CMD_SUCCESS; } static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, enum bgp_show_type type, void *output_arg, u_char use_json) { struct bgp_table *table; + unsigned long json_header_depth = 0; if (bgp == NULL) { bgp = bgp_get_default(); @@ -8224,7 +8233,7 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, safi = SAFI_UNICAST; return bgp_show_table(vty, bgp, safi, table, type, output_arg, use_json, - NULL, 1, NULL, NULL); + NULL, 1, NULL, NULL, &json_header_depth); } static void bgp_show_all_instances_routes_vty(struct vty *vty, afi_t afi, From 9611232b4c2ca2d66adc1b6e5b294ea5b8cec714 Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Fri, 9 Feb 2018 10:18:35 -0800 Subject: [PATCH 3/5] also protect ALIAS from indenting Signed-off-by: G. Paul Ziemba --- indent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent.py b/indent.py index a2c18e556df9..560c13c77d14 100644 --- a/indent.py +++ b/indent.py @@ -6,7 +6,7 @@ # find all DEFUNs defun_re = re.compile( - r'^(DEF(UN(_NOSH|_HIDDEN)?|PY)\s*\(.*?)^(?=\s*\{)', + r'^((DEF(UN(_NOSH|_HIDDEN)?|PY)|ALIAS)\s*\(.*?)^(?=\s*\{)', re.M | re.S) define_re = re.compile( r'((^#\s*define[^\n]+[^\\]\n)+)', From a4d82a8adcb8c99625cbf5697c242b42c71f06bb Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Fri, 9 Feb 2018 10:22:50 -0800 Subject: [PATCH 4/5] bgpd: ran indent.py on some files prior to bgp vpn-vrf leaking changes Signed-off-by: G. Paul Ziemba --- bgpd/bgp_debug.c | 4 +- bgpd/bgp_debug.h | 6 +- bgpd/bgp_mplsvpn.c | 6 +- bgpd/bgp_route.c | 497 +++++++++++++++++-------------------- bgpd/bgp_routemap.c | 18 +- bgpd/bgp_vty.c | 176 +++++++------ bgpd/bgp_zebra.c | 55 ++-- bgpd/bgpd.c | 91 +++---- bgpd/bgpd.h | 60 +++-- bgpd/rfapi/bgp_rfapi_cfg.c | 106 ++++---- 10 files changed, 504 insertions(+), 515 deletions(-) diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index b08522b68bd6..e89f399e418d 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -385,8 +385,8 @@ int bgp_dump_attr(struct attr *attr, char *buf, size_t size) if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES))) snprintf(buf + strlen(buf), size - strlen(buf), - ", community %s", community_str(attr->community, - false)); + ", community %s", + community_str(attr->community, false)); if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES))) snprintf(buf + strlen(buf), size - strlen(buf), diff --git a/bgpd/bgp_debug.h b/bgpd/bgp_debug.h index 7c773cfafbf4..765e43f5b433 100644 --- a/bgpd/bgp_debug.h +++ b/bgpd/bgp_debug.h @@ -153,9 +153,9 @@ extern int bgp_debug_zebra(struct prefix *p); extern int bgp_debug_count(void); extern const char *bgp_debug_rdpfxpath2str(afi_t, safi_t, struct prefix_rd *, - union prefixconstptr, - mpls_label_t *, u_int32_t, - int, u_int32_t, char *, int); + union prefixconstptr, mpls_label_t *, + u_int32_t, int, u_int32_t, char *, + int); const char *bgp_notify_admin_message(char *buf, size_t bufsz, u_char *data, size_t datalen); diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 0e2594ba8a5a..ec4989de8fc5 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -366,8 +366,8 @@ int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd, return CMD_WARNING; } table = bgp->rib[afi][SAFI_MPLS_VPN]; - return bgp_show_table_rd(vty, bgp, SAFI_MPLS_VPN, - table, prd, type, output_arg, use_json); + return bgp_show_table_rd(vty, bgp, SAFI_MPLS_VPN, table, prd, type, + output_arg, use_json); } DEFUN (show_bgp_ip_vpn_all_rd, @@ -389,7 +389,7 @@ DEFUN (show_bgp_ip_vpn_all_rd, if (argv_find_and_parse_afi(argv, argc, &idx, &afi)) { if (argv_find(argv, argc, "rd", &idx)) { - ret = str2prefix_rd(argv[idx+1]->arg, &prd); + ret = str2prefix_rd(argv[idx + 1]->arg, &prd); if (!ret) { vty_out(vty, "%% Malformed Route Distinguisher\n"); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index ea2c4aea9768..2a555aae32e1 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -771,7 +771,7 @@ static int bgp_info_cmp(struct bgp *bgp, struct bgp_info *new, /* If one path has a label but the other does not, do not treat * them as equals for multipath */ - if ((new->extra && bgp_is_valid_label(&new->extra->label[0])) + if ((new->extra &&bgp_is_valid_label(&new->extra->label[0])) != (exist->extra && bgp_is_valid_label(&exist->extra->label[0]))) { if (debug) @@ -1286,7 +1286,7 @@ void bgp_attr_add_gshut_community(struct attr *attr) if (old) { merge = community_merge(community_dup(old), gshut); - if (old->refcnt== 0) + if (old->refcnt == 0) community_free(old); new = community_uniq_sort(merge); @@ -1662,7 +1662,8 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_info *ri, } if (bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { - if (peer->sort == BGP_PEER_IBGP || peer->sort == BGP_PEER_CONFED) { + if (peer->sort == BGP_PEER_IBGP + || peer->sort == BGP_PEER_CONFED) { attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); attr->local_pref = BGP_GSHUT_LOCAL_PREF; } else { @@ -1718,8 +1719,8 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_info *ri, subgrp)) subgroup_announce_reset_nhop( (peer_cap_enhe(peer, afi, safi) - ? AF_INET6 - : p->family), + ? AF_INET6 + : p->family), attr); } /* If IPv6/MP and nexthop does not have any override and happens @@ -1966,8 +1967,9 @@ int subgroup_process_announce_selected(struct update_subgroup *subgrp, : NULL); /* First update is deferred until ORF or ROUTE-REFRESH is received */ - if (onlypeer && CHECK_FLAG(onlypeer->af_sflags[afi][safi], - PEER_STATUS_ORF_WAIT_REFRESH)) + if (onlypeer + && CHECK_FLAG(onlypeer->af_sflags[afi][safi], + PEER_STATUS_ORF_WAIT_REFRESH)) return 0; memset(&attr, 0, sizeof(struct attr)); @@ -2043,7 +2045,7 @@ int bgp_zebra_has_route_changed(struct bgp_node *rn, struct bgp_info *selected) struct bgp_process_queue { struct bgp *bgp; - STAILQ_HEAD(, bgp_node)pqueue; + STAILQ_HEAD(, bgp_node) pqueue; #define BGP_PROCESS_QUEUE_EOIU_MARKER (1 << 0) unsigned int flags; unsigned int queued; @@ -2105,7 +2107,8 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, } else bgp_register_for_label(rn, new_select); } - } else if (CHECK_FLAG(rn->flags, BGP_NODE_REGISTERED_FOR_LABEL)) { + } else if (CHECK_FLAG(rn->flags, + BGP_NODE_REGISTERED_FOR_LABEL)) { bgp_unregister_for_label(rn); } } else if (CHECK_FLAG(rn->flags, BGP_NODE_REGISTERED_FOR_LABEL)) { @@ -2226,9 +2229,8 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn, /* advertise/withdraw type-5 routes */ if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { if (new_select) - bgp_evpn_advertise_type5_route(bgp, &rn->p, - new_select->attr, - afi, safi); + bgp_evpn_advertise_type5_route( + bgp, &rn->p, new_select->attr, afi, safi); else if (old_select) bgp_evpn_withdraw_type5_route(bgp, &rn->p, afi, safi); } @@ -2307,7 +2309,8 @@ static struct bgp_process_queue *bgp_processq_alloc(struct bgp *bgp) { struct bgp_process_queue *pqnode; - pqnode = XCALLOC(MTYPE_BGP_PROCESS_QUEUE, sizeof(struct bgp_process_queue)); + pqnode = XCALLOC(MTYPE_BGP_PROCESS_QUEUE, + sizeof(struct bgp_process_queue)); /* unlocked in bgp_processq_del */ pqnode->bgp = bgp_lock(bgp); @@ -2331,13 +2334,15 @@ void bgp_process(struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi) return; /* Add route nodes to an existing work queue item until reaching the - limit only if is from the same BGP view and it's not an EOIU marker */ + limit only if is from the same BGP view and it's not an EOIU marker + */ if (work_queue_item_count(wq)) { struct work_queue_item *item = work_queue_last_item(wq); pqnode = item->data; - if (CHECK_FLAG(pqnode->flags, BGP_PROCESS_QUEUE_EOIU_MARKER) || - pqnode->bgp != bgp || pqnode->queued >= ARBITRARY_PROCESS_QLEN) + if (CHECK_FLAG(pqnode->flags, BGP_PROCESS_QUEUE_EOIU_MARKER) + || pqnode->bgp != bgp + || pqnode->queued >= ARBITRARY_PROCESS_QLEN) pqnode = bgp_processq_alloc(bgp); else pqnode_reuse = 1; @@ -2673,9 +2678,9 @@ static int bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi, int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, struct attr *attr, afi_t afi, safi_t safi, int type, - int sub_type, struct prefix_rd *prd, - mpls_label_t *label, u_int32_t num_labels, - int soft_reconfig, struct bgp_route_evpn *evpn) + int sub_type, struct prefix_rd *prd, mpls_label_t *label, + u_int32_t num_labels, int soft_reconfig, + struct bgp_route_evpn *evpn) { int ret; int aspath_loop_count = 0; @@ -2726,7 +2731,8 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, if (peer->change_local_as) { if (peer->allowas_in[afi][safi]) aspath_loop_count = peer->allowas_in[afi][safi]; - else if (!CHECK_FLAG(peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND)) + else if (!CHECK_FLAG(peer->flags, + PEER_FLAG_LOCAL_AS_NO_PREPEND)) aspath_loop_count = 1; if (aspath_loop_check(attr->aspath, peer->change_local_as) @@ -2792,23 +2798,24 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, if (peer->sort == BGP_PEER_EBGP) { - /* If we receive the graceful-shutdown community from an eBGP peer we - * must lower local-preference */ - if (new_attr.community && - community_include(new_attr.community, COMMUNITY_GSHUT)) { + /* If we receive the graceful-shutdown community from an eBGP + * peer we must lower local-preference */ + if (new_attr.community + && community_include(new_attr.community, COMMUNITY_GSHUT)) { new_attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); new_attr.local_pref = BGP_GSHUT_LOCAL_PREF; - /* If graceful-shutdown is configured then add the GSHUT community to - * all paths received from eBGP peers */ - } else if (bgp_flag_check(peer->bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)) { + /* If graceful-shutdown is configured then add the GSHUT + * community to all paths received from eBGP peers */ + } else if (bgp_flag_check(peer->bgp, + BGP_FLAG_GRACEFUL_SHUTDOWN)) { bgp_attr_add_gshut_community(&new_attr); } } /* next hop check. */ - if (!CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD) && - bgp_update_martian_nexthop(bgp, afi, safi, &new_attr)) { + if (!CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD) + && bgp_update_martian_nexthop(bgp, afi, safi, &new_attr)) { reason = "martian or self next-hop;"; bgp_attr_flush(&new_attr); goto filtered; @@ -2837,10 +2844,10 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, && CHECK_FLAG(ri->flags, BGP_INFO_HISTORY)) { if (bgp_debug_update(peer, p, NULL, 1)) { bgp_debug_rdpfxpath2str( - afi, safi, prd, p, - label, num_labels, - addpath_id ? 1 : 0, addpath_id, - pfx_buf, sizeof(pfx_buf)); + afi, safi, prd, p, label, + num_labels, addpath_id ? 1 : 0, + addpath_id, pfx_buf, + sizeof(pfx_buf)); zlog_debug("%s rcvd %s", peer->host, pfx_buf); } @@ -2863,10 +2870,10 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, } bgp_debug_rdpfxpath2str( - afi, safi, prd, p, - label, num_labels, - addpath_id ? 1 : 0, addpath_id, - pfx_buf, sizeof(pfx_buf)); + afi, safi, prd, p, label, + num_labels, addpath_id ? 1 : 0, + addpath_id, pfx_buf, + sizeof(pfx_buf)); zlog_debug( "%s rcvd %s...duplicate ignored", peer->host, pfx_buf); @@ -2890,8 +2897,7 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, if (CHECK_FLAG(ri->flags, BGP_INFO_REMOVED)) { if (bgp_debug_update(peer, p, NULL, 1)) { bgp_debug_rdpfxpath2str( - afi, safi, prd, p, - label, num_labels, + afi, safi, prd, p, label, num_labels, addpath_id ? 1 : 0, addpath_id, pfx_buf, sizeof(pfx_buf)); zlog_debug( @@ -2904,10 +2910,10 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, /* Received Logging. */ if (bgp_debug_update(peer, p, NULL, 1)) { - bgp_debug_rdpfxpath2str(afi, safi, prd, p, - label, num_labels, - addpath_id ? 1 : 0, addpath_id, - pfx_buf, sizeof(pfx_buf)); + bgp_debug_rdpfxpath2str(afi, safi, prd, p, label, + num_labels, addpath_id ? 1 : 0, + addpath_id, pfx_buf, + sizeof(pfx_buf)); zlog_debug("%s rcvd %s", peer->host, pfx_buf); } @@ -3058,8 +3064,8 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, connected = 0; if (bgp_find_or_add_nexthop(bgp, afi, ri, NULL, - connected) || - CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD)) + connected) + || CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD)) bgp_info_set_flag(rn, ri, BGP_INFO_VALID); else { if (BGP_DEBUG(nht, NHT)) { @@ -3138,8 +3144,7 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, peer->rcvd_attr_printed = 1; } - bgp_debug_rdpfxpath2str(afi, safi, prd, p, - label, num_labels, + bgp_debug_rdpfxpath2str(afi, safi, prd, p, label, num_labels, addpath_id ? 1 : 0, addpath_id, pfx_buf, sizeof(pfx_buf)); zlog_debug("%s rcvd %s", peer->host, pfx_buf); @@ -3151,8 +3156,7 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, /* Update MPLS label */ if (has_valid_label) { extra = bgp_info_extra_get(new); - memcpy(&extra->label, label, - num_labels * sizeof(mpls_label_t)); + memcpy(&extra->label, label, num_labels * sizeof(mpls_label_t)); extra->num_labels = num_labels; if (!(afi == AFI_L2VPN && safi == SAFI_EVPN)) bgp_set_valid_label(&extra->label[0]); @@ -3175,8 +3179,8 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, else connected = 0; - if (bgp_find_or_add_nexthop(bgp, afi, new, NULL, connected) || - CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD)) + if (bgp_find_or_add_nexthop(bgp, afi, new, NULL, connected) + || CHECK_FLAG(peer->flags, PEER_FLAG_IS_RFAPI_HD)) bgp_info_set_flag(rn, new, BGP_INFO_VALID); else { if (BGP_DEBUG(nht, NHT)) { @@ -3257,8 +3261,7 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, peer->rcvd_attr_printed = 1; } - bgp_debug_rdpfxpath2str(afi, safi, prd, p, - label, num_labels, + bgp_debug_rdpfxpath2str(afi, safi, prd, p, label, num_labels, addpath_id ? 1 : 0, addpath_id, pfx_buf, sizeof(pfx_buf)); zlog_debug("%s rcvd UPDATE about %s -- DENIED due to: %s", @@ -3293,9 +3296,8 @@ int bgp_update(struct peer *peer, struct prefix *p, u_int32_t addpath_id, int bgp_withdraw(struct peer *peer, struct prefix *p, u_int32_t addpath_id, struct attr *attr, afi_t afi, safi_t safi, int type, - int sub_type, struct prefix_rd *prd, - mpls_label_t *label, u_int32_t num_labels, - struct bgp_route_evpn *evpn) + int sub_type, struct prefix_rd *prd, mpls_label_t *label, + u_int32_t num_labels, struct bgp_route_evpn *evpn) { struct bgp *bgp; char pfx_buf[BGP_PRD_PATH_STRLEN]; @@ -3330,8 +3332,7 @@ int bgp_withdraw(struct peer *peer, struct prefix *p, u_int32_t addpath_id, if (!bgp_adj_in_unset(rn, peer, addpath_id)) { if (bgp_debug_update(peer, p, NULL, 1)) { bgp_debug_rdpfxpath2str( - afi, safi, prd, p, - label, num_labels, + afi, safi, prd, p, label, num_labels, addpath_id ? 1 : 0, addpath_id, pfx_buf, sizeof(pfx_buf)); zlog_debug( @@ -3351,8 +3352,7 @@ int bgp_withdraw(struct peer *peer, struct prefix *p, u_int32_t addpath_id, /* Logging. */ if (bgp_debug_update(peer, p, NULL, 1)) { - bgp_debug_rdpfxpath2str(afi, safi, prd, p, - label, num_labels, + bgp_debug_rdpfxpath2str(afi, safi, prd, p, label, num_labels, addpath_id ? 1 : 0, addpath_id, pfx_buf, sizeof(pfx_buf)); zlog_debug("%s rcvd UPDATE about %s -- withdrawn", peer->host, @@ -3363,8 +3363,7 @@ int bgp_withdraw(struct peer *peer, struct prefix *p, u_int32_t addpath_id, if (ri && !CHECK_FLAG(ri->flags, BGP_INFO_HISTORY)) bgp_rib_withdraw(rn, ri, peer, afi, safi, prd); else if (bgp_debug_update(peer, p, NULL, 1)) { - bgp_debug_rdpfxpath2str(afi, safi, prd, p, - label, num_labels, + bgp_debug_rdpfxpath2str(afi, safi, prd, p, label, num_labels, addpath_id ? 1 : 0, addpath_id, pfx_buf, sizeof(pfx_buf)); zlog_debug("%s Can't find the route %s", peer->host, pfx_buf); @@ -3500,8 +3499,8 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi, ret = bgp_update(peer, &rn->p, ain->addpath_rx_id, ain->attr, afi, safi, ZEBRA_ROUTE_BGP, - BGP_ROUTE_NORMAL, prd, - label_pnt, num_labels, 1, NULL); + BGP_ROUTE_NORMAL, prd, label_pnt, + num_labels, 1, NULL); if (ret < 0) { bgp_unlock_node(rn); @@ -4016,7 +4015,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, * an error SHOULD * be logged locally, and the prefix SHOULD be * ignored. - */ + */ zlog_err( "%s: IPv4 unicast NLRI is multicast address %s, ignoring", peer->host, inet_ntoa(p.u.prefix4)); @@ -4058,8 +4057,8 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr, else ret = bgp_withdraw(peer, &p, addpath_id, attr, afi, safi, ZEBRA_ROUTE_BGP, - BGP_ROUTE_NORMAL, NULL, - NULL, 0, NULL); + BGP_ROUTE_NORMAL, NULL, NULL, 0, + NULL); /* Address family configuration mismatch or maximum-prefix count overflow. */ @@ -4555,8 +4554,7 @@ static int bgp_static_set(struct vty *vty, const char *negate, rn = bgp_node_lookup(bgp->route[afi][safi], &p); if (!rn) { - vty_out(vty, - "%% Can't find static route specified\n"); + vty_out(vty, "%% Can't find static route specified\n"); return CMD_WARNING_CONFIG_FAILED; } @@ -4601,8 +4599,8 @@ static int bgp_static_set(struct vty *vty, const char *negate, } /* Check previous routes are installed into BGP. */ - if (bgp_static->valid && - bgp_static->backdoor != backdoor) + if (bgp_static->valid + && bgp_static->backdoor != backdoor) need_update = 1; bgp_static->backdoor = backdoor; @@ -4610,7 +4608,7 @@ static int bgp_static_set(struct vty *vty, const char *negate, if (rmap) { if (bgp_static->rmap.name) XFREE(MTYPE_ROUTE_MAP_NAME, - bgp_static->rmap.name); + bgp_static->rmap.name); bgp_static->rmap.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap); bgp_static->rmap.map = @@ -4618,7 +4616,7 @@ static int bgp_static_set(struct vty *vty, const char *negate, } else { if (bgp_static->rmap.name) XFREE(MTYPE_ROUTE_MAP_NAME, - bgp_static->rmap.name); + bgp_static->rmap.name); bgp_static->rmap.name = NULL; bgp_static->rmap.map = NULL; bgp_static->valid = 0; @@ -4636,7 +4634,7 @@ static int bgp_static_set(struct vty *vty, const char *negate, if (rmap) { if (bgp_static->rmap.name) XFREE(MTYPE_ROUTE_MAP_NAME, - bgp_static->rmap.name); + bgp_static->rmap.name); bgp_static->rmap.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap); bgp_static->rmap.map = @@ -5109,11 +5107,10 @@ DEFPY(bgp_network, } } - return bgp_static_set(vty, no, address_str ? addr_prefix_str:prefix_str, - AFI_IP, bgp_node_safi(vty), - map_name, backdoor?1:0, - label_index ? - (uint32_t)label_index : BGP_INVALID_LABEL_INDEX); + return bgp_static_set( + vty, no, address_str ? addr_prefix_str : prefix_str, AFI_IP, + bgp_node_safi(vty), map_name, backdoor ? 1 : 0, + label_index ? (uint32_t)label_index : BGP_INVALID_LABEL_INDEX); } DEFPY(ipv6_bgp_network, @@ -5128,10 +5125,9 @@ DEFPY(ipv6_bgp_network, "Label index to associate with the prefix\n" "Label index value\n") { - return bgp_static_set(vty, no, prefix_str, AFI_IP6, - bgp_node_safi(vty), map_name, 0, - label_index ? - (uint32_t)label_index : BGP_INVALID_LABEL_INDEX); + return bgp_static_set( + vty, no, prefix_str, AFI_IP6, bgp_node_safi(vty), map_name, 0, + label_index ? (uint32_t)label_index : BGP_INVALID_LABEL_INDEX); } /* Aggreagete address: @@ -5856,8 +5852,7 @@ DEFUN (no_ipv6_aggregate_address, void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, const union g_addr *nexthop, ifindex_t ifindex, enum nexthop_types_t nhtype, uint32_t metric, - u_char type, u_short instance, - route_tag_t tag) + u_char type, u_short instance, route_tag_t tag) { struct bgp_info *new; struct bgp_info *bi; @@ -5872,7 +5867,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, /* Make default attribute. */ bgp_attr_default_set(&attr, BGP_ORIGIN_INCOMPLETE); - switch(nhtype) { + switch (nhtype) { case NEXTHOP_TYPE_IFINDEX: break; case NEXTHOP_TYPE_IPV4: @@ -6253,13 +6248,13 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, switch (af) { case AF_INET: sprintf(nexthop, "%s", - inet_ntop(af, &attr->mp_nexthop_global_in, - buf, BUFSIZ)); + inet_ntop(af, &attr->mp_nexthop_global_in, buf, + BUFSIZ)); break; case AF_INET6: sprintf(nexthop, "%s", - inet_ntop(af, &attr->mp_nexthop_global, - buf, BUFSIZ)); + inet_ntop(af, &attr->mp_nexthop_global, buf, + BUFSIZ)); break; default: sprintf(nexthop, "?"); @@ -6269,13 +6264,10 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, if (json_paths) { json_nexthop_global = json_object_new_object(); + json_object_string_add(json_nexthop_global, "afi", + (af == AF_INET) ? "ip" : "ipv6"); json_object_string_add(json_nexthop_global, - "afi", - (af == AF_INET) ? - "ip" : "ipv6"); - json_object_string_add(json_nexthop_global, - (af == AF_INET) ? - "ip" : "ipv6", + (af == AF_INET) ? "ip" : "ipv6", nexthop); json_object_boolean_true_add(json_nexthop_global, "used"); @@ -6287,92 +6279,80 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, json_object_string_add(json_nexthop_global, "ip", inet_ntoa(attr->nexthop)); - json_object_string_add(json_nexthop_global, - "afi", "ipv4"); + json_object_string_add(json_nexthop_global, "afi", + "ipv4"); json_object_boolean_true_add(json_nexthop_global, "used"); } else vty_out(vty, "%-16s", inet_ntoa(attr->nexthop)); } /* IPv4 Next Hop */ - else if (p->family == AF_INET - && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) { + else if (p->family == AF_INET && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) { if (json_paths) { json_nexthop_global = json_object_new_object(); - if ((safi == SAFI_MPLS_VPN) - || (safi == SAFI_EVPN)) - json_object_string_add(json_nexthop_global, - "ip", - inet_ntoa(attr->mp_nexthop_global_in)); + if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN)) + json_object_string_add( + json_nexthop_global, "ip", + inet_ntoa(attr->mp_nexthop_global_in)); else - json_object_string_add(json_nexthop_global, - "ip", - inet_ntoa(attr->nexthop)); + json_object_string_add( + json_nexthop_global, "ip", + inet_ntoa(attr->nexthop)); - json_object_string_add(json_nexthop_global, - "afi", "ipv4"); + json_object_string_add(json_nexthop_global, "afi", + "ipv4"); json_object_boolean_true_add(json_nexthop_global, "used"); } else { - if ((safi == SAFI_MPLS_VPN) - || (safi == SAFI_EVPN)) + if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN)) vty_out(vty, "%-16s", - inet_ntoa( - attr->mp_nexthop_global_in)); + inet_ntoa(attr->mp_nexthop_global_in)); else - vty_out(vty, "%-16s", - inet_ntoa(attr->nexthop)); + vty_out(vty, "%-16s", inet_ntoa(attr->nexthop)); } } /* IPv6 Next Hop */ - else if (p->family == AF_INET6 - || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) { + else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) { int len; char buf[BUFSIZ]; if (json_paths) { json_nexthop_global = json_object_new_object(); - json_object_string_add(json_nexthop_global, "ip", - inet_ntop(AF_INET6, - &attr->mp_nexthop_global, buf, - BUFSIZ)); - json_object_string_add(json_nexthop_global, - "afi", "ipv6"); - json_object_string_add(json_nexthop_global, - "scope", "global"); + json_object_string_add( + json_nexthop_global, "ip", + inet_ntop(AF_INET6, &attr->mp_nexthop_global, + buf, BUFSIZ)); + json_object_string_add(json_nexthop_global, "afi", + "ipv6"); + json_object_string_add(json_nexthop_global, "scope", + "global"); /* We display both LL & GL if both have been * received */ if ((attr->mp_nexthop_len == 32) || (binfo->peer->conf_if)) { - json_nexthop_ll = - json_object_new_object(); + json_nexthop_ll = json_object_new_object(); json_object_string_add( json_nexthop_ll, "ip", - inet_ntop( - AF_INET6, - &attr->mp_nexthop_local, - buf, BUFSIZ)); - json_object_string_add(json_nexthop_ll, - "afi", "ipv6"); - json_object_string_add(json_nexthop_ll, - "scope", + inet_ntop(AF_INET6, + &attr->mp_nexthop_local, buf, + BUFSIZ)); + json_object_string_add(json_nexthop_ll, "afi", + "ipv6"); + json_object_string_add(json_nexthop_ll, "scope", "link-local"); - if ((IPV6_ADDR_CMP( - &attr->mp_nexthop_global, - &attr->mp_nexthop_local) + if ((IPV6_ADDR_CMP(&attr->mp_nexthop_global, + &attr->mp_nexthop_local) != 0) && !attr->mp_nexthop_prefer_global) json_object_boolean_true_add( - json_nexthop_ll, - "used"); + json_nexthop_ll, "used"); else json_object_boolean_true_add( - json_nexthop_global, - "used"); + json_nexthop_global, "used"); } else json_object_boolean_true_add( json_nexthop_global, "used"); @@ -6383,20 +6363,17 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, && !attr->mp_nexthop_prefer_global) || (binfo->peer->conf_if)) { if (binfo->peer->conf_if) { - len = vty_out( - vty, "%s", - binfo->peer->conf_if); + len = vty_out(vty, "%s", + binfo->peer->conf_if); len = 16 - len; /* len of IPv6 addr + max len of def ifname */ if (len < 1) - vty_out(vty, "\n%*s", - 36, " "); + vty_out(vty, "\n%*s", 36, " "); else - vty_out(vty, "%*s", len, - " "); + vty_out(vty, "%*s", len, " "); } else { len = vty_out( vty, "%s", @@ -6407,17 +6384,16 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, len = 16 - len; if (len < 1) - vty_out(vty, "\n%*s", - 36, " "); + vty_out(vty, "\n%*s", 36, " "); else - vty_out(vty, "%*s", len, - " "); + vty_out(vty, "%*s", len, " "); } } else { - len = vty_out(vty, "%s", - inet_ntop(AF_INET6, - &attr->mp_nexthop_global, - buf, BUFSIZ)); + len = vty_out( + vty, "%s", + inet_ntop(AF_INET6, + &attr->mp_nexthop_global, buf, + BUFSIZ)); len = 16 - len; if (len < 1) @@ -6431,8 +6407,7 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, /* MED/Metric */ if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) if (json_paths) - json_object_int_add(json_path, "med", - attr->med); + json_object_int_add(json_path, "med", attr->med); else vty_out(vty, "%10u", attr->med); else if (!json_paths) @@ -6455,10 +6430,9 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, if (json_paths) { char buf[BUFSIZ]; - json_object_string_add(json_path, "peerId", - sockunion2str(&binfo->peer->su, - buf, - SU_ADDRSTRLEN)); + json_object_string_add( + json_path, "peerId", + sockunion2str(&binfo->peer->su, buf, SU_ADDRSTRLEN)); } /* Print aspath */ @@ -6472,9 +6446,8 @@ void route_vty_out(struct vty *vty, struct prefix *p, struct bgp_info *binfo, /* Print origin */ if (json_paths) - json_object_string_add( - json_path, "origin", - bgp_origin_long_str[attr->origin]); + json_object_string_add(json_path, "origin", + bgp_origin_long_str[attr->origin]); else vty_out(vty, "%s", bgp_origin_str[attr->origin]); @@ -6672,8 +6645,7 @@ void route_vty_out_tag(struct vty *vty, struct prefix *p, if (attr) { if (((p->family == AF_INET) && ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP))) - || (safi == SAFI_EVPN - && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) + || (safi == SAFI_EVPN && !BGP_ATTR_NEXTHOP_AFI_IP6(attr)) || (!BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN) { @@ -6867,9 +6839,10 @@ static void damp_route_vty_out(struct vty *vty, struct prefix *p, bgp_damp_reuse_time_vty(vty, binfo, timebuf, BGP_UPTIME_LEN, use_json, json); else - vty_out(vty, "%s ", bgp_damp_reuse_time_vty(vty, binfo, timebuf, - BGP_UPTIME_LEN, - use_json, json)); + vty_out(vty, "%s ", + bgp_damp_reuse_time_vty(vty, binfo, timebuf, + BGP_UPTIME_LEN, use_json, + json)); /* Print attribute */ attr = binfo->attr; @@ -6948,8 +6921,9 @@ static void flap_route_vty_out(struct vty *vty, struct prefix *p, peer_uptime(bdi->start_time, timebuf, BGP_UPTIME_LEN, use_json, json); else - vty_out(vty, "%s ", peer_uptime(bdi->start_time, timebuf, - BGP_UPTIME_LEN, 0, NULL)); + vty_out(vty, "%s ", + peer_uptime(bdi->start_time, timebuf, BGP_UPTIME_LEN, 0, + NULL)); if (CHECK_FLAG(binfo->flags, BGP_INFO_DAMPED) && !CHECK_FLAG(binfo->flags, BGP_INFO_HISTORY)) { @@ -7090,8 +7064,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p, tag_buf[0] = '\0'; if (binfo->extra && binfo->extra->num_labels) { bgp_evpn_label2str(binfo->extra->label, - binfo->extra->num_labels, - tag_buf, sizeof(tag_buf)); + binfo->extra->num_labels, tag_buf, + sizeof(tag_buf)); vty_out(vty, " VNI %s", tag_buf); } vty_out(vty, "\n"); @@ -7201,8 +7175,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p, /* Line2 display Next-hop, Neighbor, Router-id */ /* Display the nexthop */ - if ((p->family == AF_INET || p->family == AF_ETHERNET || - p->family == AF_EVPN) + if ((p->family == AF_INET || p->family == AF_ETHERNET + || p->family == AF_EVPN) && (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { @@ -7610,8 +7584,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p, if (attr->community) { if (json_paths) { if (!attr->community->json) - community_str(attr->community, - true); + community_str(attr->community, true); json_object_lock(attr->community->json); json_object_object_add(json_path, "community", attr->community->json); @@ -7731,8 +7704,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct prefix *p, if (binfo->extra && bgp_is_valid_label(&binfo->extra->label[0])) #endif { - mpls_label_t label = label_pton( - &binfo->extra->label[0]); + mpls_label_t label = + label_pton(&binfo->extra->label[0]); if (json_paths) json_object_int_add(json_path, "remoteLabel", label); @@ -7860,9 +7833,8 @@ static int bgp_show_community_list(struct vty *vty, struct bgp *bgp, static int bgp_show_prefix_longer(struct vty *vty, struct bgp *bgp, const char *prefix, afi_t afi, safi_t safi, enum bgp_show_type type); -static int bgp_show_regexp(struct vty *vty, struct bgp *bgp, - const char *regstr, afi_t afi, - safi_t safi, enum bgp_show_type type); +static int bgp_show_regexp(struct vty *vty, struct bgp *bgp, const char *regstr, + afi_t afi, safi_t safi, enum bgp_show_type type); static int bgp_show_community(struct vty *vty, struct bgp *bgp, const char *comstr, int exact, afi_t afi, safi_t safi); @@ -7870,9 +7842,9 @@ static int bgp_show_community(struct vty *vty, struct bgp *bgp, static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, struct bgp_table *table, enum bgp_show_type type, - void *output_arg, u_char use_json, - char *rd, int is_last, - unsigned long *output_cum, unsigned long *total_cum, + void *output_arg, u_char use_json, char *rd, + int is_last, unsigned long *output_cum, + unsigned long *total_cum, unsigned long *json_header_depth) { struct bgp_info *ri; @@ -7927,8 +7899,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, || type == bgp_show_type_flap_neighbor || type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) { - if (!(ri->extra - && ri->extra->damp_info)) + if (!(ri->extra && ri->extra->damp_info)) continue; } if (type == bgp_show_type_regexp) { @@ -7963,8 +7934,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, binfo.peer = ri->peer; binfo.attr = &dummy_attr; - ret = route_map_apply(rmap, &rn->p, - RMAP_BGP, &binfo); + ret = route_map_apply(rmap, &rn->p, RMAP_BGP, + &binfo); if (ret == RMAP_DENYMATCH) continue; } @@ -7975,8 +7946,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, if (ri->peer == NULL || ri->peer->su_remote == NULL - || !sockunion_same(ri->peer->su_remote, - su)) + || !sockunion_same(ri->peer->su_remote, su)) continue; } if (type == bgp_show_type_cidr_only) { @@ -8015,19 +7985,17 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, struct community *com = output_arg; if (!ri->attr->community - || !community_cmp(ri->attr->community, - com)) + || !community_cmp(ri->attr->community, com)) continue; } if (type == bgp_show_type_community_list) { struct community_list *list = output_arg; - if (!community_list_match( - ri->attr->community, list)) + if (!community_list_match(ri->attr->community, + list)) continue; } - if (type - == bgp_show_type_community_list_exact) { + if (type == bgp_show_type_community_list_exact) { struct community_list *list = output_arg; if (!community_list_exact_match( @@ -8045,8 +8013,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, if (type == bgp_show_type_lcommunity_list) { struct community_list *list = output_arg; - if (!lcommunity_list_match( - ri->attr->lcommunity, list)) + if (!lcommunity_list_match(ri->attr->lcommunity, + list)) continue; } if (type == bgp_show_type_lcommunity_all) { @@ -8071,9 +8039,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, if (type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) vty_out(vty, BGP_SHOW_DAMP_HEADER); - else if ( - type == bgp_show_type_flap_statistics - || type == bgp_show_type_flap_neighbor) + else if (type == bgp_show_type_flap_statistics + || type == bgp_show_type_flap_neighbor) vty_out(vty, BGP_SHOW_FLAP_HEADER); else vty_out(vty, BGP_SHOW_HEADER); @@ -8088,16 +8055,14 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, if (type == bgp_show_type_dampend_paths || type == bgp_show_type_damp_neighbor) damp_route_vty_out(vty, &rn->p, ri, display, - safi, use_json, - json_paths); + safi, use_json, json_paths); else if (type == bgp_show_type_flap_statistics || type == bgp_show_type_flap_neighbor) flap_route_vty_out(vty, &rn->p, ri, display, - safi, use_json, - json_paths); + safi, use_json, json_paths); else - route_vty_out(vty, &rn->p, ri, display, - safi, json_paths); + route_vty_out(vty, &rn->p, ri, display, safi, + json_paths); display++; } @@ -8108,8 +8073,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, p = &rn->p; sprintf(buf2, "%s/%d", - inet_ntop(p->family, &p->u.prefix, - buf, BUFSIZ), + inet_ntop(p->family, &p->u.prefix, buf, BUFSIZ), p->prefixlen); if (first) vty_out(vty, "\"%s\": ", buf2); @@ -8136,12 +8100,12 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, if (json_paths) json_object_free(json_paths); if (rd) { - vty_out(vty, " }%s ", (is_last? "": ",")); + vty_out(vty, " }%s ", (is_last ? "" : ",")); } if (is_last) { - unsigned long i; - for (i = 0; i < *json_header_depth; ++i) - vty_out(vty, " } "); + unsigned long i; + for (i = 0; i < *json_header_depth; ++i) + vty_out(vty, " } "); } } else { if (is_last) { @@ -8185,8 +8149,7 @@ int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, safi_t safi, memcpy(&prd, &(rn->p), sizeof(struct prefix_rd)); prefix_rd2str(&prd, rd, sizeof(rd)); bgp_show_table(vty, bgp, safi, rn->info, type, - output_arg, use_json, - rd, next == NULL, + output_arg, use_json, rd, next == NULL, &output_cum, &total_cum, &json_header_depth); if (next == NULL) @@ -8338,8 +8301,8 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp, vty_out(vty, "BGP routing table entry for %s%s%s/%d\n", ((safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN) - ? prefix_rd2str(prd, buf1, sizeof(buf1)) - : ""), + ? prefix_rd2str(prd, buf1, sizeof(buf1)) + : ""), ((safi == SAFI_MPLS_VPN) || (safi == SAFI_EVPN)) ? ":" : "", buf2, p->prefixlen); @@ -8550,8 +8513,9 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp, if (display) json_object_object_add(json, "paths", json_paths); - vty_out(vty, "%s\n", json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { if (!display) { @@ -8818,14 +8782,17 @@ DEFUN (show_ip_bgp, if (argv_find(argv, argc, "community", &idx)) { /* show a specific community */ if (argv_find(argv, argc, "local-AS", &idx_community_type) - || argv_find(argv, argc, "no-advertise", &idx_community_type) + || argv_find(argv, argc, "no-advertise", + &idx_community_type) || argv_find(argv, argc, "no-export", &idx_community_type) - || argv_find(argv, argc, "graceful-shutdown", &idx_community_type) + || argv_find(argv, argc, "graceful-shutdown", + &idx_community_type) || argv_find(argv, argc, "AA:NN", &idx_community_type)) { if (argv_find(argv, argc, "exact-match", &idx)) exact_match = 1; - return bgp_show_community(vty, bgp, argv[idx_community_type]->arg, + return bgp_show_community(vty, bgp, + argv[idx_community_type]->arg, exact_match, afi, safi); } } @@ -9043,9 +9010,8 @@ DEFUN (show_ip_bgp_instance_all, return CMD_SUCCESS; } -static int bgp_show_regexp(struct vty *vty, struct bgp *bgp, - const char *regstr, afi_t afi, - safi_t safi, enum bgp_show_type type) +static int bgp_show_regexp(struct vty *vty, struct bgp *bgp, const char *regstr, + afi_t afi, safi_t safi, enum bgp_show_type type) { regex_t *regex; int rc; @@ -9192,7 +9158,8 @@ static struct peer *peer_lookup_in_view(struct vty *vty, struct bgp *bgp, ip_str); vty_out(vty, "%s\n", json_object_to_json_string_ext( - json_no, JSON_C_TO_STRING_PRETTY)); + json_no, + JSON_C_TO_STRING_PRETTY)); json_object_free(json_no); } else vty_out(vty, @@ -9213,8 +9180,8 @@ static struct peer *peer_lookup_in_view(struct vty *vty, struct bgp *bgp, json_object_string_add(json_no, "warning", "No such neighbor"); vty_out(vty, "%s\n", - json_object_to_json_string_ext(json_no, - JSON_C_TO_STRING_PRETTY)); + 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"); @@ -9332,8 +9299,8 @@ static int bgp_table_stats_walker(struct thread *t) ts->counts[BGP_STATS_UNAGGREGATEABLE]++; /* announced address space */ if (space) - ts->total_space += pow(2.0, - space - rn->p.prefixlen); + ts->total_space += + pow(2.0, space - rn->p.prefixlen); } else if (prn->info) ts->counts[BGP_STATS_MAX_AGGREGATEABLE]++; @@ -9448,20 +9415,20 @@ static int bgp_table_stats(struct vty *vty, struct bgp *bgp, afi_t afi, if (afi == AFI_IP6) { vty_out(vty, "%30s: ", "/32 equivalent "); vty_out(vty, "%12g\n", - ts.total_space * pow(2.0, -128+32)); + ts.total_space * pow(2.0, -128 + 32)); vty_out(vty, "%30s: ", "/48 equivalent "); vty_out(vty, "%12g\n", - ts.total_space * pow(2.0, -128+48)); + ts.total_space * pow(2.0, -128 + 48)); } else { vty_out(vty, "%30s: ", "% announced "); vty_out(vty, "%12.2f\n", ts.total_space * 100. * pow(2.0, -32)); vty_out(vty, "%30s: ", "/8 equivalent "); vty_out(vty, "%12.2f\n", - ts.total_space * pow(2.0, -32+8)); + ts.total_space * pow(2.0, -32 + 8)); vty_out(vty, "%30s: ", "/24 equivalent "); vty_out(vty, "%12.2f\n", - ts.total_space * pow(2.0, -32+24)); + ts.total_space * pow(2.0, -32 + 24)); } break; default: @@ -9598,9 +9565,9 @@ static int bgp_peer_counts(struct vty *vty, struct peer *peer, afi_t afi, pcounts.table = peer->bgp->rib[afi][safi]; /* in-place call via thread subsystem so as to record execution time - * * stats for the thread-walk (i.e. ensure this can't be blamed on - * * on just vty_read()). - * */ + * * stats for the thread-walk (i.e. ensure this can't be blamed on + * * on just vty_read()). + * */ thread_execute(bm->master, bgp_peer_count_walker, &pcounts, 0); if (use_json) { @@ -9623,8 +9590,9 @@ static int bgp_peer_counts(struct vty *vty, struct peer *peer, afi_t afi, json, "recommended", "Please report this bug, with the above command output"); } - vty_out(vty, "%s\n", json_object_to_json_string_ext(json, - JSON_C_TO_STRING_PRETTY)); + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { @@ -9858,8 +9826,9 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi, "bgpOriginatingDefaultNetwork", "0.0.0.0"); } else { - vty_out(vty, "BGP table version is %" PRIu64 - ", local router ID is %s\n", + vty_out(vty, + "BGP table version is %" PRIu64 + ", local router ID is %s\n", table->version, inet_ntoa(bgp->router_id)); vty_out(vty, BGP_SHOW_SCODE_HEADER); vty_out(vty, BGP_SHOW_OCODE_HEADER); @@ -9970,19 +9939,14 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi, } if (adj->attr) { - bgp_attr_dup(&attr, - adj->attr); + bgp_attr_dup(&attr, adj->attr); ret = bgp_output_modifier( - peer, &rn->p, - &attr, afi, - safi, - rmap_name); + peer, &rn->p, &attr, + afi, safi, rmap_name); if (ret != RMAP_DENY) { route_vty_out_tmp( - vty, - &rn->p, - &attr, - safi, + vty, &rn->p, + &attr, safi, use_json, json_ar); output_count++; @@ -10007,8 +9971,9 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi, output_count); } if (use_json) { - vty_out(vty, "%s\n", json_object_to_json_string_ext(json, - JSON_C_TO_STRING_PRETTY)); + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } } @@ -10945,18 +10910,20 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp, prefix_rd2str(prd, rdbuf, sizeof(rdbuf)); if (p->u.prefix_evpn.route_type == 5) { char local_buf[PREFIX_STRLEN]; - uint8_t family = IS_EVPN_PREFIX_IPADDR_V4((struct prefix_evpn *)p) - ? AF_INET - : AF_INET6; - inet_ntop(family, &p->u.prefix_evpn.ip.ip.addr, local_buf, - PREFIX_STRLEN); - sprintf(buf, "%s/%u", local_buf,p->u.prefix_evpn.ip_prefix_length); + uint8_t family = IS_EVPN_PREFIX_IPADDR_V4(( + struct prefix_evpn *)p) + ? AF_INET + : AF_INET6; + inet_ntop(family, &p->u.prefix_evpn.ip.ip.addr, + local_buf, PREFIX_STRLEN); + sprintf(buf, "%s/%u", local_buf, + p->u.prefix_evpn.ip_prefix_length); } else { prefix2str(p, buf, sizeof(buf)); } - if (bgp_static->gatewayIp.family == AF_INET || - bgp_static->gatewayIp.family == AF_INET6) + if (bgp_static->gatewayIp.family == AF_INET + || bgp_static->gatewayIp.family == AF_INET6) inet_ntop(bgp_static->gatewayIp.family, &bgp_static->gatewayIp.u.prefix, buf2, sizeof(buf2)); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index de2410e009f0..7107c8403b39 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -618,8 +618,7 @@ static route_map_result_t route_match_mac_address(void *rule, p.prefixlen = ETH_ALEN * 8; p.u.prefix_eth = prefix->u.prefix_evpn.mac; - return (access_list_apply(alist, &p) - == FILTER_DENY + return (access_list_apply(alist, &p) == FILTER_DENY ? RMAP_NOMATCH : RMAP_MATCH); } @@ -3519,9 +3518,9 @@ DEFUN (set_ip_nexthop_peer, "Use peer address (for BGP only)\n") { int (*func)(struct vty *, struct route_map_index *, const char *, - const char *) = strmatch(argv[0]->text, "no") - ? generic_set_delete - : generic_set_add; + const char *) = strmatch(argv[0]->text, "no") + ? generic_set_delete + : generic_set_add; return func(vty, VTY_GET_CONTEXT(route_map_index), "ip next-hop", "peer-address"); @@ -3537,9 +3536,9 @@ DEFUN (set_ip_nexthop_unchanged, "Don't modify existing Next hop address\n") { int (*func)(struct vty *, struct route_map_index *, const char *, - const char *) = strmatch(argv[0]->text, "no") - ? generic_set_delete - : generic_set_add; + const char *) = strmatch(argv[0]->text, "no") + ? generic_set_delete + : generic_set_add; return func(vty, VTY_GET_CONTEXT(route_map_index), "ip next-hop", "unchanged"); @@ -3780,7 +3779,8 @@ DEFUN (set_community, buffer_putstr(b, "no-export"); continue; } - if (strncmp(argv[i]->arg, "graceful-shutdown", strlen(argv[i]->arg)) + if (strncmp(argv[i]->arg, "graceful-shutdown", + strlen(argv[i]->arg)) == 0) { buffer_putstr(b, "graceful-shutdown"); continue; diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 4a8eeb912144..7ee641d6cf35 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1540,7 +1540,8 @@ DEFUN (no_bgp_maxpaths, } ALIAS_HIDDEN(no_bgp_maxpaths, no_bgp_maxpaths_hidden_cmd, - "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", NO_STR + "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM) "]", + NO_STR "Forward packets over multiple paths\n" "Number of paths\n") @@ -1868,14 +1869,14 @@ static void bgp_redistribute_redo(struct bgp *bgp) struct listnode *node; struct bgp_redist *red; - for (afi = AFI_IP; afi < AFI_MAX; afi++) { - for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { + for (afi = AFI_IP; afi < AFI_MAX; afi++) { + for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { - red_list = bgp->redist[afi][i]; - if (!red_list) - continue; + red_list = bgp->redist[afi][i]; + if (!red_list) + continue; - for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { + for (ALL_LIST_ELEMENTS_RO(red_list, node, red)) { bgp_redistribute_resend(bgp, afi, i, red->instance); } @@ -4363,23 +4364,23 @@ DEFUN (neighbor_attr_unchanged, SET_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED); SET_FLAG(flags, PEER_FLAG_MED_UNCHANGED); } else { - if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) && - peer_af_flag_check(peer, afi, safi, - PEER_FLAG_AS_PATH_UNCHANGED)) { + if (!CHECK_FLAG(flags, PEER_FLAG_AS_PATH_UNCHANGED) + && peer_af_flag_check(peer, afi, safi, + PEER_FLAG_AS_PATH_UNCHANGED)) { peer_af_flag_unset_vty(vty, peer_str, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED); } - if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) && - peer_af_flag_check(peer, afi, safi, - PEER_FLAG_NEXTHOP_UNCHANGED)) { + if (!CHECK_FLAG(flags, PEER_FLAG_NEXTHOP_UNCHANGED) + && peer_af_flag_check(peer, afi, safi, + PEER_FLAG_NEXTHOP_UNCHANGED)) { peer_af_flag_unset_vty(vty, peer_str, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED); } - if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) && - peer_af_flag_check(peer, afi, safi, - PEER_FLAG_MED_UNCHANGED)) { + if (!CHECK_FLAG(flags, PEER_FLAG_MED_UNCHANGED) + && peer_af_flag_check(peer, afi, safi, + PEER_FLAG_MED_UNCHANGED)) { peer_af_flag_unset_vty(vty, peer_str, afi, safi, PEER_FLAG_MED_UNCHANGED); } @@ -6125,8 +6126,8 @@ DEFUN_NOSH (address_family_ipv4_safi, if (argc == 3) { VTY_DECLVAR_CONTEXT(bgp, bgp); safi_t safi = bgp_vty_safi_from_str(argv[2]->text); - if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT && - safi != SAFI_UNICAST && safi != SAFI_MULTICAST + if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT + && safi != SAFI_UNICAST && safi != SAFI_MULTICAST && safi != SAFI_EVPN) { vty_out(vty, "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); @@ -6149,8 +6150,8 @@ DEFUN_NOSH (address_family_ipv6_safi, if (argc == 3) { VTY_DECLVAR_CONTEXT(bgp, bgp); safi_t safi = bgp_vty_safi_from_str(argv[2]->text); - if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT && - safi != SAFI_UNICAST && safi != SAFI_MULTICAST + if (bgp->inst_type != BGP_INSTANCE_TYPE_DEFAULT + && safi != SAFI_UNICAST && safi != SAFI_MULTICAST && safi != SAFI_EVPN) { vty_out(vty, "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n"); @@ -6511,8 +6512,8 @@ DEFUN (show_bgp_vrfs, if (!uj && count == 1) vty_out(vty, "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n", - "Type", "Id", "routerId", "#PeersVfg", - "#PeersEstb", "Name", "L3-VNI", "Rmac"); + "Type", "Id", "routerId", "#PeersVfg", + "#PeersEstb", "Name", "L3-VNI", "Rmac"); peers_cfg = peers_estb = 0; if (uj) @@ -6537,8 +6538,9 @@ DEFUN (show_bgp_vrfs, if (uj) { - int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) ? -1 : - (int64_t)bgp->vrf_id; + int64_t vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) + ? -1 + : (int64_t)bgp->vrf_id; json_object_string_add(json_vrf, "type", type); json_object_int_add(json_vrf, "vrfId", vrf_id_ui); json_object_string_add(json_vrf, "routerId", @@ -6549,17 +6551,18 @@ DEFUN (show_bgp_vrfs, peers_estb); json_object_int_add(json_vrf, "l3vni", bgp->l3vni); - json_object_string_add(json_vrf, "rmac", - prefix_mac2str(&bgp->rmac, buf, - sizeof(buf))); + json_object_string_add( + json_vrf, "rmac", + prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); json_object_object_add(json_vrfs, name, json_vrf); } else vty_out(vty, "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n", - type, bgp->vrf_id == VRF_UNKNOWN ? - -1 : (int)bgp->vrf_id, - inet_ntoa(bgp->router_id), - peers_cfg, peers_estb, name, bgp->l3vni, + type, + bgp->vrf_id == VRF_UNKNOWN ? -1 + : (int)bgp->vrf_id, + inet_ntoa(bgp->router_id), peers_cfg, + peers_estb, name, bgp->l3vni, prefix_mac2str(&bgp->rmac, buf, sizeof(buf))); } @@ -6568,8 +6571,9 @@ DEFUN (show_bgp_vrfs, json_object_int_add(json, "totalVrfs", count); - vty_out(vty, "%s\n", json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { if (count) @@ -6718,17 +6722,20 @@ DEFUN (show_bgp_memory, /* Other attributes */ if ((count = community_count())) vty_out(vty, "%ld BGP community entries, using %s of memory\n", - count, mtype_memstr(memstrbuf, sizeof(memstrbuf), - count * sizeof(struct community))); + count, + mtype_memstr(memstrbuf, sizeof(memstrbuf), + count * sizeof(struct community))); if ((count = mtype_stats_alloc(MTYPE_ECOMMUNITY))) vty_out(vty, "%ld BGP community entries, using %s of memory\n", - count, mtype_memstr(memstrbuf, sizeof(memstrbuf), - count * sizeof(struct ecommunity))); + count, + mtype_memstr(memstrbuf, sizeof(memstrbuf), + count * sizeof(struct ecommunity))); if ((count = mtype_stats_alloc(MTYPE_LCOMMUNITY))) vty_out(vty, "%ld BGP large-community entries, using %s of memory\n", - count, mtype_memstr(memstrbuf, sizeof(memstrbuf), - count * sizeof(struct lcommunity))); + count, + mtype_memstr(memstrbuf, sizeof(memstrbuf), + count * sizeof(struct lcommunity))); if ((count = mtype_stats_alloc(MTYPE_CLUSTER))) vty_out(vty, "%ld Cluster lists, using %s of memory\n", count, @@ -6757,8 +6764,9 @@ DEFUN (show_bgp_memory, count * sizeof(struct hash_backet))); if ((count = mtype_stats_alloc(MTYPE_BGP_REGEXP))) vty_out(vty, "%ld compiled regexes, using %s of memory\n", - count, mtype_memstr(memstrbuf, sizeof(memstrbuf), - count * sizeof(regex_t))); + count, + mtype_memstr(memstrbuf, sizeof(memstrbuf), + count * sizeof(regex_t))); return CMD_SUCCESS; } @@ -6773,27 +6781,21 @@ static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json) json_object_string_add(bestpath, "asPath", "confed"); if (bgp_flag_check(bgp, BGP_FLAG_ASPATH_MULTIPATH_RELAX)) { - if (bgp_flag_check(bgp, - BGP_FLAG_MULTIPATH_RELAX_AS_SET)) - json_object_string_add(bestpath, - "multiPathRelax", + if (bgp_flag_check(bgp, BGP_FLAG_MULTIPATH_RELAX_AS_SET)) + json_object_string_add(bestpath, "multiPathRelax", "as-set"); else - json_object_string_add(bestpath, - "multiPathRelax", + json_object_string_add(bestpath, "multiPathRelax", "true"); } else - json_object_string_add(bestpath, - "multiPathRelax", - "false"); + json_object_string_add(bestpath, "multiPathRelax", "false"); if (bgp_flag_check(bgp, BGP_FLAG_COMPARE_ROUTER_ID)) json_object_string_add(bestpath, "compareRouterId", "true"); if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED) || bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) { if (bgp_flag_check(bgp, BGP_FLAG_MED_CONFED)) - json_object_string_add(bestpath, "med", - "confed"); + json_object_string_add(bestpath, "med", "confed"); if (bgp_flag_check(bgp, BGP_FLAG_MED_MISSING_AS_WORST)) json_object_string_add(bestpath, "med", "missing-as-worst"); @@ -6884,9 +6886,9 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, char memstrbuf[MTYPE_MEMSTR_LEN]; int64_t vrf_id_ui; - vrf_id_ui = - (bgp->vrf_id == VRF_UNKNOWN) ? -1 : - (int64_t)bgp->vrf_id; + vrf_id_ui = (bgp->vrf_id == VRF_UNKNOWN) + ? -1 + : (int64_t)bgp->vrf_id; /* Usage summary and header */ if (use_json) { @@ -6905,8 +6907,9 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, vty_out(vty, "BGP router identifier %s, local AS number %u vrf-id %d", inet_ntoa(bgp->router_id), bgp->as, - bgp->vrf_id == VRF_UNKNOWN ? -1 : - (int)bgp->vrf_id); + bgp->vrf_id == VRF_UNKNOWN + ? -1 + : (int)bgp->vrf_id); vty_out(vty, "\n"); } @@ -7015,8 +7018,9 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, json, "peerGroupCount", ents); json_object_int_add( json, "peerGroupMemory", - ents * sizeof(struct - peer_group)); + ents + * sizeof(struct + peer_group)); } if (CHECK_FLAG(bgp->af_flags[afi][safi], @@ -7039,10 +7043,11 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, vty_out(vty, "RIB entries %ld, using %s of memory\n", ents, - mtype_memstr(memstrbuf, - sizeof(memstrbuf), - ents * sizeof(struct - bgp_node))); + mtype_memstr( + memstrbuf, sizeof(memstrbuf), + ents + * sizeof(struct + bgp_node))); /* Peer related usage */ ents = listcount(bgp->peer); @@ -7059,8 +7064,9 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, mtype_memstr( memstrbuf, sizeof(memstrbuf), - ents * sizeof(struct - peer_group))); + ents + * sizeof(struct + peer_group))); if (CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) @@ -7165,7 +7171,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, if (peer->status == Established) if (peer->afc_recv[afi][pfx_rcd_safi]) vty_out(vty, " %12ld", - peer->pcount[afi][pfx_rcd_safi]); + peer->pcount[afi] + [pfx_rcd_safi]); else vty_out(vty, " NoNeg"); else { @@ -7192,8 +7199,9 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, bgp_show_bestpath_json(bgp, json); - vty_out(vty, "%s\n", json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { if (count) @@ -7829,8 +7837,9 @@ static void bgp_show_peer_afi(struct vty *vty, struct peer *p, afi_t afi, paf = peer_af_find(p, afi, safi); if (paf && PAF_SUBGRP(paf)) { - vty_out(vty, " Update group %" PRIu64 - ", subgroup %" PRIu64 "\n", + vty_out(vty, + " Update group %" PRIu64 ", subgroup %" PRIu64 + "\n", PAF_UPDGRP(paf)->id, PAF_SUBGRP(paf)->id); vty_out(vty, " Packet Queue length %d\n", bpacket_queue_virtual_length(paf)); @@ -8300,7 +8309,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json, epoch_tbuf = time(NULL) - uptime; #if CONFDATE > 20200101 - CPP_NOTICE("bgpTimerUp should be deprecated and can be removed now"); + CPP_NOTICE( + "bgpTimerUp should be deprecated and can be removed now"); #endif /* * bgpTimerUp was miliseconds that was accurate @@ -8376,8 +8386,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json, "bgpTimerConfiguredKeepAliveIntervalMsecs", p->keepalive * 1000); } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) - || (bgp->default_keepalive != - BGP_DEFAULT_KEEPALIVE)) { + || (bgp->default_keepalive + != BGP_DEFAULT_KEEPALIVE)) { json_object_int_add(json_neigh, "bgpTimerConfiguredHoldTimeMsecs", bgp->default_holdtime); @@ -8437,8 +8447,8 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json, vty_out(vty, ", keepalive interval is %d seconds\n", p->keepalive); } else if ((bgp->default_holdtime != BGP_DEFAULT_HOLDTIME) - || (bgp->default_keepalive != - BGP_DEFAULT_KEEPALIVE)) { + || (bgp->default_keepalive + != BGP_DEFAULT_KEEPALIVE)) { vty_out(vty, " Configured hold time is %d", bgp->default_holdtime); vty_out(vty, ", keepalive interval is %d seconds\n", @@ -9629,8 +9639,9 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, u_char use_json, } else vty_out(vty, " Reduce the no. of prefix from %s, will restart in %ld seconds\n", - p->host, thread_timer_remain_second( - p->t_pmax_restart)); + p->host, + thread_timer_remain_second( + p->t_pmax_restart)); } else { if (use_json) json_object_boolean_true_add( @@ -9874,8 +9885,9 @@ static int bgp_show_neighbor(struct vty *vty, struct bgp *bgp, } if (use_json) { - vty_out(vty, "%s\n", json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); + vty_out(vty, "%s\n", + json_object_to_json_string_ext( + json, JSON_C_TO_STRING_PRETTY)); json_object_free(json); } else { vty_out(vty, "\n"); @@ -9910,7 +9922,8 @@ static void bgp_show_all_instances_neighbors_vty(struct vty *vty, json_object_int_add(json, "vrfId", (bgp->vrf_id == VRF_UNKNOWN) - ? -1 : (int64_t) bgp->vrf_id); + ? -1 + : (int64_t)bgp->vrf_id); json_object_string_add( json, "vrfName", (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) @@ -10645,7 +10658,8 @@ DEFUN (show_ip_bgp_peer_groups, vrf = pg = NULL; int idx = 0; - vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg : NULL; + vrf = argv_find(argv, argc, "VIEWVRFNAME", &idx) ? argv[idx]->arg + : NULL; pg = argv_find(argv, argc, "PGNAME", &idx) ? argv[idx]->arg : NULL; return bgp_show_peer_group_vty(vty, vrf, pg); diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index e0bd74a20699..b7529c55c160 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -570,8 +570,8 @@ static int zebra_read_route(int command, struct zclient *zclient, /* Now perform the add/update. */ bgp_redistribute_add(bgp, &api.prefix, &nexthop, ifindex, - nhtype, api.metric, api.type, - api.instance, api.tag); + nhtype, api.metric, api.type, api.instance, + api.tag); } else { bgp_redistribute_delete(bgp, &api.prefix, api.type, api.instance); @@ -1142,8 +1142,8 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, api_nh->type = NEXTHOP_TYPE_IPV6_IFINDEX; } - if (mpinfo->extra && - bgp_is_valid_label(&mpinfo->extra->label[0]) + if (mpinfo->extra + && bgp_is_valid_label(&mpinfo->extra->label[0]) && !CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) { has_valid_label = 1; label = label_pton(&mpinfo->extra->label[0]); @@ -1155,8 +1155,7 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, } /* if this is a evpn route we don't have to include the label */ - if (has_valid_label && - !(CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE))) + if (has_valid_label && !(CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE))) SET_FLAG(api.message, ZAPI_MESSAGE_LABEL); if (info->sub_type != BGP_ROUTE_AGGREGATE) @@ -1198,8 +1197,8 @@ void bgp_zebra_announce(struct bgp_node *rn, struct prefix *p, sizeof(nh_buf)); label_buf[0] = '\0'; - if (has_valid_label && - !CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) + if (has_valid_label + && !CHECK_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE)) sprintf(label_buf, "label %u", api_nh->labels[0]); zlog_debug(" nhop [%d]: %s %s", i + 1, nh_buf, @@ -1579,8 +1578,7 @@ void bgp_zebra_instance_register(struct bgp *bgp) /* For default instance, register to learn about VNIs, if appropriate. */ - if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT - && is_evpn_enabled()) + if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT && is_evpn_enabled()) bgp_zebra_advertise_all_vni(bgp, 1); } @@ -1598,8 +1596,7 @@ void bgp_zebra_instance_deregister(struct bgp *bgp) /* For default instance, unregister learning about VNIs, if appropriate. */ - if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT - && is_evpn_enabled()) + if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT && is_evpn_enabled()) bgp_zebra_advertise_all_vni(bgp, 0); /* Deregister for router-id, interfaces, redistributed routes. */ @@ -1749,8 +1746,7 @@ static int bgp_zebra_process_local_l3vni(int cmd, struct zclient *zclient, if (BGP_DEBUG(zebra, ZEBRA)) zlog_debug("Rx L3-VNI %s VRF %s VNI %u RMAC %s", (cmd == ZEBRA_L3VNI_ADD) ? "add" : "del", - vrf_id_to_name(vrf_id), - l3vni, + vrf_id_to_name(vrf_id), l3vni, prefix_mac2str(&rmac, buf, sizeof(buf))); if (cmd == ZEBRA_L3VNI_ADD) @@ -1767,7 +1763,7 @@ static int bgp_zebra_process_local_vni(int command, struct zclient *zclient, struct stream *s; vni_t vni; struct bgp *bgp; - struct in_addr vtep_ip = { INADDR_ANY }; + struct in_addr vtep_ip = {INADDR_ANY}; vrf_id_t tenant_vrf_id = VRF_DEFAULT; s = zclient->ibuf; @@ -1784,8 +1780,8 @@ static int bgp_zebra_process_local_vni(int command, struct zclient *zclient, if (BGP_DEBUG(zebra, ZEBRA)) zlog_debug("Rx VNI %s VRF %s VNI %u tenant-vrf %s", (command == ZEBRA_VNI_ADD) ? "add" : "del", - vrf_id_to_name(vrf_id), - vni, vrf_id_to_name(tenant_vrf_id)); + vrf_id_to_name(vrf_id), vni, + vrf_id_to_name(tenant_vrf_id)); if (command == ZEBRA_VNI_ADD) return bgp_evpn_local_vni_add( @@ -1844,8 +1840,7 @@ static int bgp_zebra_process_local_macip(int command, struct zclient *zclient, return bgp_evpn_local_macip_del(bgp, vni, &mac, &ip); } -static void bgp_zebra_process_local_ip_prefix(int cmd, - struct zclient *zclient, +static void bgp_zebra_process_local_ip_prefix(int cmd, struct zclient *zclient, zebra_size_t length, vrf_id_t vrf_id) { @@ -1871,25 +1866,19 @@ static void bgp_zebra_process_local_ip_prefix(int cmd, if (cmd == ZEBRA_IP_PREFIX_ROUTE_ADD) { if (p.family == AF_INET) - return bgp_evpn_advertise_type5_route(bgp_vrf, &p, - NULL, - AFI_IP, - SAFI_UNICAST); + return bgp_evpn_advertise_type5_route( + bgp_vrf, &p, NULL, AFI_IP, SAFI_UNICAST); else - return bgp_evpn_advertise_type5_route(bgp_vrf, &p, - NULL, - AFI_IP6, - SAFI_UNICAST); + return bgp_evpn_advertise_type5_route( + bgp_vrf, &p, NULL, AFI_IP6, SAFI_UNICAST); } else { if (p.family == AF_INET) - return bgp_evpn_withdraw_type5_route(bgp_vrf, &p, - AFI_IP, - SAFI_UNICAST); + return bgp_evpn_withdraw_type5_route( + bgp_vrf, &p, AFI_IP, SAFI_UNICAST); else - return bgp_evpn_withdraw_type5_route(bgp_vrf, &p, - AFI_IP6, - SAFI_UNICAST); + return bgp_evpn_withdraw_type5_route( + bgp_vrf, &p, AFI_IP6, SAFI_UNICAST); } } diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 4ff0ef41e0b5..78e748fb6c5d 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1403,16 +1403,12 @@ static void bgp_recalculate_afi_safi_bestpaths(struct bgp *bgp, afi_t afi, if (rn->info != NULL) { /* Special handling for 2-level routing * tables. */ - if (safi == SAFI_MPLS_VPN - || safi == SAFI_ENCAP + if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP || safi == SAFI_EVPN) { - for (nrn = bgp_table_top(( - struct bgp_table - *)(rn->info)); - nrn; - nrn = bgp_route_next(nrn)) - bgp_process(bgp, nrn, - afi, safi); + for (nrn = bgp_table_top( + (struct bgp_table *)(rn->info)); + nrn; nrn = bgp_route_next(nrn)) + bgp_process(bgp, nrn, afi, safi); } else bgp_process(bgp, rn, afi, safi); } @@ -1864,8 +1860,7 @@ static int peer_activate_af(struct peer *peer, afi_t afi, safi_t safi) peer->afc[afi][safi] = 1; if (peer->group) - peer_group2peer_config_copy_af(peer->group, peer, - afi, safi); + peer_group2peer_config_copy_af(peer->group, peer, afi, safi); if (!active && peer_active(peer)) { bgp_timer_set(peer); @@ -1933,12 +1928,14 @@ int peer_activate(struct peer *peer, afi_t afi, safi_t safi) ret |= peer_activate_af(peer, afi, safi); } - /* If this is the first peer to be activated for this afi/labeled-unicast - * recalc bestpaths to trigger label allocation */ - if (safi == SAFI_LABELED_UNICAST && !bgp->allocate_mpls_labels[afi][SAFI_UNICAST]) { + /* If this is the first peer to be activated for this + * afi/labeled-unicast recalc bestpaths to trigger label allocation */ + if (safi == SAFI_LABELED_UNICAST + && !bgp->allocate_mpls_labels[afi][SAFI_UNICAST]) { if (BGP_DEBUG(zebra, ZEBRA)) - zlog_info("peer(s) are now active for labeled-unicast, allocate MPLS labels"); + zlog_info( + "peer(s) are now active for labeled-unicast, allocate MPLS labels"); bgp->allocate_mpls_labels[afi][SAFI_UNICAST] = 1; bgp_recalculate_afi_safi_bestpaths(bgp, afi, SAFI_UNICAST); @@ -2027,14 +2024,15 @@ int peer_deactivate(struct peer *peer, afi_t afi, safi_t safi) bgp = peer->bgp; - /* If this is the last peer to be deactivated for this afi/labeled-unicast - * recalc bestpaths to trigger label deallocation */ - if (safi == SAFI_LABELED_UNICAST && - bgp->allocate_mpls_labels[afi][SAFI_UNICAST] && - !bgp_afi_safi_peer_exists(bgp, afi, safi)) { + /* If this is the last peer to be deactivated for this + * afi/labeled-unicast recalc bestpaths to trigger label deallocation */ + if (safi == SAFI_LABELED_UNICAST + && bgp->allocate_mpls_labels[afi][SAFI_UNICAST] + && !bgp_afi_safi_peer_exists(bgp, afi, safi)) { if (BGP_DEBUG(zebra, ZEBRA)) - zlog_info("peer(s) are no longer active for labeled-unicast, deallocate MPLS labels"); + zlog_info( + "peer(s) are no longer active for labeled-unicast, deallocate MPLS labels"); bgp->allocate_mpls_labels[afi][SAFI_UNICAST] = 0; bgp_recalculate_afi_safi_bestpaths(bgp, afi, SAFI_UNICAST); @@ -2654,7 +2652,7 @@ int peer_group_bind(struct bgp *bgp, union sockunion *su, struct peer *peer, } } else if (peer->afc[afi][safi]) peer_deactivate(peer, afi, safi); - } + } if (peer->group) { assert(group && peer->group == group); @@ -2856,8 +2854,7 @@ static struct bgp *bgp_create(as_t *as, const char *name, XSTRDUP(MTYPE_BGP_PEER_HOST, cmd_domainname_get()); bgp->peer = list_new(); bgp->peer->cmp = (int (*)(void *, void *))peer_cmp; - bgp->peerhash = hash_create(peer_hash_key_make, - peer_hash_same, + bgp->peerhash = hash_create(peer_hash_key_make, peer_hash_same, "BGP Peer Hash"); bgp->peerhash->max_size = BGP_PEER_MAX_HASH_SIZE; @@ -3988,8 +3985,9 @@ static int peer_af_flag_modify(struct peer *peer, afi_t afi, safi_t safi, } /* Track if addpath TX is in use */ - if (flag & (PEER_FLAG_ADDPATH_TX_ALL_PATHS - | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { + if (flag + & (PEER_FLAG_ADDPATH_TX_ALL_PATHS + | PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS)) { bgp = peer->bgp; addpath_tx_used = 0; @@ -6802,8 +6800,9 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, } else { if (!peer_af_flag_check(peer, afi, safi, PEER_FLAG_SEND_COMMUNITY) - && (!g_peer || peer_af_flag_check(g_peer, afi, safi, - PEER_FLAG_SEND_COMMUNITY)) + && (!g_peer + || peer_af_flag_check(g_peer, afi, safi, + PEER_FLAG_SEND_COMMUNITY)) && !peer_af_flag_check(peer, afi, safi, PEER_FLAG_SEND_EXT_COMMUNITY) && (!g_peer @@ -6811,9 +6810,10 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, PEER_FLAG_SEND_EXT_COMMUNITY)) && !peer_af_flag_check(peer, afi, safi, PEER_FLAG_SEND_LARGE_COMMUNITY) - && (!g_peer || peer_af_flag_check( - g_peer, afi, safi, - PEER_FLAG_SEND_LARGE_COMMUNITY))) { + && (!g_peer + || peer_af_flag_check( + g_peer, afi, safi, + PEER_FLAG_SEND_LARGE_COMMUNITY))) { vty_out(vty, " no neighbor %s send-community all\n", addr); } else { @@ -6841,9 +6841,10 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, if (!peer_af_flag_check(peer, afi, safi, PEER_FLAG_SEND_COMMUNITY) - && (!g_peer || peer_af_flag_check( - g_peer, afi, safi, - PEER_FLAG_SEND_COMMUNITY))) { + && (!g_peer + || peer_af_flag_check( + g_peer, afi, safi, + PEER_FLAG_SEND_COMMUNITY))) { vty_out(vty, " no neighbor %s send-community\n", addr); @@ -6954,17 +6955,17 @@ static void bgp_config_write_peer_af(struct vty *vty, struct bgp *bgp, bgp_config_write_filter(vty, peer, afi, safi); /* atribute-unchanged. */ - if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) || - peer_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED) || - peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { - - if (!peer_group_active(peer) || - peergroup_af_flag_check(peer, afi, safi, - PEER_FLAG_AS_PATH_UNCHANGED) || - peergroup_af_flag_check(peer, afi, safi, - PEER_FLAG_NEXTHOP_UNCHANGED) || - peergroup_af_flag_check(peer, afi, safi, - PEER_FLAG_MED_UNCHANGED)) { + if (peer_af_flag_check(peer, afi, safi, PEER_FLAG_AS_PATH_UNCHANGED) + || peer_af_flag_check(peer, afi, safi, PEER_FLAG_NEXTHOP_UNCHANGED) + || peer_af_flag_check(peer, afi, safi, PEER_FLAG_MED_UNCHANGED)) { + + if (!peer_group_active(peer) + || peergroup_af_flag_check(peer, afi, safi, + PEER_FLAG_AS_PATH_UNCHANGED) + || peergroup_af_flag_check(peer, afi, safi, + PEER_FLAG_NEXTHOP_UNCHANGED) + || peergroup_af_flag_check(peer, afi, safi, + PEER_FLAG_MED_UNCHANGED)) { vty_out(vty, " neighbor %s attribute-unchanged%s%s%s\n", diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index c4ac4b0adb05..747515a87080 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -262,13 +262,14 @@ struct bgp { /* $FRR indent$ */ /* clang-format off */ #define BGP_MAXMED_ADMIN_UNCONFIGURED 0 /* Off by default */ - u_int32_t - maxmed_admin_value; /* Max-med value when administrative in on + u_int32_t maxmed_admin_value; /* Max-med value when administrative in on */ + /* $FRR indent$ */ + /* clang-format off */ #define BGP_MAXMED_VALUE_DEFAULT 4294967294 /* Maximum by default */ - u_char maxmed_active; /* 1/0 if max-med is active or not */ - u_int32_t maxmed_value; /* Max-med value when its active */ + u_char maxmed_active; /* 1/0 if max-med is active or not */ + u_int32_t maxmed_value; /* Max-med value when its active */ /* BGP update delay on startup */ struct thread *t_update_delay; @@ -828,8 +829,8 @@ struct peer { #define PEER_CONFIG_ROUTEADV (1 << 2) /* route advertise */ #define PEER_GROUP_CONFIG_TIMER (1 << 3) /* timers from peer-group */ -#define PEER_OR_GROUP_TIMER_SET(peer) \ - (CHECK_FLAG(peer->config, PEER_CONFIG_TIMER) \ +#define PEER_OR_GROUP_TIMER_SET(peer) \ + (CHECK_FLAG(peer->config, PEER_CONFIG_TIMER) \ || CHECK_FLAG(peer->config, PEER_GROUP_CONFIG_TIMER)) _Atomic uint32_t holdtime; @@ -869,25 +870,33 @@ struct peer { /* workqueues */ struct work_queue *clear_node_queue; -#define PEER_TOTAL_RX(peer) \ - atomic_load_explicit(&peer->open_in, memory_order_relaxed) + \ - atomic_load_explicit(&peer->update_in, memory_order_relaxed) + \ - atomic_load_explicit(&peer->notify_in, memory_order_relaxed) + \ - atomic_load_explicit(&peer->refresh_in, memory_order_relaxed) + \ - atomic_load_explicit(&peer->keepalive_in, memory_order_relaxed) + \ - atomic_load_explicit(&peer->dynamic_cap_in, memory_order_relaxed) - -#define PEER_TOTAL_TX(peer) \ - atomic_load_explicit(&peer->open_out, memory_order_relaxed) + \ - atomic_load_explicit(&peer->update_out, memory_order_relaxed) + \ - atomic_load_explicit(&peer->notify_out, memory_order_relaxed) + \ - atomic_load_explicit(&peer->refresh_out, memory_order_relaxed) + \ - atomic_load_explicit(&peer->keepalive_out, memory_order_relaxed) + \ - atomic_load_explicit(&peer->dynamic_cap_out, memory_order_relaxed) +#define PEER_TOTAL_RX(peer) \ + atomic_load_explicit(&peer->open_in, memory_order_relaxed) \ + + atomic_load_explicit(&peer->update_in, memory_order_relaxed) \ + + atomic_load_explicit(&peer->notify_in, memory_order_relaxed) \ + + atomic_load_explicit(&peer->refresh_in, \ + memory_order_relaxed) \ + + atomic_load_explicit(&peer->keepalive_in, \ + memory_order_relaxed) \ + + atomic_load_explicit(&peer->dynamic_cap_in, \ + memory_order_relaxed) + +#define PEER_TOTAL_TX(peer) \ + atomic_load_explicit(&peer->open_out, memory_order_relaxed) \ + + atomic_load_explicit(&peer->update_out, \ + memory_order_relaxed) \ + + atomic_load_explicit(&peer->notify_out, \ + memory_order_relaxed) \ + + atomic_load_explicit(&peer->refresh_out, \ + memory_order_relaxed) \ + + atomic_load_explicit(&peer->keepalive_out, \ + memory_order_relaxed) \ + + atomic_load_explicit(&peer->dynamic_cap_out, \ + memory_order_relaxed) /* Statistics field */ - _Atomic uint32_t open_in; /* Open message input count */ - _Atomic uint32_t open_out; /* Open message output count */ + _Atomic uint32_t open_in; /* Open message input count */ + _Atomic uint32_t open_out; /* Open message output count */ _Atomic uint32_t update_in; /* Update message input count */ _Atomic uint32_t update_out; /* Update message ouput count */ _Atomic time_t update_time; /* Update message received time. */ @@ -898,7 +907,7 @@ struct peer { _Atomic uint32_t refresh_in; /* Route Refresh input count */ _Atomic uint32_t refresh_out; /* Route Refresh output count */ _Atomic uint32_t dynamic_cap_in; /* Dynamic Capability input count. */ - _Atomic uint32_t dynamic_cap_out; /* Dynamic Capability output count. */ + _Atomic uint32_t dynamic_cap_out; /* Dynamic Capability output count. */ /* BGP state count */ u_int32_t established; /* Established */ @@ -1480,7 +1489,8 @@ extern int peer_cmp(struct peer *p1, struct peer *p2); extern int bgp_map_afi_safi_iana2int(iana_afi_t pkt_afi, iana_safi_t pkt_safi, afi_t *afi, safi_t *safi); extern int bgp_map_afi_safi_int2iana(afi_t afi, safi_t safi, - iana_afi_t *pkt_afi, iana_safi_t *pkt_safi); + iana_afi_t *pkt_afi, + iana_safi_t *pkt_safi); extern struct peer_af *peer_af_create(struct peer *, afi_t, safi_t); extern struct peer_af *peer_af_find(struct peer *, afi_t, safi_t); diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index e3cb73946474..1fbbac9fc19d 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -260,20 +260,21 @@ int bgp_rfapi_is_vnc_configured(struct bgp *bgp) /*********************************************************************** * VNC Configuration/CLI ***********************************************************************/ -#define VNC_VTY_CONFIG_CHECK(bgp) \ - { \ - switch (bgp_rfapi_is_vnc_configured(bgp)) { \ - case EPERM: \ - vty_out(vty, "VNC operations only permitted on default BGP instance.\n"); \ - return CMD_WARNING_CONFIG_FAILED; \ - break; \ - case ENXIO: \ - vty_out(vty, "VNC not configured.\n"); \ - return CMD_WARNING_CONFIG_FAILED; \ - break; \ - default: \ - break; \ - } \ +#define VNC_VTY_CONFIG_CHECK(bgp) \ + { \ + switch (bgp_rfapi_is_vnc_configured(bgp)) { \ + case EPERM: \ + vty_out(vty, \ + "VNC operations only permitted on default BGP instance.\n"); \ + return CMD_WARNING_CONFIG_FAILED; \ + break; \ + case ENXIO: \ + vty_out(vty, "VNC not configured.\n"); \ + return CMD_WARNING_CONFIG_FAILED; \ + break; \ + default: \ + break; \ + } \ } DEFUN (vnc_advertise_un_method, @@ -509,9 +510,8 @@ DEFUN (vnc_defaults_responselifetime, } else { rspint = strtoul(argv[1]->arg, NULL, 10); if (rspint > INT32_MAX) - rspint = - INT32_MAX; /* is really an int, not an unsigned - int */ + rspint = INT32_MAX; /* is really an int, not an unsigned + int */ } bgp->rfapi_cfg->default_response_lifetime = rspint; @@ -1631,14 +1631,14 @@ DEFUN (vnc_nve_group_export_no_prefixlist, return CMD_WARNING_CONFIG_FAILED; } - if (argv[idx-1]->text[0] == 'z') + if (argv[idx - 1]->text[0] == 'z') is_bgp = 0; - idx += 2; /* skip afi and keyword */ + idx += 2; /* skip afi and keyword */ if (is_bgp) { - if (idx == argc || - strmatch(argv[idx]->arg, - rfg->plist_export_bgp_name[afi])) { + if (idx == argc + || strmatch(argv[idx]->arg, + rfg->plist_export_bgp_name[afi])) { if (rfg->plist_export_bgp_name[afi]) free(rfg->plist_export_bgp_name[afi]); rfg->plist_export_bgp_name[afi] = NULL; @@ -1647,9 +1647,9 @@ DEFUN (vnc_nve_group_export_no_prefixlist, vnc_direct_bgp_reexport_group_afi(bgp, rfg, afi); } } else { - if (idx == argc || - strmatch(argv[idx]->arg, - rfg->plist_export_zebra_name[afi])) { + if (idx == argc + || strmatch(argv[idx]->arg, + rfg->plist_export_zebra_name[afi])) { if (rfg->plist_export_zebra_name[afi]) free(rfg->plist_export_zebra_name[afi]); rfg->plist_export_zebra_name[afi] = NULL; @@ -1700,7 +1700,7 @@ DEFUN (vnc_nve_group_export_prefixlist, return CMD_WARNING_CONFIG_FAILED; } - if (argv[idx-1]->text[0] == 'z') + if (argv[idx - 1]->text[0] == 'z') is_bgp = 0; idx = argc - 1; @@ -1758,18 +1758,19 @@ DEFUN (vnc_nve_group_export_no_routemap, switch (argv[idx]->text[0]) { case 'z': is_bgp = 0; - /* fall thru */ + /* fall thru */ case 'b': idx += 2; break; - default: /* route-map */ + default: /* route-map */ idx++; break; } if (is_bgp) { - if (idx == argc || - strmatch(argv[idx]->arg, rfg->routemap_export_bgp_name)) { + if (idx == argc + || strmatch(argv[idx]->arg, + rfg->routemap_export_bgp_name)) { if (rfg->routemap_export_bgp_name) free(rfg->routemap_export_bgp_name); rfg->routemap_export_bgp_name = NULL; @@ -1779,9 +1780,9 @@ DEFUN (vnc_nve_group_export_no_routemap, vnc_direct_bgp_reexport_group_afi(bgp, rfg, AFI_IP6); } } else { - if (idx == argc || - strmatch(argv[idx]->arg, - rfg->routemap_export_zebra_name)) { + if (idx == argc + || strmatch(argv[idx]->arg, + rfg->routemap_export_zebra_name)) { if (rfg->routemap_export_zebra_name) free(rfg->routemap_export_zebra_name); rfg->routemap_export_zebra_name = NULL; @@ -2466,8 +2467,7 @@ bgp_rfapi_delete_named_nve_group(struct vty *vty, /* NULL = no output */ if (rfg->rfd) clear_vnc_vrf_closer(rfg); bgp_rfapi_delete_nve_group(vty, bgp, rfg); - } - else /* must be delete all */ + } else /* must be delete all */ for (ALL_LIST_ELEMENTS(bgp->rfapi_cfg->nve_groups_sequential, node, nnode, rfg)) { if (rfg->rfd) @@ -3950,7 +3950,9 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) if (rfg->plist_export_bgp_name[afi]) { vty_out(vty, " export %s%s prefix-list %s\n", - (rfg->type == RFAPI_GROUP_CFG_VRF ? "" : "bgp "), + (rfg->type == RFAPI_GROUP_CFG_VRF + ? "" + : "bgp "), afistr, rfg->plist_export_bgp_name [afi]); @@ -3958,7 +3960,9 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) if (rfg->plist_export_zebra_name[afi]) { vty_out(vty, " export %s%s prefix-list %s\n", - (rfg->type == RFAPI_GROUP_CFG_VRF ? "" : "zebra "), + (rfg->type == RFAPI_GROUP_CFG_VRF + ? "" + : "zebra "), afistr, rfg->plist_export_zebra_name [afi]); @@ -3993,12 +3997,16 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) if (rfg->routemap_export_bgp_name) { vty_out(vty, " export %sroute-map %s\n", - (rfg->type == RFAPI_GROUP_CFG_VRF ? "" : "bgp "), + (rfg->type == RFAPI_GROUP_CFG_VRF + ? "" + : "bgp "), rfg->routemap_export_bgp_name); } if (rfg->routemap_export_zebra_name) { vty_out(vty, " export %sroute-map %s\n", - (rfg->type == RFAPI_GROUP_CFG_VRF ? "" : "zebra "), + (rfg->type == RFAPI_GROUP_CFG_VRF + ? "" + : "zebra "), rfg->routemap_export_zebra_name); } if (rfg->routemap_redist_name[ZEBRA_ROUTE_BGP_DIRECT]) { @@ -4098,7 +4106,8 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) } if (hc->default_rd.prefixlen - || hc->default_response_lifetime != BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT + || hc->default_response_lifetime + != BGP_VNC_DEFAULT_RESPONSE_LIFETIME_DEFAULT || hc->default_rt_import_list || hc->default_rt_export_list || hc->nve_groups_sequential->count) { @@ -4184,8 +4193,8 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) prefix2str(&rfg->vn_prefix, buf, sizeof(buf)); - vty_out(vty, " prefix %s %s\n", - "vn", buf); + vty_out(vty, " prefix %s %s\n", "vn", + buf); } if (rfg->un_prefix.family && rfg->un_node) { @@ -4193,8 +4202,8 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) prefix2str(&rfg->un_prefix, buf, sizeof(buf)); - vty_out(vty, " prefix %s %s\n", - "un", buf); + vty_out(vty, " prefix %s %s\n", "un", + buf); } @@ -4215,11 +4224,10 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) value); } else - vty_out(vty, - " rd %s\n", - prefix_rd2str(&rfg->rd, - buf, - sizeof(buf))); + vty_out(vty, " rd %s\n", + prefix_rd2str( + &rfg->rd, buf, + sizeof(buf))); } if (rfg->flags & RFAPI_RFG_RESPONSE_LIFETIME) { vty_out(vty, " response-lifetime "); From d316210b6580faa2462b1e5fb5020ef3b4f1d03c Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Fri, 9 Feb 2018 13:14:22 -0800 Subject: [PATCH 5/5] whitespace/comment fixes per qlyoung Signed-off-by: G. Paul Ziemba --- bgpd/bgp_route.c | 6 +++--- bgpd/bgpd.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2a555aae32e1..046c59aa5413 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -9565,9 +9565,9 @@ static int bgp_peer_counts(struct vty *vty, struct peer *peer, afi_t afi, pcounts.table = peer->bgp->rib[afi][safi]; /* in-place call via thread subsystem so as to record execution time - * * stats for the thread-walk (i.e. ensure this can't be blamed on - * * on just vty_read()). - * */ + * stats for the thread-walk (i.e. ensure this can't be blamed on + * on just vty_read()). + */ thread_execute(bm->master, bgp_peer_count_walker, &pcounts, 0); if (use_json) { diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 747515a87080..51709f9ed0ef 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -895,8 +895,8 @@ struct peer { memory_order_relaxed) /* Statistics field */ - _Atomic uint32_t open_in; /* Open message input count */ - _Atomic uint32_t open_out; /* Open message output count */ + _Atomic uint32_t open_in; /* Open message input count */ + _Atomic uint32_t open_out; /* Open message output count */ _Atomic uint32_t update_in; /* Update message input count */ _Atomic uint32_t update_out; /* Update message ouput count */ _Atomic time_t update_time; /* Update message received time. */