summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_route.c
diff options
context:
space:
mode:
authorMitesh Kanjariya <mitesh@cumulusnetworks.com>2018-02-21 09:36:58 +0100
committerGitHub <noreply@github.com>2018-02-21 09:36:58 +0100
commitf487dcaf74c9bd7a716a749d15281d5b92d363d4 (patch)
tree5362b8a4081b3b8a13038fa520c8d66a95c0192e /bgpd/bgp_route.c
parentbgpd: update the VNI labels in type-2 routes when l3vni gets deleted (diff)
parentMerge pull request #1730 from Orange-OpenSource/master (diff)
downloadfrr-f487dcaf74c9bd7a716a749d15281d5b92d363d4.tar.xz
frr-f487dcaf74c9bd7a716a749d15281d5b92d363d4.zip
Merge branch 'master' into evpn-bug-fixes
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r--bgpd/bgp_route.c515
1 files changed, 246 insertions, 269 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index fe2c5d11a..3dfc446b2 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;
@@ -2099,13 +2101,14 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
rn->flags,
BGP_NODE_REGISTERED_FOR_LABEL))
bgp_unregister_for_label(rn);
- label_ntop(MPLS_IMP_NULL_LABEL, 1,
+ label_ntop(MPLS_LABEL_IMPLICIT_NULL, 1,
&rn->local_label);
bgp_set_valid_label(&rn->local_label);
} 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)) {
@@ -2309,7 +2312,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);
@@ -2333,13 +2337,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;
@@ -2675,9 +2681,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;
@@ -2728,7 +2734,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)
@@ -2794,23 +2801,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;
@@ -2839,10 +2847,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);
}
@@ -2865,10 +2873,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);
@@ -2892,8 +2900,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(
@@ -2906,10 +2913,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);
}
@@ -3060,8 +3067,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)) {
@@ -3140,8 +3147,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);
@@ -3153,8 +3159,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]);
@@ -3177,8 +3182,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)) {
@@ -3259,8 +3264,7 @@ filtered:
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",
@@ -3295,9 +3299,8 @@ filtered:
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];
@@ -3332,8 +3335,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(
@@ -3353,8 +3355,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,
@@ -3365,8 +3366,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);
@@ -3502,8 +3502,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);
@@ -4018,7 +4018,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));
@@ -4060,8 +4060,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. */
@@ -4557,8 +4557,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;
}
@@ -4603,8 +4602,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;
@@ -4612,7 +4611,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 =
@@ -4620,7 +4619,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;
@@ -4638,7 +4637,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 =
@@ -5111,11 +5110,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,
@@ -5130,10 +5128,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:
@@ -5858,8 +5855,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;
@@ -5874,7 +5870,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:
@@ -6255,13 +6251,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, "?");
@@ -6271,13 +6267,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");
@@ -6289,92 +6282,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");
@@ -6385,20 +6366,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",
@@ -6409,17 +6387,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)
@@ -6433,8 +6410,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)
@@ -6457,10 +6433,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 */
@@ -6474,9 +6449,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]);
@@ -6674,8 +6648,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) {
@@ -6869,9 +6842,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;
@@ -6950,8 +6924,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)) {
@@ -7092,8 +7067,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");
@@ -7203,8 +7178,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))) {
@@ -7612,8 +7587,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);
@@ -7733,8 +7707,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);
@@ -7862,9 +7836,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);
@@ -7872,9 +7845,10 @@ 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;
struct bgp_node *rn;
@@ -7891,7 +7865,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\": { ",
@@ -7899,8 +7873,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();
}
@@ -7925,8 +7902,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) {
@@ -7961,8 +7937,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;
}
@@ -7973,8 +7949,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) {
@@ -8013,19 +7988,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(
@@ -8043,8 +8016,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) {
@@ -8069,9 +8042,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);
@@ -8086,16 +8058,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++;
}
@@ -8106,8 +8076,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);
@@ -8133,10 +8102,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 */
@@ -8163,6 +8136,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,9 +8152,9 @@ 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_cum, &total_cum);
+ output_arg, use_json, rd, next == NULL,
+ &output_cum, &total_cum,
+ &json_header_depth);
if (next == NULL)
show_msg = false;
}
@@ -8194,14 +8168,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();
@@ -8226,7 +8199,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,
@@ -8331,8 +8304,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);
@@ -8543,8 +8516,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) {
@@ -8811,14 +8785,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);
}
}
@@ -9036,9 +9013,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;
@@ -9185,7 +9161,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,
@@ -9206,8 +9183,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");
@@ -9325,8 +9302,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]++;
@@ -9441,20 +9418,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:
@@ -9591,9 +9568,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) {
@@ -9616,8 +9593,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 {
@@ -9851,8 +9829,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);
@@ -9963,19 +9942,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++;
@@ -10000,8 +9974,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);
}
}
@@ -10938,18 +10913,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));