Browse Source

2005-04-07 Paul Jakma <paul.jakma@sun.com>

	* (global): Fix up list loops to match changes in lib/linklist,
	  and some basic auditing of usage.
	* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
	* HACKING: Add notes about deprecating interfaces and commands.
	* lib/linklist.h: Add usage comments.
	  Rename getdata macro to listgetdata.
	  Rename nextnode to listnextnode and fix its odd behaviour to be
	  less dangerous.
	  Make listgetdata macro assert node is not null, NULL list entries
          should be bug condition.
          ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use
          with for loop, Suggested by Jim Carlson of Sun.
          Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the
          "safety" of previous macro.
	  LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to
	  distinguish from the similarly named functions, and reflect their
	  effect better.
	  Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section
	  with the old defines which were modified above,
	  for backwards compatibility - guarded to prevent Quagga using it..
	* lib/linklist.c: fix up for linklist.h changes.
	* ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single
	  scan of the area list, rather than scanning all areas first for
	  INTER_ROUTER and then again for INTER_NETWORK. According to
	  16.2, the scan should be area specific anyway, and further
	  ospf6d does not seem to implement 16.3 anyway.
paul 14 years ago
parent
commit
1eb8ef2584
84 changed files with 1886 additions and 2485 deletions
  1. 7 0
      ChangeLog
  2. 30 1
      HACKING
  3. 1 3
      bgpd/bgp_network.c
  4. 6 9
      bgpd/bgp_nexthop.c
  5. 2 2
      bgpd/bgp_packet.c
  6. 20 20
      bgpd/bgp_route.c
  7. 11 10
      bgpd/bgp_routemap.c
  8. 4 4
      bgpd/bgp_snmp.c
  9. 17 17
      bgpd/bgp_vty.c
  10. 24 47
      bgpd/bgp_zebra.c
  11. 123 123
      bgpd/bgpd.c
  12. 9 1
      configure.ac
  13. 23 44
      isisd/isis_adjacency.c
  14. 19 32
      isisd/isis_circuit.c
  15. 6 13
      isisd/isis_dr.c
  16. 4 8
      isisd/isis_dynhn.c
  17. 3 6
      isisd/isis_events.c
  18. 1 1
      isisd/isis_flags.c
  19. 42 58
      isisd/isis_lsp.c
  20. 31 34
      isisd/isis_pdu.c
  21. 41 66
      isisd/isis_route.c
  22. 47 69
      isisd/isis_spf.c
  23. 15 23
      isisd/isis_tlv.c
  24. 3 8
      isisd/isis_zebra.c
  25. 24 34
      isisd/isisd.c
  26. 22 0
      lib/ChangeLog
  27. 17 33
      lib/if.c
  28. 14 14
      lib/keychain.c
  29. 3 3
      lib/linklist.c
  30. 53 11
      lib/linklist.h
  31. 8 13
      lib/smux.c
  32. 10 0
      ospf6d/ChangeLog
  33. 16 33
      ospf6d/ospf6_abr.c
  34. 17 31
      ospf6d/ospf6_area.c
  35. 6 12
      ospf6d/ospf6_asbr.c
  36. 20 40
      ospf6d/ospf6_flood.c
  37. 34 56
      ospf6d/ospf6_interface.c
  38. 24 36
      ospf6d/ospf6_intra.c
  39. 2 4
      ospf6d/ospf6_message.c
  40. 14 33
      ospf6d/ospf6_neighbor.c
  41. 2 5
      ospf6d/ospf6_snmp.c
  42. 5 6
      ospf6d/ospf6_spf.c
  43. 24 44
      ospf6d/ospf6_top.c
  44. 44 90
      ospf6d/ospf6d.c
  45. 1 1
      ospf6d/ospf6d.h
  46. 35 58
      ospfd/ospf_abr.c
  47. 54 67
      ospfd/ospf_apiserver.c
  48. 38 46
      ospfd/ospf_ase.c
  49. 38 39
      ospfd/ospf_flood.c
  50. 24 29
      ospfd/ospf_ia.c
  51. 48 64
      ospfd/ospf_interface.c
  52. 3 9
      ospfd/ospf_ism.c
  53. 50 69
      ospfd/ospf_lsa.c
  54. 3 6
      ospfd/ospf_neighbor.c
  55. 60 87
      ospfd/ospf_opaque.c
  56. 29 34
      ospfd/ospf_packet.c
  57. 27 42
      ospfd/ospf_route.c
  58. 21 27
      ospfd/ospf_snmp.c
  59. 44 61
      ospfd/ospf_spf.c
  60. 26 29
      ospfd/ospf_te.c
  61. 110 130
      ospfd/ospf_vty.c
  62. 35 41
      ospfd/ospf_zebra.c
  63. 66 111
      ospfd/ospfd.c
  64. 87 116
      ripd/rip_interface.c
  65. 4 4
      ripd/rip_offset.c
  66. 6 6
      ripd/rip_peer.c
  67. 16 29
      ripd/ripd.c
  68. 38 50
      ripngd/ripng_interface.c
  69. 2 3
      ripngd/ripng_nexthop.c
  70. 4 4
      ripngd/ripng_offset.c
  71. 6 6
      ripngd/ripng_peer.c
  72. 18 28
      ripngd/ripngd.c
  73. 9 9
      vtysh/vtysh_config.c
  74. 4 4
      vtysh/vtysh_user.c
  75. 6 12
      zebra/connected.c
  76. 2 4
      zebra/if_ioctl.c
  77. 1 1
      zebra/if_ioctl_solaris.c
  78. 15 27
      zebra/interface.c
  79. 5 8
      zebra/irdp_interface.c
  80. 7 8
      zebra/irdp_main.c
  81. 68 74
      zebra/redistribute.c
  82. 13 17
      zebra/router-id.c
  83. 8 16
      zebra/rtadv.c
  84. 7 12
      zebra/zserv.c

