summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_te.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 /ospfd/ospf_te.c
parent5920990fecba7e2430af3cfaa8bcbaed40d0ba1a (diff)
downloadquagga-1eb8ef2584833f18fb674e127d59cb5a7f771482.tar.bz2
quagga-1eb8ef2584833f18fb674e127d59cb5a7f771482.tar.xz
2005-04-07 Paul Jakma <paul.jakma@sun.com>quagga_post_listloop_cleanup
* (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 'ospfd/ospf_te.c')
-rw-r--r--ospfd/ospf_te.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 0b04c969..582dc433 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -252,10 +252,10 @@ out:
static struct mpls_te_link *
lookup_linkparams_by_ifp (struct interface *ifp)
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
if (lp->ifp == ifp)
return lp;
@@ -269,7 +269,7 @@ lookup_linkparams_by_instance (struct ospf_lsa *lsa)
struct mpls_te_link *lp;
unsigned int key = GET_OPAQUE_ID (ntohl (lsa->data->id.s_addr));
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS_RO (OspfMplsTE.iflist, node, lp))
if (lp->instance == key)
return lp;
@@ -282,11 +282,12 @@ ospf_mpls_te_foreach_area (
void (*func)(struct mpls_te_link *lp, enum sched_opcode),
enum sched_opcode sched_opcode)
{
- struct listnode *node, *node2;
+ struct listnode *node, *nnode;
+ struct listnode *node2;
struct mpls_te_link *lp;
struct ospf_area *area;
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
if ((area = lp->area) == NULL)
continue;
@@ -296,14 +297,14 @@ ospf_mpls_te_foreach_area (
if (func != NULL)
(* func)(lp, sched_opcode);
- for (node2 = nextnode (node); node2; nextnode (node2))
- if ((lp = getdata (node2)) != NULL)
+ for (node2 = listnextnode (node); node2; node2 = listnextnode (node2))
+ if ((lp = listgetdata (node2)) != NULL)
if (lp->area != NULL)
if (IPV4_ADDR_SAME (&lp->area->area_id, &area->area_id))
lp->flags |= LPFLG_LOOKUP_DONE;
}
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS_RO (OspfMplsTE.iflist, node, lp))
if (lp->area != NULL)
lp->flags &= ~LPFLG_LOOKUP_DONE;
@@ -965,7 +966,7 @@ static int
ospf_mpls_te_lsa_originate (void *arg)
{
struct ospf_area *area = (struct ospf_area *) arg;
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
int rc = -1;
@@ -976,10 +977,8 @@ ospf_mpls_te_lsa_originate (void *arg)
goto out;
}
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
- if ((lp = getdata (node)) == NULL)
- continue;
if (lp->area == NULL)
continue;
if (! IPV4_ADDR_SAME (&lp->area->area_id, &area->area_id))
@@ -1471,7 +1470,7 @@ DEFUN (mpls_te,
"Configure MPLS-TE parameters\n"
"Enable the MPLS-TE functionality\n")
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
if (OspfMplsTE.status == enabled)
@@ -1488,9 +1487,8 @@ DEFUN (mpls_te,
* 1) MPLS-TE was disabled at startup time, but now become enabled.
* 2) MPLS-TE was once enabled then disabled, and now enabled again.
*/
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- if ((lp = getdata (node)) != NULL)
- initialize_linkparams (lp);
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
+ initialize_linkparams (lp);
ospf_mpls_te_foreach_area (ospf_mpls_te_lsa_schedule, REORIGINATE_PER_AREA);
@@ -1510,7 +1508,7 @@ DEFUN (no_mpls_te,
"Configure MPLS-TE parameters\n"
"Disable the MPLS-TE functionality\n")
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
if (OspfMplsTE.status == disabled)
@@ -1521,11 +1519,10 @@ DEFUN (no_mpls_te,
OspfMplsTE.status = disabled;
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- if ((lp = getdata (node)) != NULL)
- if (lp->area != NULL)
- if (lp->flags & LPFLG_LSA_ENGAGED)
- ospf_mpls_te_lsa_schedule (lp, FLUSH_THIS_LSA);
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
+ if (lp->area != NULL)
+ if (lp->flags & LPFLG_LSA_ENGAGED)
+ ospf_mpls_te_lsa_schedule (lp, FLUSH_THIS_LSA);
return CMD_SUCCESS;
}
@@ -1549,7 +1546,7 @@ DEFUN (mpls_te_router_addr,
if (ntohs (ra->header.type) == 0
|| ntohl (ra->value.s_addr) != ntohl (value.s_addr))
{
- struct listnode *node;
+ struct listnode *node, *nnode;
struct mpls_te_link *lp;
int need_to_reoriginate = 0;
@@ -1558,7 +1555,7 @@ DEFUN (mpls_te_router_addr,
if (OspfMplsTE.status == disabled)
goto out;
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
if (lp->area == NULL)
continue;
@@ -1569,8 +1566,8 @@ DEFUN (mpls_te_router_addr,
break;
}
}
- for (node = listhead (OspfMplsTE.iflist); node; nextnode (node))
- LIST_LOOP (OspfMplsTE.iflist, lp, node)
+
+ for (ALL_LIST_ELEMENTS (OspfMplsTE.iflist, node, nnode, lp))
{
if (lp->area == NULL)
continue;
@@ -1868,13 +1865,13 @@ DEFUN (show_mpls_te_link,
"Interface name\n")
{
struct interface *ifp;
- struct listnode *node;
+ struct listnode *node, *nnode;
/* Show All Interfaces. */
if (argc == 0)
{
- LIST_LOOP (iflist, ifp, node)
- show_mpls_te_link_sub (vty, ifp);
+ for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+ show_mpls_te_link_sub (vty, ifp);
}
/* Interface name is specified. */
else