summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2017-09-15 17:47:35 +0200
committerRenato Westphal <renato@opensourcerouting.org>2017-09-15 19:53:46 +0200
commita2addae8fe172f04f4d8ac99aa123a7d2dd64604 (patch)
treec58663b6654a9bec64ac4c26e11d158fd48b34ad /bgpd
parentMerge pull request #1178 from donaldsharp/pim_obfuscation (diff)
downloadfrr-a2addae8fe172f04f4d8ac99aa123a7d2dd64604.tar.xz
frr-a2addae8fe172f04f4d8ac99aa123a7d2dd64604.zip
*: use clang's 'ForEachMacros' format style option
This fixes the broken indentation of several foreach loops throughout the code. From clang's documentation[1]: ForEachMacros: A vector of macros that should be interpreted as foreach loops instead of as function calls. [1] http://clang.llvm.org/docs/ClangFormatStyleOptions.html Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_advertise.c34
-rw-r--r--bgpd/bgp_nht.c3
-rw-r--r--bgpd/bgp_route.c117
-rw-r--r--bgpd/bgp_updgrp.c52
-rw-r--r--bgpd/bgp_updgrp_adv.c21
-rw-r--r--bgpd/bgp_updgrp_packet.c3
-rw-r--r--bgpd/bgpd.c7
7 files changed, 112 insertions, 125 deletions
diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c
index a7f72974c..2c83de89e 100644
--- a/bgpd/bgp_advertise.c
+++ b/bgpd/bgp_advertise.c
@@ -155,22 +155,24 @@ int bgp_adj_out_lookup(struct peer *peer, struct bgp_node *rn,
int addpath_capable;
for (adj = rn->adj_out; adj; adj = adj->next)
- SUBGRP_FOREACH_PEER(adj->subgroup, paf)
- if (paf->peer == peer) {
- afi = SUBGRP_AFI(adj->subgroup);
- safi = SUBGRP_SAFI(adj->subgroup);
- addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
-
- /* Match on a specific addpath_tx_id if we are using addpath for
- * this
- * peer and if an addpath_tx_id was specified */
- if (addpath_capable && addpath_tx_id
- && adj->addpath_tx_id != addpath_tx_id)
- continue;
-
- return (adj->adv ? (adj->adv->baa ? 1 : 0)
- : (adj->attr ? 1 : 0));
- }
+ SUBGRP_FOREACH_PEER (adj->subgroup, paf)
+ if (paf->peer == peer) {
+ afi = SUBGRP_AFI(adj->subgroup);
+ safi = SUBGRP_SAFI(adj->subgroup);
+ addpath_capable =
+ bgp_addpath_encode_tx(peer, afi, safi);
+
+ /* Match on a specific addpath_tx_id if we are
+ * using addpath for
+ * this
+ * peer and if an addpath_tx_id was specified */
+ if (addpath_capable && addpath_tx_id
+ && adj->addpath_tx_id != addpath_tx_id)
+ continue;
+
+ return (adj->adv ? (adj->adv->baa ? 1 : 0)
+ : (adj->attr ? 1 : 0));
+ }
return 0;
}
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index a0fc10c74..fc44e5e9b 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -687,8 +687,7 @@ static void evaluate_paths(struct bgp_nexthop_cache *bnc)
buf, bnc->flags, bnc->change_flags);
}
- LIST_FOREACH(path, &(bnc->paths), nh_thread)
- {
+ LIST_FOREACH (path, &(bnc->paths), nh_thread) {
if (!(path->type == ZEBRA_ROUTE_BGP
&& ((path->sub_type == BGP_ROUTE_NORMAL)
|| (path->sub_type == BGP_ROUTE_STATIC))))
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index fabe4483e..e3f63f11b 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -1710,8 +1710,7 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_info *ri,
* Note: 3rd party nexthop currently implemented for
* IPv4 only.
*/
- SUBGRP_FOREACH_PEER(subgrp, paf)
- {
+ SUBGRP_FOREACH_PEER (subgrp, paf) {
if (bgp_multiaccess_check_v4(riattr->nexthop,
paf->peer))
break;
@@ -10110,60 +10109,70 @@ static void show_adj_route(struct vty *vty, struct peer *peer, afi_t afi,
}
} else {
for (adj = rn->adj_out; adj; adj = adj->next)
- SUBGRP_FOREACH_PEER(adj->subgroup, paf)
- if (paf->peer == peer) {
- if (header1) {
- if (use_json) {
- json_object_int_add(
- json, "bgpTableVersion",
- table->version);
- json_object_string_add(
- json,
- "bgpLocalRouterId",
- inet_ntoa(
- bgp->router_id));
- json_object_object_add(
- json, "bgpStatusCodes",
- json_scode);
- json_object_object_add(
- json, "bgpOriginCodes",
- json_ocode);
- } else {
- 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);
- }
- header1 = 0;
- }
+ SUBGRP_FOREACH_PEER (adj->subgroup, paf)
+ if (paf->peer == peer) {
+ if (header1) {
+ if (use_json) {
+ json_object_int_add(
+ json,
+ "bgpTableVersion",
+ table->version);
+ json_object_string_add(
+ json,
+ "bgpLocalRouterId",
+ inet_ntoa(
+ bgp->router_id));
+ json_object_object_add(
+ json,
+ "bgpStatusCodes",
+ json_scode);
+ json_object_object_add(
+ json,
+ "bgpOriginCodes",
+ json_ocode);
+ } else {
+ 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);
+ }
+ header1 = 0;
+ }
- if (header2) {
- if (!use_json)
- vty_out(vty, BGP_SHOW_HEADER);
- header2 = 0;
- }
+ if (header2) {
+ if (!use_json)
+ vty_out(vty,
+ BGP_SHOW_HEADER);
+ header2 = 0;
+ }
- if (adj->attr) {
- bgp_attr_dup(&attr, adj->attr);
- ret = bgp_output_modifier(
- peer, &rn->p, &attr, afi, safi,
- rmap_name);
- if (ret != RMAP_DENY) {
- route_vty_out_tmp(vty, &rn->p,
- &attr, safi,
- use_json,
- json_ar);
- output_count++;
- } else
- filtered_count++;
- }
- }
+ if (adj->attr) {
+ bgp_attr_dup(&attr,
+ adj->attr);
+ ret = bgp_output_modifier(
+ peer, &rn->p,
+ &attr, afi,
+ safi,
+ rmap_name);
+ if (ret != RMAP_DENY) {
+ route_vty_out_tmp(
+ vty,
+ &rn->p,
+ &attr,
+ safi,
+ use_json,
+ json_ar);
+ output_count++;
+ } else
+ filtered_count++;
+ }
+ }
}
}
if (use_json)
diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c
index 05395a583..8f6729060 100644
--- a/bgpd/bgp_updgrp.c
+++ b/bgpd/bgp_updgrp.c
@@ -549,8 +549,7 @@ static int update_group_show_walkcb(struct update_group *updgrp, void *arg)
return CMD_SUCCESS;
if (ctx->subgrp_id) {
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
if (ctx->subgrp_id && (ctx->subgrp_id != subgrp->id))
continue;
else {
@@ -591,8 +590,7 @@ static int update_group_show_walkcb(struct update_group *updgrp, void *arg)
? " replace-as"
: "");
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
if (ctx->subgrp_id && (ctx->subgrp_id != subgrp->id))
continue;
vty_out(vty, "\n");
@@ -636,8 +634,8 @@ static int update_group_show_walkcb(struct update_group *updgrp, void *arg)
: "");
if (subgrp->peer_count > 0) {
vty_out(vty, " Peers:\n");
- SUBGRP_FOREACH_PEER(subgrp, paf)
- vty_out(vty, " - %s\n", paf->peer->host);
+ SUBGRP_FOREACH_PEER (subgrp, paf)
+ vty_out(vty, " - %s\n", paf->peer->host);
}
}
return UPDWALK_CONTINUE;
@@ -655,8 +653,7 @@ static int updgrp_show_packet_queue_walkcb(struct update_group *updgrp,
struct vty *vty;
vty = ctx->vty;
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
if (ctx->subgrp_id && (ctx->subgrp_id != subgrp->id))
continue;
vty_out(vty, "update group %" PRIu64 ", subgroup %" PRIu64 "\n",
@@ -959,8 +956,7 @@ static struct update_subgroup *update_subgroup_find(struct update_group *updgrp,
if (!peer_established(PAF_PEER(paf)))
return NULL;
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
if (subgrp->version != version
|| CHECK_FLAG(subgrp->sflags,
SUBGRP_STATUS_DEFAULT_ORIGINATE))
@@ -1109,8 +1105,7 @@ int update_subgroup_check_merge(struct update_subgroup *subgrp,
/*
* Look for a subgroup to merge into.
*/
- UPDGRP_FOREACH_SUBGRP(subgrp->update_group, target)
- {
+ UPDGRP_FOREACH_SUBGRP (subgrp->update_group, target) {
if (update_subgroup_can_merge_into(subgrp, target))
break;
}
@@ -1177,8 +1172,7 @@ static void update_subgroup_copy_adj_out(struct update_subgroup *source,
{
struct bgp_adj_out *aout, *aout_copy;
- SUBGRP_FOREACH_ADJ(source, aout)
- {
+ SUBGRP_FOREACH_ADJ (source, aout) {
/*
* Copy the adj out.
*/
@@ -1361,15 +1355,13 @@ static int updgrp_policy_update_walkcb(struct update_group *updgrp, void *arg)
* refresh.
*/
if (ctx->policy_event_start_flag) {
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
update_subgroup_set_needs_refresh(subgrp, 1);
}
return UPDWALK_CONTINUE;
}
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
if (changed) {
if (bgp_debug_update(NULL, NULL, updgrp, 0))
zlog_debug(
@@ -1408,8 +1400,8 @@ static int update_group_periodic_merge_walkcb(struct update_group *updgrp,
struct update_subgroup *tmp_subgrp;
const char *reason = arg;
- UPDGRP_FOREACH_SUBGRP_SAFE(updgrp, subgrp, tmp_subgrp)
- update_subgroup_check_merge(subgrp, reason);
+ UPDGRP_FOREACH_SUBGRP_SAFE (updgrp, subgrp, tmp_subgrp)
+ update_subgroup_check_merge(subgrp, reason);
return UPDWALK_CONTINUE;
}
@@ -1550,7 +1542,7 @@ void update_bgp_group_init(struct bgp *bgp)
{
int afid;
- AF_FOREACH(afid)
+ AF_FOREACH (afid)
bgp->update_groups[afid] =
hash_create(updgrp_hash_key_make,
updgrp_hash_cmp,
@@ -1561,8 +1553,7 @@ void update_bgp_group_free(struct bgp *bgp)
{
int afid;
- AF_FOREACH(afid)
- {
+ AF_FOREACH (afid) {
if (bgp->update_groups[afid]) {
hash_free(bgp->update_groups[afid]);
bgp->update_groups[afid] = NULL;
@@ -1740,8 +1731,7 @@ void update_group_walk(struct bgp *bgp, updgrp_walkcb cb, void *ctx)
afi_t afi;
safi_t safi;
- FOREACH_AFI_SAFI(afi, safi)
- {
+ FOREACH_AFI_SAFI (afi, safi) {
update_group_af_walk(bgp, afi, safi, cb, ctx);
}
}
@@ -1763,8 +1753,7 @@ update_group_default_originate_route_map_walkcb(struct update_group *updgrp,
afi_t afi;
safi_t safi;
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
peer = SUBGRP_PEER(subgrp);
afi = SUBGRP_AFI(subgrp);
safi = SUBGRP_SAFI(subgrp);
@@ -1824,8 +1813,7 @@ void peer_af_announce_route(struct peer_af *paf, int combine)
*/
all_pending = 1;
- SUBGRP_FOREACH_PEER(subgrp, cur_paf)
- {
+ SUBGRP_FOREACH_PEER (subgrp, cur_paf) {
if (cur_paf == paf)
continue;
@@ -1860,8 +1848,7 @@ void peer_af_announce_route(struct peer_af *paf, int combine)
*
* First stop refresh timers on all the other peers.
*/
- SUBGRP_FOREACH_PEER(subgrp, cur_paf)
- {
+ SUBGRP_FOREACH_PEER (subgrp, cur_paf) {
if (cur_paf == paf)
continue;
@@ -1889,8 +1876,7 @@ void subgroup_trigger_write(struct update_subgroup *subgrp)
zlog_debug("u%llu:s%llu scheduling write thread for peers",
subgrp->update_group->id, subgrp->id);
#endif
- SUBGRP_FOREACH_PEER(subgrp, paf)
- {
+ SUBGRP_FOREACH_PEER (subgrp, paf) {
if (paf->peer->status == Established) {
BGP_PEER_WRITE_ON(paf->peer->t_write, bgp_write,
paf->peer->fd, paf->peer);
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index 1bd6fb8b3..fbbeaee9b 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -113,8 +113,7 @@ static int group_announce_route_walkcb(struct update_group *updgrp, void *arg)
peer = UPDGRP_PEER(updgrp);
addpath_capable = bgp_addpath_encode_tx(peer, afi, safi);
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
/*
* Skip the subgroups that have coalesce timer running. We will
@@ -262,8 +261,7 @@ static int updgrp_show_adj_walkcb(struct update_group *updgrp, void *arg)
struct vty *vty;
vty = ctx->vty;
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
if (ctx->subgrp_id && (ctx->subgrp_id != subgrp->id))
continue;
vty_out(vty, "update group %" PRIu64 ", subgroup %" PRIu64 "\n",
@@ -311,8 +309,7 @@ static int subgroup_coalesce_timer(struct thread *thread)
struct peer_af *paf;
struct peer *peer;
- SUBGRP_FOREACH_PEER(subgrp, paf)
- {
+ SUBGRP_FOREACH_PEER (subgrp, paf) {
peer = PAF_PEER(paf);
BGP_TIMER_OFF(peer->t_routeadv);
BGP_TIMER_ON(peer->t_routeadv, bgp_routeadv_timer, 0);
@@ -326,8 +323,7 @@ static int update_group_announce_walkcb(struct update_group *updgrp, void *arg)
{
struct update_subgroup *subgrp;
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
subgroup_announce_all(subgrp);
}
@@ -348,8 +344,7 @@ static int update_group_announce_rrc_walkcb(struct update_group *updgrp,
/* Only announce if this is a group of route-reflector-clients */
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_REFLECTOR_CLIENT)) {
- UPDGRP_FOREACH_SUBGRP(updgrp, subgrp)
- {
+ UPDGRP_FOREACH_SUBGRP (updgrp, subgrp) {
subgroup_announce_all(subgrp);
}
}
@@ -468,8 +463,7 @@ void bgp_adj_out_set_subgroup(struct bgp_node *rn,
if (BGP_ADV_FIFO_EMPTY(&subgrp->sync->update)) {
struct peer_af *paf;
- SUBGRP_FOREACH_PEER(subgrp, paf)
- {
+ SUBGRP_FOREACH_PEER (subgrp, paf) {
bgp_adjust_routeadv(PAF_PEER(paf));
}
}
@@ -556,8 +550,7 @@ void subgroup_clear_table(struct update_subgroup *subgrp)
{
struct bgp_adj_out *aout, *taout;
- SUBGRP_FOREACH_ADJ_SAFE(subgrp, aout, taout)
- {
+ SUBGRP_FOREACH_ADJ_SAFE (subgrp, aout, taout) {
struct bgp_node *rn = aout->rn;
bgp_adj_out_remove_subgroup(rn, aout, subgrp);
bgp_unlock_node(rn);
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index 692db32fa..433c5ce51 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -374,8 +374,7 @@ void bpacket_queue_show_vty(struct bpacket_queue *q, struct vty *vty)
vty_out(vty, " Packet %p ver %u buffer %p\n", pkt, pkt->ver,
pkt->buffer);
- LIST_FOREACH(paf, &(pkt->peers), pkt_train)
- {
+ LIST_FOREACH (paf, &(pkt->peers), pkt_train) {
vty_out(vty, " - %s\n", paf->peer->host);
}
pkt = bpacket_next(pkt);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 0d6004756..54155290d 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -2078,8 +2078,8 @@ int peer_delete(struct peer *peer)
}
}
- FOREACH_AFI_SAFI(afi, safi)
- peer_af_delete(peer, afi, safi);
+ FOREACH_AFI_SAFI (afi, safi)
+ peer_af_delete(peer, afi, safi);
if (peer->hostname) {
XFREE(MTYPE_BGP_PEER_HOST, peer->hostname);
@@ -7365,8 +7365,7 @@ static void bgp_viewvrf_autocomplete(vector comps, struct cmd_token *token)
struct listnode *next;
struct bgp *bgp;
- RB_FOREACH(vrf, vrf_name_head, &vrfs_by_name)
- {
+ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
if (vrf->vrf_id != VRF_DEFAULT)
vector_set(comps, XSTRDUP(MTYPE_COMPLETION, vrf->name));
}