summaryrefslogtreecommitdiff
path: root/zebra/redistribute.c
diff options
context:
space:
mode:
authorpaul <paul>2005-04-07 07:30:20 +0000
committerpaul <paul>2005-04-07 07:30:20 +0000
commit1eb8ef2584833f18fb674e127d59cb5a7f771482 (patch)
treef5b09d4781de9a9b08839fefb6530e64d2d2ec31 /zebra/redistribute.c
parent5920990fecba7e2430af3cfaa8bcbaed40d0ba1a (diff)
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.
Diffstat (limited to 'zebra/redistribute.c')
-rw-r--r--zebra/redistribute.c142
1 files changed, 68 insertions, 74 deletions
diff --git a/zebra/redistribute.c b/zebra/redistribute.c
index 949159de..dff6cb54 100644
--- a/zebra/redistribute.c
+++ b/zebra/redistribute.c
@@ -169,71 +169,71 @@ zebra_redistribute (struct zserv *client, int type)
void
redistribute_add (struct prefix *p, struct rib *rib)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- {
- if (is_default (p))
- {
- if (client->redist_default || client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ {
+ if (is_default (p))
+ {
+ if (client->redist_default || client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
#endif /* HAVE_IPV6 */
- }
- }
- else if (client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
+ }
+ }
+ else if (client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_ADD, client, p, rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_ADD, client, p, rib);
#endif /* HAVE_IPV6 */
- }
- }
+ }
+ }
}
void
redistribute_delete (struct prefix *p, struct rib *rib)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
/* Add DISTANCE_INFINITY check. */
if (rib->distance == DISTANCE_INFINITY)
return;
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- {
- if (is_default (p))
- {
- if (client->redist_default || client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ {
+ if (is_default (p))
+ {
+ if (client->redist_default || client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p,
+ rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib);
-#endif /* HAVE_IPV6 */
- }
- }
- else if (client->redist[rib->type])
- {
- if (p->family == AF_INET)
- zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib);
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p,
+ rib);
+#endif /* HAVE_IPV6 */
+ }
+ }
+ else if (client->redist[rib->type])
+ {
+ if (p->family == AF_INET)
+ zsend_route_multipath (ZEBRA_IPV4_ROUTE_DELETE, client, p, rib);
#ifdef HAVE_IPV6
- if (p->family == AF_INET6)
- zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib);
-#endif /* HAVE_IPV6 */
- }
- }
+ if (p->family == AF_INET6)
+ zsend_route_multipath (ZEBRA_IPV6_ROUTE_DELETE, client, p, rib);
+#endif /* HAVE_IPV6 */
+ }
+ }
}
void
@@ -306,46 +306,43 @@ zebra_redistribute_default_delete (int command, struct zserv *client,
void
zebra_interface_up_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_UP %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_interface_update (ZEBRA_INTERFACE_UP, client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ zsend_interface_update (ZEBRA_INTERFACE_UP, client, ifp);
}
/* Interface down information. */
void
zebra_interface_down_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_DOWN %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- zsend_interface_update (ZEBRA_INTERFACE_DOWN, client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ zsend_interface_update (ZEBRA_INTERFACE_DOWN, client, ifp);
}
/* Interface information update. */
void
zebra_interface_add_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_ADD %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo)
- zsend_interface_add (client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo)
+ zsend_interface_add (client, ifp);
}
/*
@@ -357,16 +354,15 @@ zebra_interface_add_update (struct interface *ifp)
void
zebra_interface_delete_update (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
if (IS_ZEBRA_DEBUG_EVENT)
zlog_debug ("MESSAGE: ZEBRA_INTERFACE_DELETE %s", ifp->name);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo)
- zsend_interface_delete (client, ifp);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo)
+ zsend_interface_delete (client, ifp);
}
#endif /* defined(RTM_IFANNOUNCE) || defined(HAVE_NETLINK) */
@@ -375,7 +371,7 @@ void
zebra_interface_address_add_update (struct interface *ifp,
struct connected *ifc)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
struct prefix *p;
char buf[BUFSIZ];
@@ -390,10 +386,9 @@ zebra_interface_address_add_update (struct interface *ifp,
router_id_add_address(ifc);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
- zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client, ifp, ifc);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
+ zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_ADD, client, ifp, ifc);
}
/* Interface address deletion. */
@@ -401,7 +396,7 @@ void
zebra_interface_address_delete_update (struct interface *ifp,
struct connected *ifc)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct zserv *client;
struct prefix *p;
char buf[BUFSIZ];
@@ -416,8 +411,7 @@ zebra_interface_address_delete_update (struct interface *ifp,
router_id_del_address(ifc);
- for (node = listhead (zebrad.client_list); node; nextnode (node))
- if ((client = getdata (node)) != NULL)
- if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
- zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_DELETE, client, ifp, ifc);
+ for (ALL_LIST_ELEMENTS (zebrad.client_list, node, nnode, client))
+ if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
+ zsend_interface_address (ZEBRA_INTERFACE_ADDRESS_DELETE, client, ifp, ifc);
}