summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_network.c4
-rw-r--r--bgpd/bgp_nexthop.c15
-rw-r--r--bgpd/bgp_packet.c4
-rw-r--r--bgpd/bgp_route.c40
-rw-r--r--bgpd/bgp_routemap.c21
-rw-r--r--bgpd/bgp_snmp.c8
-rw-r--r--bgpd/bgp_vty.c34
-rw-r--r--bgpd/bgp_zebra.c71
-rw-r--r--bgpd/bgpd.c246
9 files changed, 208 insertions, 235 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index df377835..e3048687 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -184,10 +184,8 @@ bgp_update_address (struct interface *ifp)
struct connected *connected;
struct listnode *node;
- for (node = listhead (ifp->connected); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
{
- connected = getdata (node);
-
p = (struct prefix_ipv4 *) connected->address;
if (p->family == AF_INET)
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 76c1c2a1..df55f326 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -419,7 +419,7 @@ bgp_scan (afi_t afi, safi_t safi)
struct bgp_info *bi;
struct bgp_info *next;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int valid;
int current;
int changed;
@@ -437,7 +437,7 @@ bgp_scan (afi_t afi, safi_t safi)
return;
/* Maximum prefix check */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->status != Established)
continue;
@@ -723,13 +723,10 @@ bgp_nexthop_self (afi_t afi, struct attr *attr)
struct connected *ifc;
struct prefix *p;
- for (node = listhead (iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
{
- ifp = getdata (node);
-
- for (node2 = listhead (ifp->connected); node2; nextnode (node2))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node2, ifc))
{
- ifc = getdata (node2);
p = ifc->address;
if (p && p->family == AF_INET
@@ -1033,7 +1030,7 @@ bgp_import (struct thread *t)
struct bgp *bgp;
struct bgp_node *rn;
struct bgp_static *bgp_static;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int valid;
u_int32_t metric;
struct in_addr nexthop;
@@ -1046,7 +1043,7 @@ bgp_import (struct thread *t)
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("Import timer expired.");
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MPLS_VPN; safi++)
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 8f7577be..9fa23e52 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1121,7 +1121,7 @@ int
bgp_collision_detect (struct peer *new, struct in_addr remote_id)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp *bgp;
bgp = bgp_get_default ();
@@ -1137,7 +1137,7 @@ bgp_collision_detect (struct peer *new, struct in_addr remote_id)
OPEN message, then the local system performs the following
collision resolution procedure: */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
/* Under OpenConfirm status, local peer structure already hold
remote router ID. */
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 9009638d..4f3847d6 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -1158,7 +1158,7 @@ bgp_process_rsclient (struct bgp *bgp, struct peer *rsclient,
struct bgp_info_pair old_and_new;
struct attr attr;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
p = &rn->p;
@@ -1170,7 +1170,7 @@ bgp_process_rsclient (struct bgp *bgp, struct peer *rsclient,
if (CHECK_FLAG(rsclient->sflags, PEER_STATUS_GROUP))
{
group = rsclient->group;
- LIST_LOOP(group->peer, rsclient, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, rsclient))
{
/* Nothing to do. */
if (old_select && old_select == new_select)
@@ -1203,7 +1203,7 @@ bgp_process_main (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
struct bgp_info *new_select;
struct bgp_info *old_select;
struct bgp_info_pair old_and_new;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct peer *peer;
struct attr attr;
@@ -1235,7 +1235,7 @@ bgp_process_main (struct bgp *bgp, struct bgp_node *rn, afi_t afi, safi_t safi)
/* Check each BGP peer. */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
bgp_process_announce_selected (peer, new_select, rn, &attr, afi, safi);
}
@@ -1954,7 +1954,7 @@ bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
struct prefix_rd *prd, u_char *tag, int soft_reconfig)
{
struct peer *rsclient;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp *bgp;
int ret;
@@ -1964,7 +1964,7 @@ bgp_update (struct peer *peer, struct prefix *p, struct attr *attr,
bgp = peer->bgp;
/* Process the update for each RS-client. */
- LIST_LOOP(bgp->rsclient, rsclient, nn)
+ for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
{
if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
bgp_update_rsclient (rsclient, afi, safi, attr, peer, p, type,
@@ -1984,12 +1984,12 @@ bgp_withdraw (struct peer *peer, struct prefix *p, struct attr *attr,
struct bgp_node *rn;
struct bgp_info *ri;
struct peer *rsclient;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp = peer->bgp;
/* Process the withdraw for each RS-client. */
- LIST_LOOP (bgp->rsclient, rsclient, nn)
+ for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
{
if (CHECK_FLAG (rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
bgp_withdraw_rsclient (rsclient, afi, safi, peer, p, type, sub_type, prd, tag);
@@ -2316,7 +2316,7 @@ bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi)
struct bgp_node *rn;
struct bgp_table *table;
struct peer *rsclient;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (safi != SAFI_MPLS_VPN)
bgp_clear_route_table (peer, afi, safi, NULL, NULL);
@@ -2326,7 +2326,7 @@ bgp_clear_route (struct peer *peer, afi_t afi, safi_t safi)
if ((table = rn->info) != NULL)
bgp_clear_route_table (peer, afi, safi, table, NULL);
- LIST_LOOP (peer->bgp->rsclient, rsclient, nn)
+ for (ALL_LIST_ELEMENTS (peer->bgp->rsclient, node, nnode, rsclient))
{
if (CHECK_FLAG(rsclient->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
bgp_clear_route_table (peer, afi, safi, NULL, rsclient);
@@ -2389,12 +2389,12 @@ void
bgp_cleanup_routes ()
{
struct bgp *bgp;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp_node *rn;
struct bgp_table *table;
struct bgp_info *ri;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
table = bgp->rib[AFI_IP][SAFI_UNICAST];
@@ -2884,11 +2884,11 @@ bgp_static_update (struct bgp *bgp, struct prefix *p,
struct bgp_static *bgp_static, afi_t afi, safi_t safi)
{
struct peer *rsclient;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp_static_update_main (bgp, p, bgp_static, afi, safi);
- LIST_LOOP(bgp->rsclient, rsclient, nn)
+ for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, rsclient))
{
bgp_static_update_rsclient (rsclient, p, bgp_static, afi, safi);
}
@@ -4558,7 +4558,7 @@ bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop,
u_int32_t metric, u_char type)
{
struct bgp *bgp;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp_info *new;
struct bgp_info *bi;
struct bgp_info info;
@@ -4577,7 +4577,7 @@ bgp_redistribute_add (struct prefix *p, struct in_addr *nexthop,
attr.med = metric;
attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
afi = family2afi (p->family);
@@ -4673,12 +4673,12 @@ void
bgp_redistribute_delete (struct prefix *p, u_char type)
{
struct bgp *bgp;
- struct listnode *nn;
+ struct listnode *node, *nnode;
afi_t afi;
struct bgp_node *rn;
struct bgp_info *ri;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
afi = family2afi (p->family);
@@ -5590,7 +5590,7 @@ route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
struct bgp_info *ri;
struct prefix *p;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
char buf1[INET6_ADDRSTRLEN];
char buf2[INET6_ADDRSTRLEN];
int count = 0;
@@ -5649,7 +5649,7 @@ route_vty_out_detail_header (struct vty *vty, struct bgp *bgp,
vty_out (vty, ")%s", VTY_NEWLINE);
/* advertised peer */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (bgp_adj_out_lookup (peer, p, afi, safi, rn))
{
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index b11aaf23..060c68c0 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -108,7 +108,7 @@ route_match_peer (void *rule, struct prefix *prefix, route_map_object_t type,
union sockunion *su2;
struct peer_group *group;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (type == RMAP_BGP)
{
@@ -147,7 +147,7 @@ route_match_peer (void *rule, struct prefix *prefix, route_map_object_t type,
else
{
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (sockunion_same (su, &peer->su))
return RMAP_MATCH;
@@ -2181,7 +2181,8 @@ bgp_route_map_update (const char *unused)
afi_t afi;
safi_t safi;
int direct;
- struct listnode *nn, *nm;
+ struct listnode *node, *nnode;
+ struct listnode *mnode, *mnnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
@@ -2190,9 +2191,9 @@ bgp_route_map_update (const char *unused)
struct bgp_static *bgp_static;
/* For neighbor route-map updates. */
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -2214,7 +2215,7 @@ bgp_route_map_update (const char *unused)
filter->usmap.map = NULL;
}
}
- LIST_LOOP (bgp->group, group, nm)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -2239,9 +2240,9 @@ bgp_route_map_update (const char *unused)
}
/* For default-originate route-map updates. */
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -2256,7 +2257,7 @@ bgp_route_map_update (const char *unused)
}
/* For network route-map updates. */
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -2273,7 +2274,7 @@ bgp_route_map_update (const char *unused)
}
/* For redistribute route-map updates. */
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
{
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index f2d554df..344358e3 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -280,7 +280,7 @@ peer_lookup_addr_ipv4 (struct in_addr *src)
{
struct bgp *bgp;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node;
struct in_addr addr;
int ret;
@@ -288,7 +288,7 @@ peer_lookup_addr_ipv4 (struct in_addr *src)
if (! bgp)
return NULL;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer))
{
ret = inet_pton (AF_INET, peer->host, &addr);
if (ret > 0)
@@ -305,7 +305,7 @@ bgp_peer_lookup_next (struct in_addr *src)
{
struct bgp *bgp;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node;
struct in_addr *p;
union sockunion su;
int ret;
@@ -316,7 +316,7 @@ bgp_peer_lookup_next (struct in_addr *src)
if (! bgp)
return NULL;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS_RO (bgp->peer, node, peer))
{
ret = inet_pton (AF_INET, peer->host, &su.sin.sin_addr);
if (ret > 0)
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index c4b1ef54..52025b76 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -1996,7 +1996,7 @@ peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp_filter *pfilter;
struct bgp_filter *gfilter;
@@ -2032,7 +2032,7 @@ peer_rsclient_set_vty (struct vty *vty, const char *peer_str,
group = peer->group;
gfilter = &peer->filter[afi][safi];
- LIST_LOOP(group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
pfilter = &peer->filter[afi][safi];
@@ -2078,7 +2078,7 @@ peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp = vty->index;
@@ -2094,7 +2094,7 @@ peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
{
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
ret = peer_af_flag_unset (peer, afi, safi, PEER_FLAG_RSERVER_CLIENT);
if (ret < 0)
@@ -3967,12 +3967,12 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
{
int ret;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
/* Clear all neighbors. */
if (sort == clear_all)
{
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (stype == BGP_CLEAR_SOFT_NONE)
ret = peer_clear (peer);
@@ -4028,7 +4028,7 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
return -1;
}
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (stype == BGP_CLEAR_SOFT_NONE)
{
@@ -4049,7 +4049,7 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
if (sort == clear_external)
{
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
@@ -4081,7 +4081,7 @@ bgp_clear (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
}
as = (as_t) as_ul;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->as != as)
continue;
@@ -6425,7 +6425,7 @@ int
bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int count = 0;
char timebuf[BGP_UPTIME_LEN];
int len;
@@ -6433,7 +6433,7 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
/* Header string for each address family. */
static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->afc[afi][safi])
{
@@ -7319,11 +7319,11 @@ int
bgp_show_neighbor (struct vty *vty, struct bgp *bgp,
enum show_type type, union sockunion *su)
{
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct peer *peer;
int find = 0;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
switch (type)
{
@@ -7667,13 +7667,13 @@ bgp_write_rsclient_summary (struct vty *vty, struct peer *rsclient,
char rmbuf[14];
const char *rmname;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int len;
int count = 0;
if (CHECK_FLAG (rsclient->sflags, PEER_STATUS_GROUP))
{
- LIST_LOOP (rsclient->group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (rsclient->group->peer, node, nnode, peer))
{
count++;
bgp_write_rsclient_summary (vty, peer, afi, safi);
@@ -7732,13 +7732,13 @@ bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
afi_t afi, safi_t safi)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int count = 0;
/* Header string for each address family. */
static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State";
- LIST_LOOP (bgp->rsclient, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer))
{
if (peer->afc[afi][safi] &&
CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 176e447a..0c0c8c0c 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -46,16 +46,16 @@ int
bgp_router_id_update (int command, struct zclient *zclient, zebra_size_t length)
{
struct prefix router_id;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp *bgp;
zebra_router_id_update_read(zclient->ibuf,&router_id);
router_id_zebra = router_id.u.prefix4;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
{
if (!bgp->router_id_static.s_addr)
- bgp_router_id_set (bgp, &router_id.u.prefix4);
+ bgp_router_id_set (bgp, &router_id.u.prefix4);
}
return 0;
@@ -92,7 +92,7 @@ bgp_interface_up (int command, struct zclient *zclient, zebra_size_t length)
struct stream *s;
struct interface *ifp;
struct connected *c;
- struct listnode *node;
+ struct listnode *node, *nnode;
s = zclient->ibuf;
ifp = zebra_interface_state_read (s);
@@ -100,11 +100,8 @@ bgp_interface_up (int command, struct zclient *zclient, zebra_size_t length)
if (! ifp)
return 0;
- for (node = listhead (ifp->connected); node; nextnode (node))
- {
- c = getdata (node);
- bgp_connected_add (c);
- }
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
+ bgp_connected_add (c);
return 0;
}
@@ -115,32 +112,29 @@ bgp_interface_down (int command, struct zclient *zclient, zebra_size_t length)
struct stream *s;
struct interface *ifp;
struct connected *c;
- struct listnode *node;
+ struct listnode *node, *nnode;
s = zclient->ibuf;
ifp = zebra_interface_state_read (s);
if (! ifp)
return 0;
- for (node = listhead (ifp->connected); node; nextnode (node))
- {
- c = getdata (node);
- bgp_connected_delete (c);
- }
+ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, c))
+ bgp_connected_delete (c);
/* Fast external-failover (Currently IPv4 only) */
{
- struct listnode *nn, *nm;
+ struct listnode *mnode;
struct bgp *bgp;
struct peer *peer;
struct interface *peer_if;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS_RO (bm->bgp, mnode, bgp))
{
if (CHECK_FLAG (bgp->flags, BGP_FLAG_NO_FAST_EXT_FAILOVER))
continue;
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->ttl != 1)
continue;
@@ -319,13 +313,10 @@ if_lookup_by_ipv4 (struct in_addr *addr)
p.prefix = *addr;
p.prefixlen = IPV4_MAX_BITLEN;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET)
@@ -345,13 +336,10 @@ if_lookup_by_ipv4_exact (struct in_addr *addr)
struct connected *connected;
struct prefix *cp;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET)
@@ -377,13 +365,10 @@ if_lookup_by_ipv6 (struct in6_addr *addr)
p.prefix = *addr;
p.prefixlen = IPV6_MAX_BITLEN;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
@@ -403,13 +388,10 @@ if_lookup_by_ipv6_exact (struct in6_addr *addr)
struct connected *connected;
struct prefix *cp;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
@@ -427,9 +409,8 @@ if_get_ipv6_global (struct interface *ifp, struct in6_addr *addr)
struct connected *connected;
struct prefix *cp;
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
@@ -449,9 +430,8 @@ if_get_ipv6_local (struct interface *ifp, struct in6_addr *addr)
struct connected *connected;
struct prefix *cp;
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
@@ -591,15 +571,12 @@ bgp_ifindex_by_nexthop (struct in6_addr *addr)
p.prefix = *addr;
p.prefixlen = IPV6_MAX_BITLEN;
- for (ifnode = listhead (iflist); ifnode; nextnode (ifnode))
+ for (ALL_LIST_ELEMENTS_RO (iflist, ifnode, ifp))
{
- ifp = getdata (ifnode);
-
- for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, connected))
{
struct prefix *cp;
- connected = getdata (cnode);
cp = connected->address;
if (cp->family == AF_INET6)
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index f3caf46e..d1e8d969 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -160,7 +160,7 @@ int
bgp_router_id_set (struct bgp *bgp, struct in_addr *id)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (bgp_config_check (bgp, BGP_CONFIG_ROUTER_ID)
&& IPV4_ADDR_SAME (&bgp->router_id, id))
@@ -170,7 +170,7 @@ bgp_router_id_set (struct bgp *bgp, struct in_addr *id)
bgp_config_set (bgp, BGP_CONFIG_ROUTER_ID);
/* Set all peer's local identifier with this value. */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
IPV4_ADDR_COPY (&peer->local_id, id);
@@ -189,7 +189,7 @@ int
bgp_cluster_id_set (struct bgp *bgp, struct in_addr *cluster_id)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (bgp_config_check (bgp, BGP_CONFIG_CLUSTER_ID)
&& IPV4_ADDR_SAME (&bgp->cluster_id, cluster_id))
@@ -199,7 +199,7 @@ bgp_cluster_id_set (struct bgp *bgp, struct in_addr *cluster_id)
bgp_config_set (bgp, BGP_CONFIG_CLUSTER_ID);
/* Clear all IBGP peer. */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer_sort (peer) != BGP_PEER_IBGP)
continue;
@@ -218,7 +218,7 @@ int
bgp_cluster_id_unset (struct bgp *bgp)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! bgp_config_check (bgp, BGP_CONFIG_CLUSTER_ID))
return 0;
@@ -227,7 +227,7 @@ bgp_cluster_id_unset (struct bgp *bgp)
bgp_config_unset (bgp, BGP_CONFIG_CLUSTER_ID);
/* Clear all IBGP peer. */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer_sort (peer) != BGP_PEER_IBGP)
continue;
@@ -267,7 +267,7 @@ int
bgp_confederation_id_set (struct bgp *bgp, as_t as)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
int already_confed;
if (as == 0)
@@ -281,7 +281,7 @@ bgp_confederation_id_set (struct bgp *bgp, as_t as)
/* If we were doing confederation already, this is just an external
AS change. Just Reset EBGP sessions, not CONFED sessions. If we
were not doing confederation before, reset all EBGP sessions. */
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
/* We're looking for peers who's AS is not local or part of our
confederation. */
@@ -328,12 +328,12 @@ int
bgp_confederation_id_unset (struct bgp *bgp)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp->confed_id = 0;
bgp_config_unset (bgp, BGP_CONFIG_CONFEDERATION);
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
/* We're looking for peers who's AS is not local */
if (peer_sort (peer) != BGP_PEER_IBGP)
@@ -374,7 +374,7 @@ int
bgp_confederation_peers_add (struct bgp *bgp, as_t as)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! bgp)
return BGP_ERR_INVALID_BGP;
@@ -398,7 +398,7 @@ bgp_confederation_peers_add (struct bgp *bgp, as_t as)
if (bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION))
{
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->as == as)
{
@@ -424,7 +424,7 @@ bgp_confederation_peers_remove (struct bgp *bgp, as_t as)
int i;
int j;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! bgp)
return -1;
@@ -454,7 +454,7 @@ bgp_confederation_peers_remove (struct bgp *bgp, as_t as)
CONFED */
if (bgp_config_check (bgp, BGP_CONFIG_CONFEDERATION))
{
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->as == as)
{
@@ -980,13 +980,13 @@ peer_deactivate (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
struct peer *peer1;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
group = peer->group;
- LIST_LOOP (group->peer, peer1, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer1))
{
if (peer1->af_group[afi][safi])
return BGP_ERR_PEER_GROUP_MEMBER_EXISTS;
@@ -1233,9 +1233,9 @@ struct peer_group *
peer_group_lookup (struct bgp *bgp, const char *name)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
- LIST_LOOP (bgp->group, group, nn)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
if (strcmp (group->name, name) == 0)
return group;
@@ -1528,7 +1528,7 @@ peer_group_remote_as (struct bgp *bgp, const char *group_name, as_t *as)
{
struct peer_group *group;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
group = peer_group_lookup (bgp, group_name);
if (! group)
@@ -1541,7 +1541,7 @@ peer_group_remote_as (struct bgp *bgp, const char *group_name, as_t *as)
number must be updated to same number. */
peer_as_change (group->conf, *as);
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->as != *as)
peer_as_change (peer, *as);
@@ -1555,11 +1555,11 @@ peer_group_delete (struct peer_group *group)
{
struct bgp *bgp;
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp = group->bgp;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->group = NULL;
peer_delete (peer);
@@ -1584,12 +1584,12 @@ int
peer_group_remote_as_delete (struct peer_group *group)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! group->conf->as)
return 0;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->group = NULL;
peer_delete (peer);
@@ -1819,7 +1819,7 @@ struct bgp *
bgp_get_default ()
{
if (bm->bgp->head)
- return bm->bgp->head->data;
+ return (listgetdata (listhead (bm->bgp)));
return NULL;
}
@@ -1828,9 +1828,9 @@ struct bgp *
bgp_lookup (as_t as, const char *name)
{
struct bgp *bgp;
- struct listnode *nn;
+ struct listnode *node, *nnode;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
if (bgp->as == as
&& ((bgp->name == NULL && name == NULL)
|| (bgp->name && name && strcmp (bgp->name, name) == 0)))
@@ -1843,9 +1843,9 @@ struct bgp *
bgp_lookup_by_name (const char *name)
{
struct bgp *bgp;
- struct listnode *nn;
+ struct listnode *node, *nnode;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, node, nnode, bgp))
if ((bgp->name == NULL && name == NULL)
|| (bgp->name && name && strcmp (bgp->name, name) == 0))
return bgp;
@@ -1912,7 +1912,7 @@ int
bgp_delete (struct bgp *bgp)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node;
struct listnode *next;
afi_t afi;
safi_t safi;
@@ -1930,12 +1930,8 @@ bgp_delete (struct bgp *bgp)
bgp->group->del = (void (*)(void *)) peer_group_delete;
list_delete (bgp->group);
- for (nn = bgp->peer->head; nn; nn = next)
- {
- peer = nn->data;
- next = nn->next;
- peer_delete (peer);
- }
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, next, peer))
+ peer_delete (peer);
bgp->rsclient->del = (void (*)(void *)) peer_delete;
list_delete (bgp->rsclient);
@@ -1964,7 +1960,7 @@ struct peer *
peer_lookup (struct bgp *bgp, union sockunion *su)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! bgp)
bgp = bgp_get_default ();
@@ -1972,7 +1968,7 @@ peer_lookup (struct bgp *bgp, union sockunion *su)
if (! bgp)
return NULL;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
@@ -1986,14 +1982,14 @@ peer_lookup_with_open (union sockunion *su, as_t remote_as,
struct in_addr *remote_id, int *as)
{
struct peer *peer;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct bgp *bgp;
bgp = bgp_get_default ();
if (! bgp)
return NULL;
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
@@ -2005,7 +2001,7 @@ peer_lookup_with_open (union sockunion *su, as_t remote_as,
*as = 1;
}
}
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (sockunion_same (&peer->su, su)
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
@@ -2231,7 +2227,7 @@ peer_flag_modify (struct peer *peer, u_int32_t flag, int set)
int found;
int size;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct peer_flag_action action;
memset (&action, 0, sizeof (struct peer_flag_action));
@@ -2288,7 +2284,7 @@ peer_flag_modify (struct peer *peer, u_int32_t flag, int set)
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (set && CHECK_FLAG (peer->flags, flag) == flag)
continue;
@@ -2333,7 +2329,7 @@ peer_af_flag_modify (struct peer *peer, afi_t afi, safi_t safi, u_int32_t flag,
{
int found;
int size;
- struct listnode *nn;
+ struct listnode *node, *nnode;
struct peer_group *group;
struct peer_flag_action action;
@@ -2411,7 +2407,7 @@ peer_af_flag_modify (struct peer *peer, afi_t afi, safi_t safi, u_int32_t flag,
{
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->af_group[afi][safi])
continue;
@@ -2467,7 +2463,7 @@ int
peer_ebgp_multihop_set (struct peer *peer, int ttl)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer_sort (peer) == BGP_PEER_IBGP)
return 0;
@@ -2482,7 +2478,7 @@ peer_ebgp_multihop_set (struct peer *peer, int ttl)
else
{
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
@@ -2500,7 +2496,7 @@ int
peer_ebgp_multihop_unset (struct peer *peer)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer_sort (peer) == BGP_PEER_IBGP)
return 0;
@@ -2518,7 +2514,7 @@ peer_ebgp_multihop_unset (struct peer *peer)
else
{
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer_sort (peer) == BGP_PEER_IBGP)
continue;
@@ -2560,7 +2556,7 @@ int
peer_update_source_if_set (struct peer *peer, const char *ifname)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer->update_if)
{
@@ -2595,7 +2591,7 @@ peer_update_source_if_set (struct peer *peer, const char *ifname)
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->update_if)
{
@@ -2630,7 +2626,7 @@ int
peer_update_source_addr_set (struct peer *peer, union sockunion *su)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer->update_source)
{
@@ -2664,7 +2660,7 @@ peer_update_source_addr_set (struct peer *peer, union sockunion *su)
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->update_source)
{
@@ -2699,7 +2695,7 @@ peer_update_source_unset (struct peer *peer)
{
union sockunion *su;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)
&& ! peer->update_source
@@ -2746,7 +2742,7 @@ peer_update_source_unset (struct peer *peer)
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->update_source && ! peer->update_if)
continue;
@@ -2780,7 +2776,7 @@ peer_default_originate_set (struct peer *peer, afi_t afi, safi_t safi,
const char *rmap)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
/* Adress family must be activated. */
if (! peer->afc[afi][safi])
@@ -2814,7 +2810,7 @@ peer_default_originate_set (struct peer *peer, afi_t afi, safi_t safi,
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
SET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE);
@@ -2836,7 +2832,7 @@ int
peer_default_originate_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
/* Adress family must be activated. */
if (! peer->afc[afi][safi])
@@ -2865,7 +2861,7 @@ peer_default_originate_unset (struct peer *peer, afi_t afi, safi_t safi)
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
UNSET_FLAG (peer->af_flags[afi][safi], PEER_FLAG_DEFAULT_ORIGINATE);
@@ -2899,7 +2895,7 @@ int
peer_weight_set (struct peer *peer, u_int16_t weight)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
SET_FLAG (peer->config, PEER_CONFIG_WEIGHT);
peer->weight = weight;
@@ -2909,7 +2905,7 @@ peer_weight_set (struct peer *peer, u_int16_t weight)
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->weight = group->conf->weight;
}
@@ -2920,7 +2916,7 @@ int
peer_weight_unset (struct peer *peer)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
/* Set default weight. */
if (peer_group_active (peer))
@@ -2935,7 +2931,7 @@ peer_weight_unset (struct peer *peer)
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->weight = 0;
}
@@ -2946,7 +2942,7 @@ int
peer_timers_set (struct peer *peer, u_int32_t keepalive, u_int32_t holdtime)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
/* Not for peer group memeber. */
if (peer_group_active (peer))
@@ -2974,7 +2970,7 @@ peer_timers_set (struct peer *peer, u_int32_t keepalive, u_int32_t holdtime)
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
SET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->holdtime = group->conf->holdtime;
@@ -2987,7 +2983,7 @@ int
peer_timers_unset (struct peer *peer)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
@@ -3002,7 +2998,7 @@ peer_timers_unset (struct peer *peer)
/* peer-group member updates. */
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
UNSET_FLAG (peer->config, PEER_CONFIG_TIMER);
peer->holdtime = 0;
@@ -3106,7 +3102,7 @@ int
peer_allowas_in_set (struct peer *peer, afi_t afi, safi_t safi, int allow_num)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (allow_num < 1 || allow_num > 10)
return BGP_ERR_INVALID_VALUE;
@@ -3122,7 +3118,7 @@ peer_allowas_in_set (struct peer *peer, afi_t afi, safi_t safi, int allow_num)
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (peer->allowas_in[afi][safi] != allow_num)
{
@@ -3139,7 +3135,7 @@ int
peer_allowas_in_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN))
{
@@ -3151,7 +3147,7 @@ peer_allowas_in_unset (struct peer *peer, afi_t afi, safi_t safi)
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_ALLOWAS_IN))
{
@@ -3167,7 +3163,7 @@ peer_local_as_set (struct peer *peer, as_t as, int no_prepend)
{
struct bgp *bgp = peer->bgp;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer_sort (peer) != BGP_PEER_EBGP
&& peer_sort (peer) != BGP_PEER_INTERNAL)
@@ -3205,7 +3201,7 @@ peer_local_as_set (struct peer *peer, as_t as, int no_prepend)
}
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->change_local_as = as;
if (no_prepend)
@@ -3230,7 +3226,7 @@ int
peer_local_as_unset (struct peer *peer)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (peer_group_active (peer))
return BGP_ERR_INVALID_FOR_PEER_GROUP_MEMBER;
@@ -3256,7 +3252,7 @@ peer_local_as_unset (struct peer *peer)
}
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
peer->change_local_as = 0;
UNSET_FLAG (peer->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND);
@@ -3280,7 +3276,7 @@ peer_distribute_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3305,7 +3301,7 @@ peer_distribute_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
@@ -3327,7 +3323,7 @@ peer_distribute_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3364,7 +3360,7 @@ peer_distribute_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
@@ -3387,15 +3383,16 @@ peer_distribute_update (struct access_list *access)
afi_t afi;
safi_t safi;
int direct;
- struct listnode *nn, *nm;
+ struct listnode *mnode, *mnnode;
+ struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_filter *filter;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -3412,7 +3409,7 @@ peer_distribute_update (struct access_list *access)
}
}
}
- LIST_LOOP (bgp->group, group, nm)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -3439,7 +3436,7 @@ peer_prefix_list_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3464,7 +3461,7 @@ peer_prefix_list_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
@@ -3485,7 +3482,7 @@ peer_prefix_list_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3522,7 +3519,7 @@ peer_prefix_list_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
@@ -3542,7 +3539,8 @@ peer_prefix_list_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
void
peer_prefix_list_update (struct prefix_list *plist)
{
- struct listnode *nn, *nm;
+ struct listnode *mnode, *mnnode;
+ struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
@@ -3551,9 +3549,9 @@ peer_prefix_list_update (struct prefix_list *plist)
safi_t safi;
int direct;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -3570,7 +3568,7 @@ peer_prefix_list_update (struct prefix_list *plist)
}
}
}
- LIST_LOOP (bgp->group, group, nm)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -3596,7 +3594,7 @@ peer_aslist_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3618,7 +3616,7 @@ peer_aslist_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
@@ -3639,7 +3637,7 @@ peer_aslist_unset (struct peer *peer,afi_t afi, safi_t safi, int direct)
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3678,7 +3676,7 @@ peer_aslist_unset (struct peer *peer,afi_t afi, safi_t safi, int direct)
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
@@ -3700,15 +3698,16 @@ peer_aslist_update ()
afi_t afi;
safi_t safi;
int direct;
- struct listnode *nn, *nm;
+ struct listnode *mnode, *mnnode;
+ struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;
struct peer_group *group;
struct bgp_filter *filter;
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
- LIST_LOOP (bgp->peer, peer, nm)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -3725,7 +3724,7 @@ peer_aslist_update ()
}
}
}
- LIST_LOOP (bgp->group, group, nm)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
@@ -3752,7 +3751,7 @@ peer_route_map_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3777,7 +3776,7 @@ peer_route_map_set (struct peer *peer, afi_t afi, safi_t safi, int direct,
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
@@ -3799,7 +3798,7 @@ peer_route_map_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
struct bgp_filter *filter;
struct bgp_filter *gfilter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3836,7 +3835,7 @@ peer_route_map_unset (struct peer *peer, afi_t afi, safi_t safi, int direct)
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
@@ -3858,7 +3857,7 @@ peer_unsuppress_map_set (struct peer *peer, afi_t afi, safi_t safi,
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3878,7 +3877,7 @@ peer_unsuppress_map_set (struct peer *peer, afi_t afi, safi_t safi,
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
@@ -3899,7 +3898,7 @@ peer_unsuppress_map_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct bgp_filter *filter;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3918,7 +3917,7 @@ peer_unsuppress_map_unset (struct peer *peer, afi_t afi, safi_t safi)
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
filter = &peer->filter[afi][safi];
@@ -3939,7 +3938,7 @@ peer_maximum_prefix_set (struct peer *peer, afi_t afi, safi_t safi,
int warning, u_int16_t restart)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -3957,7 +3956,7 @@ peer_maximum_prefix_set (struct peer *peer, afi_t afi, safi_t safi,
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->af_group[afi][safi])
continue;
@@ -3978,7 +3977,7 @@ int
peer_maximum_prefix_unset (struct peer *peer, afi_t afi, safi_t safi)
{
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
if (! peer->afc[afi][safi])
return BGP_ERR_PEER_INACTIVE;
@@ -4014,7 +4013,7 @@ peer_maximum_prefix_unset (struct peer *peer, afi_t afi, safi_t safi)
return 0;
group = peer->group;
- LIST_LOOP (group->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (group->peer, node, nnode, peer))
{
if (! peer->af_group[afi][safi])
continue;
@@ -4606,13 +4605,13 @@ bgp_config_write_family (struct vty *vty, struct bgp *bgp, afi_t afi,
int write = 0;
struct peer *peer;
struct peer_group *group;
- struct listnode *nn;
+ struct listnode *node, *nnode;
bgp_config_write_network (vty, bgp, afi, safi, &write);
bgp_config_write_redistribute (vty, bgp, afi, safi, &write);
- LIST_LOOP (bgp->group, group, nn)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
if (group->conf->afc[afi][safi])
{
@@ -4620,7 +4619,7 @@ bgp_config_write_family (struct vty *vty, struct bgp *bgp, afi_t afi,
bgp_config_write_peer (vty, bgp, group->conf, afi, safi);
}
}
- LIST_LOOP (bgp->peer, peer, nn)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (peer->afc[afi][safi])
{
@@ -4644,7 +4643,8 @@ bgp_config_write (struct vty *vty)
struct bgp *bgp;
struct peer_group *group;
struct peer *peer;
- struct listnode *nn, *nm, *no;
+ struct listnode *node, *nnode;
+ struct listnode *mnode, *mnnode;
/* BGP Multiple instance. */
if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
@@ -4661,7 +4661,7 @@ bgp_config_write (struct vty *vty)
}
/* BGP configuration. */
- LIST_LOOP (bm->bgp, bgp, nn)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
{
if (write)
vty_out (vty, "!%s", VTY_NEWLINE);
@@ -4789,13 +4789,13 @@ bgp_config_write (struct vty *vty)
bgp->default_holdtime, VTY_NEWLINE);
/* peer-group */
- LIST_LOOP (bgp->group, group, nm)
+ for (ALL_LIST_ELEMENTS (bgp->group, node, nnode, group))
{
bgp_config_write_peer (vty, bgp, group->conf, AFI_IP, SAFI_UNICAST);
}
/* Normal neighbor configuration. */
- LIST_LOOP (bgp->peer, peer, no)
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
{
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
bgp_config_write_peer (vty, bgp, peer, AFI_IP, SAFI_UNICAST);
@@ -4887,15 +4887,15 @@ bgp_terminate ()
{
struct bgp *bgp;
struct peer *peer;
- struct listnode *nn;
- struct listnode *mm;
+ struct listnode *node, *nnode;
+ struct listnode *mnode, *mnnode;
- LIST_LOOP (bm->bgp, bgp, nn)
- LIST_LOOP (bgp->peer, peer, mm)
+ for (ALL_LIST_ELEMENTS (bm->bgp, mnode, mnnode, bgp))
+ for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_PEER_UNCONFIG);
-
+
bgp_cleanup_routes ();
}