diff options
author | paul <paul> | 2005-04-07 07:30:20 +0000 |
---|---|---|
committer | paul <paul> | 2005-04-07 07:30:20 +0000 |
commit | 1eb8ef2584833f18fb674e127d59cb5a7f771482 (patch) | |
tree | f5b09d4781de9a9b08839fefb6530e64d2d2ec31 /zebra/interface.c | |
parent | 5920990fecba7e2430af3cfaa8bcbaed40d0ba1a (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/interface.c')
-rw-r--r-- | zebra/interface.c | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/zebra/interface.c b/zebra/interface.c index 0f294a56..bd31fb40 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -170,7 +170,7 @@ if_subnet_delete (struct interface *ifp, struct connected *ifc) /* If deleted address is primary, mark subsequent one as such and distribute. */ if (! CHECK_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY)) { - ifc = (struct connected *) addr_list->head->data; + ifc = listgetdata (listhead (addr_list)); zebra_interface_address_delete_update (ifp, ifc); UNSET_FLAG (ifc->flags, ZEBRA_IFA_SECONDARY); zebra_interface_address_add_update (ifp, ifc); @@ -192,14 +192,13 @@ if_subnet_delete (struct interface *ifp, struct connected *ifc) void if_addr_wakeup (struct interface *ifp) { - struct listnode *node; + struct listnode *node, *nnode; struct connected *ifc; struct prefix *p; int ret; - for (node = listhead (ifp->connected); node; nextnode (node)) + for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, ifc)) { - ifc = getdata (node); p = ifc->address; if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED) @@ -334,7 +333,7 @@ if_delete_update (struct interface *ifp) last = NULL; while ((node = (last ? last->next : listhead (ifp->connected)))) { - ifc = getdata (node); + ifc = listgetdata (node); p = ifc->address; if (p->family == AF_INET) @@ -354,7 +353,7 @@ if_delete_update (struct interface *ifp) } next = node->next; - ifc = getdata (node); + ifc = listgetdata (node); p = ifc->address; connected_down_ipv4 (ifp, ifc); @@ -423,10 +422,8 @@ if_up (struct interface *ifp) /* Install connected routes to the kernel. */ if (ifp->connected) { - for (node = listhead (ifp->connected); node; node = next) + for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc)) { - next = node->next; - ifc = getdata (node); p = ifc->address; if (p->family == AF_INET) @@ -458,10 +455,8 @@ if_down (struct interface *ifp) /* Delete connected routes from the kernel. */ if (ifp->connected) { - for (node = listhead (ifp->connected); node; node = next) + for (ALL_LIST_ELEMENTS (ifp->connected, node, next, ifc)) { - next = node->next; - ifc = getdata (node); p = ifc->address; if (p->family == AF_INET) @@ -727,16 +722,12 @@ if_dump_vty (struct vty *vty, struct interface *ifp) if (! rn->info) continue; - for (node = listhead ((struct list *) rn->info); node; nextnode (node)) - { - connected = getdata (node); - connected_dump_vty (vty, connected); - } + for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, connected)) + connected_dump_vty (vty, connected); } - for (node = listhead (ifp->connected); node; nextnode (node)) + for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected)) { - connected = getdata (node); if (CHECK_FLAG (connected->conf, ZEBRA_IFC_REAL) && (connected->address->family == AF_INET6)) connected_dump_vty (vty, connected); @@ -902,8 +893,8 @@ DEFUN (show_interface, show_interface_cmd, } /* All interface print. */ - for (node = listhead (iflist); node; nextnode (node)) - if_dump_vty (vty, getdata (node)); + for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) + if_dump_vty (vty, ifp); return CMD_SUCCESS; } @@ -919,10 +910,9 @@ DEFUN (show_interface_desc, struct interface *ifp; vty_out (vty, "Interface Status Protocol Description%s", VTY_NEWLINE); - for (node = listhead (iflist); node; nextnode (node)) + for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) { int len; - ifp = getdata (node); len = vty_out (vty, "%s", ifp->name); vty_out (vty, "%*s", (16 - len), " "); @@ -1514,14 +1504,13 @@ if_config_write (struct vty *vty) struct interface *ifp; char buf[BUFSIZ]; - for (node = listhead (iflist); node; nextnode (node)) + for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp)) { struct zebra_if *if_data; struct listnode *addrnode; struct connected *ifc; struct prefix *p; - ifp = getdata (node); if_data = ifp->info; vty_out (vty, "interface %s%s", ifp->name, @@ -1539,9 +1528,8 @@ if_config_write (struct vty *vty) if (CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)) vty_out(vty, " link-detect%s", VTY_NEWLINE); - for (addrnode = listhead (ifp->connected); addrnode; nextnode (addrnode)) + for (ALL_LIST_ELEMENTS_RO (ifp->connected, addrnode, ifc)) { - ifc = getdata (addrnode); if (CHECK_FLAG (ifc->conf, ZEBRA_IFC_CONFIGURED)) { p = ifc->address; |