+ 7 - 0
ChangeLog

@@ -1,3 +1,10 @@
+2005-04-07 Paul Jakma <paul.jakma@sun.com>
+
+	* (global): Fix up list loops to match changes in lib/linklist, 
+	  and some basic auditing of usage.
+	* configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES
+	* HACKING: Add notes about deprecating interfaces and commands.
+
 2005-04-05 Paul Jakma <paul@dishone.st>
 
 	* HACKING: remove the 'manually patch redhat/quagga.spec' bit

+ 30 - 1
HACKING

@@ -1,5 +1,5 @@
 -*- mode: text; -*-
-$Id: HACKING,v 1.18 2005/04/05 10:14:50 paul Exp $
+$Id: HACKING,v 1.19 2005/04/07 07:30:20 paul Exp $
 
 GUIDELINES FOR HACKING ON QUAGGA
 
@@ -44,6 +44,32 @@ these header files:
   lib/log.h	logging levels and usage guidance
   [more to be added]
 
+If changing an exported interface, please try to deprecate the interface in
+an orderly manner. If at all possible, try to retain the old deprecated
+interface as is, or functionally equivalent. Make a note of when the
+interface was deprecated and guard the deprecated interface definitions in
+the header file, ie:
+
+/* Deprecated: 20050406 */
+#if !defined(QUAGGA_NO_DEPRECATED_INTERFACES)
+#warning "Using deprecated <libname> (interface(s)|function(s))"
+...
+#endif /* QUAGGA_NO_DEPRECATED_INTERFACES */
+
+To ensure that the core Quagga sources do not use the deprecated interfaces
+(you should update Quagga sources to use new interfaces, if applicable)
+while allowing external sources to continue to build. Deprecated interfaces
+should be excised in the next unstable cycle.
+
+If changing or removing a command definition, *ensure* that you properly
+deprecate it - use the _DEPRECATED form of the appropriate DEFUN macro. This
+is *critical*. Even if the command can no longer function, you *must* still
+implement it as a do-nothing stub. Failure to follow this causes grief for
+systems administrators. Deprecated commands should be excised in the next
+unstable cycle. A list of deprecated commands should be collated for each
+release.
+
+See also below regarding SHARED LIBRARY VERSIONING.
 
 CHANGELOG
 
@@ -79,6 +105,9 @@ If any errors occur, move tags as needed and start over from the fresh
 checkouts.  Do not append to tarballs, as this has produced
 non-standards-conforming tarballs in the past.
 
+[TODO: collation of a list of deprecated commands. Possibly can be scripted
+to extract from vtysh/vtysh_cmd.c]
+
 TOOL VERSIONS
 
 Require versions of support tools are listed in INSTALL.quagga.txt.

+ 1 - 3
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)

+ 6 - 9
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++)

+ 2 - 2
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. */

+ 20 - 20
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))
 	{

+ 11 - 10
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++)
 	{

+ 4 - 4
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)

+ 17 - 17
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))

+ 24 - 47
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)

+ 123 - 123
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 ();
 }
 

+ 9 - 1
configure.ac

@@ -5,7 +5,7 @@
 ##  Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
 ##  Portions Copyright (c) 2003 Paul Jakma <paul@dishone.st>
 ##
-## $Id: configure.ac,v 1.98 2005/04/03 23:46:37 hasso Exp $
+## $Id: configure.ac,v 1.99 2005/04/07 07:30:20 paul Exp $
 AC_PREREQ(2.53)
 
 AC_INIT(Quagga, 0.99.0, [http://bugzilla.quagga.net])
@@ -1252,6 +1252,14 @@ AC_DEFINE_UNQUOTED(OSPF6_VTYSH_PATH, "$quagga_statedir/ospf6d.vty",ospf6d vty so
 AC_DEFINE_UNQUOTED(ISIS_VTYSH_PATH, "$quagga_statedir/isisd.vty",isisd vty socket)
 AC_DEFINE_UNQUOTED(DAEMON_VTY_DIR, "$quagga_statedir",daemon vty directory)
 
+dnl -------------------------------
+dnl Quagga sources should always be 
+dnl current wrt interfaces. Dont
+dnl allow deprecated interfaces to
+dnl be exposed.
+dnl -------------------------------
+AC_DEFINE(QUAGGA_NO_DEPRECATED_INTERFACES, 1, Hide deprecated interfaces)
+
 dnl ---------------------------
 dnl Check htonl works correctly
 dnl ---------------------------

+ 23 - 44
isisd/isis_adjacency.c

@@ -103,12 +103,9 @@ isis_adj_lookup (u_char * sysid, struct list *adjdb)
   struct isis_adjacency *adj;
   struct listnode *node;
 
-  for (node = listhead (adjdb); node; nextnode (node))
-    {
-      adj = getdata (node);
-      if (memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN) == 0)
-	return adj;
-    }
+  for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
+    if (memcmp (adj->sysid, sysid, ISIS_SYS_ID_LEN) == 0)
+      return adj;
 
   return NULL;
 }
@@ -120,12 +117,9 @@ isis_adj_lookup_snpa (u_char * ssnpa, struct list *adjdb)
   struct listnode *node;
   struct isis_adjacency *adj;
 
-  for (node = listhead (adjdb); node; nextnode (node))
-    {
-      adj = getdata (node);
-      if (memcmp (adj->snpa, ssnpa, ETH_ALEN) == 0)
-	return adj;
-    }
+  for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
+    if (memcmp (adj->snpa, ssnpa, ETH_ALEN) == 0)
+      return adj;
 
   return NULL;
 }
@@ -136,17 +130,15 @@ isis_adj_lookup_snpa (u_char * ssnpa, struct list *adjdb)
 void
 isis_delete_adj (struct isis_adjacency *adj, struct list *adjdb)
 {
-  struct isis_adjacency *adj2;
+  struct isis_adjacency *adj2 = NULL;
   struct listnode *node;
 
   if (adjdb)
     {
-      for (node = listhead (adjdb); node; nextnode (node))
-	{
-	  adj2 = getdata (node);
-	  if (adj2 == adj)
-	    break;
-	}
+      for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj2))
+        if (adj2 == adj)
+          break;
+
       listnode_delete (adjdb, adj);
     }
 
@@ -249,20 +241,16 @@ isis_adj_print (struct isis_adjacency *adj)
     {
       zlog_debug ("IPv4 Addresses:");
 
-      for (node = listhead (adj->ipv4_addrs); node; nextnode (node))
-	{
-	  ipv4_addr = getdata (node);
-	  zlog_debug ("%s", inet_ntoa (*ipv4_addr));
-	}
+      for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ipv4_addr))
+        zlog_debug ("%s", inet_ntoa (*ipv4_addr));
     }
 
 #ifdef HAVE_IPV6
   if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0)
     {
       zlog_debug ("IPv6 Addresses:");
-      for (node = listhead (adj->ipv6_addrs); node; nextnode (node))
+      for (ALL_LIST_ELEMENTS_RO (adj->ipv6_addrs, node, ipv6_addr))
 	{
-	  ipv6_addr = getdata (node);
 	  inet_ntop (AF_INET6, ipv6_addr, (char *)ip6, INET6_ADDRSTRLEN);
 	  zlog_debug ("%s", ip6);
 	}
@@ -400,19 +388,15 @@ isis_adj_print_vty2 (struct isis_adjacency *adj, struct vty *vty, char detail)
       if (adj->ipv4_addrs && listcount (adj->ipv4_addrs) > 0)
 	{
 	  vty_out (vty, "    IPv4 Addresses:%s", VTY_NEWLINE);
-	  for (node = listhead (adj->ipv4_addrs); node; nextnode (node))
-	    {
-	      ip_addr = getdata (node);
-	      vty_out (vty, "      %s%s", inet_ntoa (*ip_addr), VTY_NEWLINE);
-	    }
+	  for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ip_addr))
+            vty_out (vty, "      %s%s", inet_ntoa (*ip_addr), VTY_NEWLINE);
 	}
 #ifdef HAVE_IPV6
       if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0)
 	{
 	  vty_out (vty, "    IPv6 Addresses:%s", VTY_NEWLINE);
-	  for (node = listhead (adj->ipv6_addrs); node; nextnode (node))
+	  for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ipv6_addr))
 	    {
-	      ipv6_addr = getdata (node);
 	      inet_ntop (AF_INET6, ipv6_addr, (char *)ip6, INET6_ADDRSTRLEN);
 	      vty_out (vty, "      %s%s", ip6, VTY_NEWLINE);
 	    }
@@ -463,13 +447,11 @@ void
 isis_adjdb_iterate (struct list *adjdb, void (*func) (struct isis_adjacency *,
 						      void *), void *arg)
 {
-  struct listnode *node;
+  struct listnode *node, *nnode;
   struct isis_adjacency *adj;
-  for (node = listhead (adjdb); node; nextnode (node))
-    {
-      adj = getdata (node);
-      (*func) (adj, arg);
-    }
+
+  for (ALL_LIST_ELEMENTS (adjdb, node, nnode, adj))
+    (*func) (adj, arg);
 }
 
 void
@@ -484,9 +466,8 @@ isis_adj_build_neigh_list (struct list *adjdb, struct list *list)
       return;
     }
 
-  for (node = listhead (adjdb); node; nextnode (node))
+  for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
     {
-      adj = getdata (node);
       if (!adj)
 	{
 	  zlog_warn ("isis_adj_build_neigh_list(): NULL adj");
@@ -512,10 +493,8 @@ isis_adj_build_up_list (struct list *adjdb, struct list *list)
       return;
     }
 
-  for (node = listhead (adjdb); node; nextnode (node))
+  for (ALL_LIST_ELEMENTS_RO (adjdb, node, adj))
     {
-      adj = getdata (node);
-
       if (!adj)
 	{
 	  zlog_warn ("isis_adj_build_up_list(): NULL adj");

+ 19 - 32
isisd/isis_circuit.c

@@ -150,13 +150,10 @@ circuit_lookup_by_ifp (struct interface *ifp, struct list *list)
   if (!list)
     return NULL;
 
-  for (node = listhead (list); node; nextnode (node))
-    {
-      circuit = getdata (node);
-      if (circuit->interface == ifp)
-	return circuit;
-    }
-
+  for (ALL_LIST_ELEMENTS_RO (list, node, circuit))
+    if (circuit->interface == ifp)
+      return circuit;
+  
   return NULL;
 }
 
@@ -170,9 +167,8 @@ circuit_scan_by_ifp (struct interface *ifp)
   if (!isis->area_list)
     return NULL;
 
-  for (node = listhead (isis->area_list); node; nextnode (node))
+  for (ALL_LIST_ELEMENTS_RO (isis->area_list, node, area))
     {
-      area = getdata (node);
       circuit = circuit_lookup_by_ifp (ifp, area->circuit_list);
       if (circuit)
 	return circuit;
@@ -295,12 +291,9 @@ isis_circuit_del_addr (struct isis_circuit *circuit,
       ipv4->prefixlen = connected->address->prefixlen;
       ipv4->prefix = connected->address->u.prefix4;
 
-      for (node = listhead (circuit->ip_addrs); node; nextnode (node))
-	{
-	  ip = getdata (node);
-	  if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
-	    break;
-	}
+      for (ALL_LIST_ELEMENTS_RO (circuit->ip_addrs, node, ip))
+        if (prefix_same ((struct prefix *) ip, (struct prefix *) &ipv4))
+          break;
 
       if (ip)
 	{
@@ -324,9 +317,8 @@ isis_circuit_del_addr (struct isis_circuit *circuit,
 
       if (IN6_IS_ADDR_LINKLOCAL (&ipv6->prefix))
 	{
-	  for (node = listhead (circuit->ipv6_link); node; nextnode (node))
+	  for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_link, node, ip6))
 	    {
-	      ip6 = getdata (node);
 	      if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
 		break;
 	    }
@@ -338,9 +330,8 @@ isis_circuit_del_addr (struct isis_circuit *circuit,
 	}
       else
 	{
-	  for (node = listhead (circuit->ipv6_non_link); node; nextnode (node))
+	  for (ALL_LIST_ELEMENTS_RO (circuit->ipv6_non_link, node, ip6))
 	    {
-	      ip6 = getdata (node);
 	      if (prefix_same ((struct prefix *) ip6, (struct prefix *) ipv6))
 		break;
 	    }
@@ -368,7 +359,7 @@ isis_circuit_del_addr (struct isis_circuit *circuit,
 void
 isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
 {
-  struct listnode *node;
+  struct listnode *node, *nnode;
   struct connected *conn;
 
   circuit->interface = ifp;
@@ -416,12 +407,8 @@ isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp)
       zlog_warn ("isis_circuit_if_add: unsupported media");
     }
 
-  for (node = ifp->connected ? listhead (ifp->connected) : NULL; node;
-       nextnode (node))
-    {
-      conn = getdata (node);
-      isis_circuit_add_addr (circuit, conn);
-    }
+  for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn))
+    isis_circuit_add_addr (circuit, conn);
 
   return;
 }
@@ -631,14 +618,14 @@ isis_interface_config_write (struct vty *vty)
 {
 
   int write = 0;
-  struct listnode *node;
-  struct listnode *node2;
+  struct listnode *node, *nnode;
+  struct listnode *node2, *nnode2;
   struct interface *ifp;
   struct isis_area *area;
   struct isis_circuit *c;
   int i;
 
-  LIST_LOOP (iflist, ifp, node)
+  for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
   {
     /* IF name */
     vty_out (vty, "interface %s%s", ifp->name, VTY_NEWLINE);
@@ -650,7 +637,7 @@ isis_interface_config_write (struct vty *vty)
 	write++;
       }
     /* ISIS Circuit */
-    LIST_LOOP (isis->area_list, area, node2)
+    for (ALL_LIST_ELEMENTS (isis->area_list, node2, nnode2, area))
     {
       c = circuit_lookup_by_ifp (ifp, area->circuit_list);
       if (c)
@@ -901,7 +888,7 @@ DEFUN (no_ip_router_isis,
   struct isis_circuit *circuit = NULL;
   struct interface *ifp;
   struct isis_area *area;
-  struct listnode *node;
+  struct listnode *node, *nnode;
 
   ifp = (struct interface *) vty->index;
   assert (ifp);
@@ -912,7 +899,7 @@ DEFUN (no_ip_router_isis,
       vty_out (vty, "Can't find ISIS instance %s", VTY_NEWLINE);
       return CMD_WARNING;
     }
-  LIST_LOOP (area->circuit_list, circuit, node)
+  for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
     if (circuit->interface == ifp)
       break;
   if (!circuit)

+ 6 - 13
isisd/isis_dr.c

@@ -130,7 +130,7 @@ int
 isis_dr_elect (struct isis_circuit *circuit, int level)
 {
   struct list *adjdb;
-  struct listnode *node;
+  struct listnode *node, *nnode;
   struct isis_adjacency *adj, *adj_dr = NULL;
   struct list *list = list_new ();
   u_char own_prio;
@@ -152,9 +152,8 @@ isis_dr_elect (struct isis_circuit *circuit, int level)
   /*
    * Loop the adjacencies and find the one with the biggest priority
    */
-  for (node = listhead (list); node; nextnode (node))
+  for (ALL_LIST_ELEMENTS (list, node, nnode, adj))
     {
-      adj = getdata (node);
       /* clear flag for show output */
       adj->dis_record[level - 1].dis = ISIS_IS_NOT_DIS;
       adj->dis_record[level - 1].last_dis_change = time (NULL);
@@ -215,11 +214,8 @@ isis_dr_elect (struct isis_circuit *circuit, int level)
 	   */
 
 	  /* rotate the history log */
-	  for (node = listhead (list); node; nextnode (node))
-	    {
-	      adj = getdata (node);
-	      isis_check_dr_change (adj, level);
-	    }
+	  for (ALL_LIST_ELEMENTS (list, node, nnode, adj))
+            isis_check_dr_change (adj, level);
 
 	  /* commence */
 	  list_delete (list);
@@ -238,11 +234,8 @@ isis_dr_elect (struct isis_circuit *circuit, int level)
        * if yes rotate the history log
        */
 
-      for (node = listhead (list); node; nextnode (node))
-	{
-	  adj = getdata (node);
-	  isis_check_dr_change (adj, level);
-	}
+      for (ALL_LIST_ELEMENTS (list, node, nnode, adj))
+        isis_check_dr_change (adj, level);
 
       /*
        * We are not DR - if we were -> resign

+ 4 - 8
isisd/isis_dynhn.c

@@ -60,12 +60,9 @@ dynhn_find_by_id (u_char * id)
   struct listnode *node = NULL;
   struct isis_dynhn *dyn = NULL;
 
-  for (node = listhead (dyn_cache); node; nextnode (node))
-    {
-      dyn = getdata (node);
-      if (memcmp (dyn->id, id, ISIS_SYS_ID_LEN) == 0)
-	return dyn;
-    }
+  for (ALL_LIST_ELEMENTS_RO (dyn_cache, node, dyn))
+    if (memcmp (dyn->id, id, ISIS_SYS_ID_LEN) == 0)
+      return dyn;
 
   return NULL;
 }
@@ -114,9 +111,8 @@ dynhn_print_all (struct vty *vty)
   struct isis_dynhn *dyn;
 
   vty_out (vty, "Level  System ID      Dynamic Hostname%s", VTY_NEWLINE);
-  for (node = listhead (dyn_cache); node; nextnode (node))
+  for (ALL_LIST_ELEMENTS_RO (dyn_cache, node, dyn))
     {
-      dyn = getdata (node);
       vty_out (vty, "%-7d", dyn->level);
       vty_out (vty, "%-15s%-15s%s", sysid_print (dyn->id), dyn->name.name,
 	       VTY_NEWLINE);

+ 3 - 6
isisd/isis_events.c

@@ -88,7 +88,7 @@ isis_event_circuit_state_change (struct isis_circuit *circuit, int up)
 void
 isis_event_system_type_change (struct isis_area *area, int newtype)
 {
-  struct listnode *node;
+  struct listnode *node, *nnode;
   struct isis_circuit *circuit;
 
   if (isis->debugs & DEBUG_EVENTS)
@@ -125,11 +125,8 @@ isis_event_system_type_change (struct isis_area *area, int newtype)
     }
 
   area->is_type = newtype;
-  for (node = listhead (area->circuit_list); node; nextnode (node))
-    {
-      circuit = getdata (node);
-      isis_event_circuit_type_change (circuit, newtype);
-    }
+  for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
+    isis_event_circuit_type_change (circuit, newtype);
 
   spftree_area_init (area);
   lsp_regenerate_schedule (area);

+ 1 - 1
isisd/isis_flags.c

@@ -43,7 +43,7 @@ flags_get_index (struct flags *flags)
   else
     {
       node = listhead (flags->free_idcs);
-      index = (int) getdata (node);
+      index = (int) listgetdata (node);
       listnode_delete (flags->free_idcs, (void *) index);
     }
 

+ 42 - 58
isisd/isis_lsp.c

@@ -187,12 +187,11 @@ static void
 lsp_remove_frags (struct list *frags, dict_t * lspdb)
 {
   dnode_t *dnode;
-  struct listnode *lnode;
+  struct listnode *lnode, *lnnode;
   struct isis_lsp *lsp;
 
-  for (lnode = listhead (frags); lnode; nextnode (lnode))
+  for (ALL_LIST_ELEMENTS (frags, lnode, lnnode, lsp))
     {
-      lsp = getdata (lnode);
       dnode = dict_lookup (lspdb, lsp->lsp_header->lsp_id);
       lsp_destroy (lsp);
       dnode_destroy (dict_delete (lspdb, dnode));
@@ -325,18 +324,15 @@ static void
 lsp_seqnum_update (struct isis_lsp *lsp0)
 {
   struct isis_lsp *lsp;
-  struct listnode *node;
+  struct listnode *node, *nnode;
 
   lsp_inc_seqnum (lsp0, 0);
 
   if (!lsp0->lspu.frags)
     return;
 
-  for (node = listhead (lsp0->lspu.frags); node; nextnode (node))
-    {
-      lsp = getdata (node);
-      lsp_inc_seqnum (lsp, 0);
-    }
+  for (ALL_LIST_ELEMENTS (lsp0->lspu.frags, node, nnode, lsp))
+    lsp_inc_seqnum (lsp, 0);
 
   return;
 }
@@ -717,7 +713,7 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
   struct isis_lsp *lsp = dnode_get (node);
   struct area_addr *area_addr;
   int i;
-  struct listnode *lnode;
+  struct listnode *lnode, *lnnode;
   struct is_neigh *is_neigh;
   struct te_is_neigh *te_is_neigh;
   struct ipv4_reachability *ipv4_reach;
@@ -739,15 +735,14 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
 
   /* for all area address */
   if (lsp->tlv_data.area_addrs)
-    {
-      LIST_LOOP (lsp->tlv_data.area_addrs, area_addr, lnode)
+    for (ALL_LIST_ELEMENTS (lsp->tlv_data.area_addrs, lnode, 
+                            lnnode, area_addr))
       {
 	vty_out (vty, "  Area Address: %s%s",
 		 isonet_print (area_addr->area_addr, area_addr->addr_len),
 		 VTY_NEWLINE);
       }
-    }
-
+  
   /* for the nlpid tlv */
   if (lsp->tlv_data.nlpids)
     {
@@ -777,13 +772,12 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
     }
 
   if (lsp->tlv_data.ipv4_addrs)
-    {
-      LIST_LOOP (lsp->tlv_data.ipv4_addrs, ipv4_addr, lnode)
+    for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv4_addrs, lnode, 
+                            lnnode, ipv4_addr))
       {
 	memcpy (ipv4_address, inet_ntoa (*ipv4_addr), sizeof (ipv4_address));
 	vty_out (vty, "  IP:        %s%s", ipv4_address, VTY_NEWLINE);
       }
-    }
 
   /* TE router id */
   if (lsp->tlv_data.router_id)
@@ -795,18 +789,17 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
 
   /* for the IS neighbor tlv */
   if (lsp->tlv_data.is_neighs)
-    {
-      LIST_LOOP (lsp->tlv_data.is_neighs, is_neigh, lnode)
+    for (ALL_LIST_ELEMENTS (lsp->tlv_data.is_neighs, lnode, lnnode, is_neigh))
       {
 	lspid_print (is_neigh->neigh_id, LSPid, dynhost, 0);
 	vty_out (vty, "  Metric: %d IS %s%s",
 		 is_neigh->metrics.metric_default, LSPid, VTY_NEWLINE);
       }
-    }
   
   /* for the internal reachable tlv */
   if (lsp->tlv_data.ipv4_int_reachs)
-    LIST_LOOP (lsp->tlv_data.ipv4_int_reachs, ipv4_reach, lnode)
+    for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv4_int_reachs, lnode, 
+                            lnnode, ipv4_reach))
     {
       memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix),
 	      sizeof (ipv4_reach_prefix));
@@ -819,7 +812,8 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
 
   /* for the external reachable tlv */
   if (lsp->tlv_data.ipv4_ext_reachs)
-    LIST_LOOP (lsp->tlv_data.ipv4_ext_reachs, ipv4_reach, lnode)
+    for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv4_ext_reachs, lnode, 
+                            lnnode, ipv4_reach))
     {
       memcpy (ipv4_reach_prefix, inet_ntoa (ipv4_reach->prefix),
 	      sizeof (ipv4_reach_prefix));
@@ -829,11 +823,12 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
 	       ipv4_reach->metrics.metric_default, ipv4_reach_prefix,
 	       ipv4_reach_mask, VTY_NEWLINE);
     }
-
+  
   /* IPv6 tlv */
 #ifdef HAVE_IPV6
   if (lsp->tlv_data.ipv6_reachs)
-    LIST_LOOP (lsp->tlv_data.ipv6_reachs, ipv6_reach, lnode)
+    for (ALL_LIST_ELEMENTS (lsp->tlv_data.ipv6_reachs, lnode, 
+                            lnnode, ipv6_reach))
     {
       memset (&in6, 0, sizeof (in6));
       memcpy (in6.s6_addr, ipv6_reach->prefix,
@@ -850,9 +845,11 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
 		 buff, ipv6_reach->prefix_len, VTY_NEWLINE);
     }
 #endif
+
   /* TE IS neighbor tlv */
   if (lsp->tlv_data.te_is_neighs)
-    LIST_LOOP (lsp->tlv_data.te_is_neighs, te_is_neigh, lnode)
+    for (ALL_LIST_ELEMENTS (lsp->tlv_data.te_is_neighs, lnode, 
+                            lnnode, te_is_neigh))
     {
       /* FIXME: metric display is wrong. */
       lspid_print (te_is_neigh->neigh_id, LSPid, dynhost, 0);
@@ -862,7 +859,8 @@ lsp_print_detail (dnode_t * node, struct vty *vty, char dynhost)
 
   /* TE IPv4 tlv */
   if (lsp->tlv_data.te_ipv4_reachs)
-    LIST_LOOP (lsp->tlv_data.te_ipv4_reachs, te_ipv4_reach, lnode)
+    for (ALL_LIST_ELEMENTS (lsp->tlv_data.te_ipv4_reachs, lnode, 
+                            lnnode, te_ipv4_reach))
     {
       /* FIXME: There should be better way to output this stuff. */
       vty_out (vty, "  Metric: %d extd-IP %s/%d%s",
@@ -949,7 +947,7 @@ void
 lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
 {
   struct is_neigh *is_neigh;
-  struct listnode *node, *ipnode;
+  struct listnode *node, *nnode, *ipnode, *ipnnode;
   int level = lsp->level;
   struct isis_circuit *circuit;
   struct prefix_ipv4 *ipv4;
@@ -1027,9 +1025,8 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
   /*
    * Then add tlvs related to circuits
    */
-  for (node = listhead (area->circuit_list); node; nextnode (node))
+  for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
     {
-      circuit = getdata (node);
       if (circuit->state != C_STATE_UP)
 	continue;
 
@@ -1044,10 +1041,8 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
 	      lsp->tlv_data.ipv4_int_reachs = list_new ();
 	      lsp->tlv_data.ipv4_int_reachs->del = free_tlv;
 	    }
-	  for (ipnode = listhead (circuit->ip_addrs); ipnode;
-	       nextnode (ipnode))
+          for (ALL_LIST_ELEMENTS (circuit->ip_addrs, ipnode, ipnnode, ipv4))
 	    {
-	      ipv4 = getdata (ipnode);
 	      ipreach =
 		XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
 	      ipreach->metrics = circuit->metrics[level - 1];
@@ -1068,10 +1063,9 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
 	      lsp->tlv_data.ipv6_reachs = list_new ();
 	      lsp->tlv_data.ipv6_reachs->del = free_tlv;
 	    }
-	  for (ipnode = listhead (circuit->ipv6_non_link); ipnode;
-	       nextnode (ipnode))
+          for (ALL_LIST_ELEMENTS (circuit->ipv6_non_link, ipnode, 
+                                  ipnnode, ipv6))
 	    {
-	      ipv6 = getdata (ipnode);
 	      ip6reach =
 		XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
 	      memset (ip6reach, 0, sizeof (struct ipv6_reachability));
@@ -1192,8 +1186,8 @@ lsp_tlv_fit (struct isis_lsp *lsp, struct list **from, struct list **to,
 	count = count / tlvsize;
       for (i = 0; i < count; i++)
 	{
-	  listnode_add (*to, getdata (listhead (*from)));
-	  listnode_delete (*from, getdata (listhead (*from)));
+	  listnode_add (*to, listgetdata (listhead (*from)));
+	  listnode_delete (*from, listgetdata (listhead (*from)));
 	}
       tlv_build_func (*to, lsp->pdu);
     }
@@ -1256,7 +1250,7 @@ static void
 lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
 {
   struct is_neigh *is_neigh;
-  struct listnode *node, *ipnode;
+  struct listnode *node, *nnode, *ipnode, *ipnnode;
   int level = lsp->level;
   struct isis_circuit *circuit;
   struct prefix_ipv4 *ipv4;
@@ -1360,9 +1354,8 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
   /*
    * Then build lists of tlvs related to circuits
    */
-  for (node = listhead (area->circuit_list); node; nextnode (node))
+  for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit))
     {
-      circuit = getdata (node);
       if (circuit->state != C_STATE_UP)
 	continue;
 
@@ -1376,10 +1369,8 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
 	    {
 	      tlv_data.ipv4_int_reachs = list_new ();
 	    }
-	  for (ipnode = listhead (circuit->ip_addrs); ipnode;
-	       nextnode (ipnode))
+          for (ALL_LIST_ELEMENTS (circuit->ip_addrs, ipnode, ipnnode, ipv4))
 	    {
-	      ipv4 = getdata (ipnode);
 	      ipreach =
 		XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv4_reachability));
 	      ipreach->metrics = circuit->metrics[level - 1];
@@ -1402,10 +1393,9 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area)
 	    {
 	      tlv_data.ipv6_reachs = list_new ();
 	    }
-	  for (ipnode = listhead (circuit->ipv6_non_link); ipnode;
-	       nextnode (ipnode))
+          for (ALL_LIST_ELEMENTS (circuit->ipv6_non_link, ipnode, ipnnode,
+                                  ipv6))
 	    {
-	      ipv6 = getdata (ipnode);
 	      ip6reach =
 		XMALLOC (MTYPE_ISIS_TLV, sizeof (struct ipv6_reachability));
 	      memset (ip6reach, 0, sizeof (struct ipv6_reachability));
@@ -1696,9 +1686,8 @@ lsp_non_pseudo_regenerate (struct isis_area *area, int level)
   lsp->last_generated = time (NULL);
   area->lsp_regenerate_pending[level - 1] = 0;
   ISIS_FLAGS_SET_ALL (lsp->SRMflags);
-  for (node = listhead (lsp->lspu.frags); node; nextnode (node))
+  for (ALL_LIST_ELEMENTS_RO (lsp->lspu.frags, node, frag))
     {
-      frag = getdata (node);
       frag->lsp_header->rem_lifetime = htons (isis_jitter
 					      (area->
 					       max_lsp_lifetime[level - 1],
@@ -1862,7 +1851,7 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit,
   struct is_neigh *is_neigh;
   struct es_neigh *es_neigh;
   struct list *adj_list;
-  struct listnode *node;
+  struct listnode *node, *nnode;
   struct isis_passwd *passwd;
 
   assert (circuit);
@@ -1893,9 +1882,8 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit,
   adj_list = list_new ();
   isis_adj_build_up_list (circuit->u.bc.adjdb[level - 1], adj_list);
 
-  for (node = listhead (adj_list); node; nextnode (node))
+  for (ALL_LIST_ELEMENTS (adj_list, node, nnode, adj))
     {
-      adj = getdata (node);
       if (adj->circuit_t & level)
 	{
 	  if ((level == 1 && adj->sys_type == ISIS_SYSTYPE_L1_IS) ||
@@ -2127,7 +2115,7 @@ lsp_tick (struct thread *thread)
   struct isis_circuit *circuit;
   struct isis_lsp *lsp;
   struct list *lsp_list;
-  struct listnode *lspnode, *cnode;
+  struct listnode *lspnode, *lspnnode, *cnode;
   dnode_t *dnode, *dnode_next;
   int level;
 
@@ -2174,14 +2162,10 @@ lsp_tick (struct thread *thread)
 	   */
 	  if (listcount (lsp_list) > 0)
 	    {
-	      for (cnode = listhead (area->circuit_list); cnode;
-		   nextnode (cnode))
+              for (ALL_LIST_ELEMENTS_RO (area->circuit_list, cnode, circuit))
 		{
-		  circuit = getdata (cnode);
-		  for (lspnode = listhead (lsp_list); lspnode;
-		       nextnode (lspnode))
+                  for (ALL_LIST_ELEMENTS (lsp_list, lspnode, lspnnode, lsp))
 		    {
-		      lsp = getdata (lspnode);
 		      if (ISIS_CHECK_FLAG (lsp->SRMflags, circuit))
 			{
 			  /* FIXME: if same or elder lsp is already in lsp

+ 31 - 34
isisd/isis_pdu.c

@@ -80,11 +80,12 @@ static int
 area_match (struct list *left, struct list *right)
 {
   struct area_addr *addr1, *addr2;
-  struct listnode *node1, *node2;
+  struct listnode *node1, *nnode1;
+  struct listnode *node2, *nnode2;
 
-  LIST_LOOP (left, addr1, node1)
+  for (ALL_LIST_ELEMENTS (left, node1, nnode1, addr1))
   {
-    LIST_LOOP (right, addr2, node2)
+    for (ALL_LIST_ELEMENTS (right, node2, nnode2, addr2))
     {
       if (addr1->addr_len == addr2->addr_len &&
 	  !memcmp (addr1->area_addr, addr2->area_addr, (int) addr1->addr_len))
@@ -139,14 +140,15 @@ ip_match (struct list *left, struct list *right)
 {
   struct prefix_ipv4 *ip1;
   struct in_addr *ip2;
-  struct listnode *node1, *node2;
+  struct listnode *node1, *nnode1;
+  struct listnode *node2, *nnode2;
 
   if ((left == NULL) || (right == NULL))
     return 0;
   
-  LIST_LOOP (left, ip1, node1)
+  for (ALL_LIST_ELEMENTS (left, node1, nnode1, ip1))
   {
-    LIST_LOOP (right, ip2, node2)
+    for (ALL_LIST_ELEMENTS (right, node2, nnode2, ip2))
     {
       if (ip_same_subnet (ip1, ip2))
 	{
@@ -223,7 +225,7 @@ del_ip_addr (void *val)
 static void
 tlvs_to_adj_ipv4_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
 {
-  struct listnode *node;
+  struct listnode *node, *nnode;
   struct in_addr *ipv4_addr, *malloced;
 
   if (adj->ipv4_addrs)
@@ -234,7 +236,7 @@ tlvs_to_adj_ipv4_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
   adj->ipv4_addrs = list_new ();
   if (tlvs->ipv4_addrs)
     {
-      LIST_LOOP (tlvs->ipv4_addrs, ipv4_addr, node)
+      for (ALL_LIST_ELEMENTS (tlvs->ipv4_addrs, node, nnode, ipv4_addr))
       {
 	malloced = XMALLOC (MTYPE_ISIS_TMP, sizeof (struct in_addr));
 	memcpy (malloced, ipv4_addr, sizeof (struct in_addr));
@@ -247,7 +249,7 @@ tlvs_to_adj_ipv4_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
 static void
 tlvs_to_adj_ipv6_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
 {
-  struct listnode *node;
+  struct listnode *node, *nnode;
   struct in6_addr *ipv6_addr, *malloced;
 
   if (adj->ipv6_addrs)
@@ -258,7 +260,7 @@ tlvs_to_adj_ipv6_addrs (struct tlvs *tlvs, struct isis_adjacency *adj)
   adj->ipv6_addrs = list_new ();
   if (tlvs->ipv6_addrs)