Add IFNET_FOREACH and IFADDR_FOREACH macros and start using them.

This commit is contained in:
matt 2005-01-24 21:25:09 +00:00
parent 4d1829e17f
commit 027c11539b
16 changed files with 58 additions and 55 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_route.c,v 1.8 2004/11/07 04:08:37 david Exp $ */
/* $NetBSD: darwin_route.c,v 1.9 2005/01/24 21:25:09 matt Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_route.c,v 1.8 2004/11/07 04:08:37 david Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_route.c,v 1.9 2005/01/24 21:25:09 matt Exp $");
#include <sys/errno.h>
#include <sys/systm.h>
@ -66,7 +66,7 @@ darwin_ifaddrs(af, dst, sizep)
af = darwin_to_native_af[af];
TAILQ_FOREACH(ifp, &ifnet, if_list) {
IFNET_FOREACH(ifp) {
struct ifaddr *ifa;
struct sockaddr_dl *laddr = NULL;
struct sockaddr_storage dladdr;
@ -75,7 +75,7 @@ darwin_ifaddrs(af, dst, sizep)
* Find the link layer info as it is needed
* for computing darwin_if_msghdr's dim_len
*/
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, ifp) {
if ((ifa->ifa_addr) &&
(ifa->ifa_addr->sa_family == AF_LINK)) {
laddr = (struct sockaddr_dl *)ifa->ifa_addr;
@ -144,7 +144,7 @@ darwin_ifaddrs(af, dst, sizep)
dst += ALIGN(dladdr.ss_len);
}
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, ifp) {
struct darwin_ifa_msghdr diam;
int iaf;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_bge.c,v 1.80 2005/01/08 16:00:03 fredb Exp $ */
/* $NetBSD: if_bge.c,v 1.81 2005/01/24 21:25:09 matt Exp $ */
/*
* Copyright (c) 2001 Wind River Systems
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.80 2005/01/08 16:00:03 fredb Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.81 2005/01/24 21:25:09 matt Exp $");
#include "bpfilter.h"
#include "vlan.h"
@ -675,7 +675,7 @@ bge_update_all_threshes(int lvl)
/*
* Now search all the interfaces for this name/number
*/
TAILQ_FOREACH(ifp, &ifnet, if_list) {
IFNET_FOREACH(ifp) {
if (strncmp(ifp->if_xname, namebuf, namelen) != 0)
continue;
/* We got a match: update if doing auto-threshold-tuning */

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_dmc.c,v 1.7 2003/08/07 16:31:14 agc Exp $ */
/* $NetBSD: if_dmc.c,v 1.8 2005/01/24 21:25:09 matt Exp $ */
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_dmc.c,v 1.7 2003/08/07 16:31:14 agc Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_dmc.c,v 1.8 2005/01/24 21:25:09 matt Exp $");
#undef DMCDEBUG /* for base table dump on fatal error */
@ -313,7 +313,7 @@ dmcinit(struct ifnet *ifp)
* Check to see that an address has been set
* (both local and destination for an address family).
*/
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
IFADDR_FOREACH(ifa, ifp)
if (ifa->ifa_addr->sa_family && ifa->ifa_dstaddr->sa_family)
break;
if (ifa == (struct ifaddr *) 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_subr.c,v 1.114 2004/10/24 17:06:24 cube Exp $ */
/* $NetBSD: kern_subr.c,v 1.115 2005/01/24 21:25:09 matt Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
@ -86,7 +86,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.114 2004/10/24 17:06:24 cube Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.115 2005/01/24 21:25:09 matt Exp $");
#include "opt_ddb.h"
#include "opt_md.h"
@ -821,7 +821,7 @@ setroot(bootdv, bootpartition)
if (vops != NULL && vops->vfs_mountroot == mountroot &&
rootspec == NULL &&
(bootdv == NULL || bootdv->dv_class != DV_IFNET)) {
TAILQ_FOREACH(ifp, &ifnet, if_list) {
IFNET_FOREACH(ifp) {
if ((ifp->if_flags &
(IFF_LOOPBACK|IFF_POINTOPOINT)) == 0)
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_uuid.c,v 1.3 2004/09/12 23:17:37 thorpej Exp $ */
/* $NetBSD: kern_uuid.c,v 1.4 2005/01/24 21:25:09 matt Exp $ */
/*
* Copyright (c) 2002 Marcel Moolenaar
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_uuid.c,v 1.3 2004/09/12 23:17:37 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_uuid.c,v 1.4 2005/01/24 21:25:09 matt Exp $");
#include <sys/param.h>
#include <sys/endian.h>
@ -104,9 +104,9 @@ uuid_node(uint16_t *node)
int i, s;
s = splnet();
TAILQ_FOREACH(ifp, &ifnet, if_list) {
IFNET_FOREACH(ifp) {
/* Walk the address list */
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, ifp) {
sdl = (struct sockaddr_dl*)ifa->ifa_addr;
if (sdl != NULL && sdl->sdl_family == AF_LINK &&
sdl->sdl_type == IFT_ETHER) {

View File

@ -384,9 +384,10 @@ m_reclaim(void *arg, int flags)
if (pr->pr_drain)
(*pr->pr_drain)();
}
TAILQ_FOREACH(ifp, &ifnet, if_list)
IFNET_FOREACH(ifp) {
if (ifp->if_drain)
(*ifp->if_drain)(ifp);
}
splx(s);
mbstat.m_drain++;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if.c,v 1.152 2005/01/23 18:41:56 matt Exp $ */
/* $NetBSD: if.c,v 1.153 2005/01/24 21:25:09 matt Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.152 2005/01/23 18:41:56 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.153 2005/01/24 21:25:09 matt Exp $");
#include "opt_inet.h"
@ -1662,7 +1662,7 @@ ifconf(cmd, data)
} else {
sign = 1;
}
TAILQ_FOREACH(ifp, &ifnet, if_list) {
IFNET_FOREACH(ifp) {
bcopy(ifp->if_xname, ifr.ifr_name, IFNAMSIZ);
if ((ifa = TAILQ_FIRST(&ifp->if_addrlist)) == 0) {
memset(&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr));

View File

@ -1,4 +1,4 @@
/* $NetBSD: if.h,v 1.99 2005/01/08 03:18:18 yamt Exp $ */
/* $NetBSD: if.h,v 1.100 2005/01/24 21:25:09 matt Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -725,11 +725,13 @@ do { \
#define IFQ_INC_DROPS(ifq) ((ifq)->ifq_drops++)
#define IFQ_SET_MAXLEN(ifq, len) ((ifq)->ifq_maxlen = (len))
#ifdef _KERNEL
#include <sys/mallocvar.h>
MALLOC_DECLARE(M_IFADDR);
MALLOC_DECLARE(M_IFMADDR);
#endif
#define IFNET_FOREACH(ifp) TAILQ_FOREACH(ifp, &ifnet, if_list)
#define IFADDR_FOREACH(ifa, ifp) TAILQ_FOREACH(ifa, \
&(ifp)->if_addrlist, ifa_list)
extern struct ifnet_head ifnet;
extern struct ifnet **ifindex2ifnet;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_spppsubr.c,v 1.80 2004/12/22 05:11:24 itojun Exp $ */
/* $NetBSD: if_spppsubr.c,v 1.81 2005/01/24 21:25:09 matt Exp $ */
/*
* Synchronous PPP/Cisco link level subroutines.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.80 2004/12/22 05:11:24 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.81 2005/01/24 21:25:09 matt Exp $");
#include "opt_inet.h"
#include "opt_ipx.h"
@ -4749,7 +4749,7 @@ sppp_get_ip_addrs(struct sppp *sp, u_int32_t *src, u_int32_t *dst, u_int32_t *sr
* aliases don't make any sense on a p2p link anyway.
*/
si = 0;
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, ifp) {
if (ifa->ifa_addr->sa_family == AF_INET) {
si = (struct sockaddr_in *)ifa->ifa_addr;
sm = (struct sockaddr_in *)ifa->ifa_netmask;
@ -4789,7 +4789,7 @@ sppp_set_ip_addrs(struct sppp *sp, u_int32_t myaddr, u_int32_t hisaddr)
* aliases don't make any sense on a p2p link anyway.
*/
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, ifp) {
if (ifa->ifa_addr->sa_family == AF_INET) {
si = (struct sockaddr_in *)ifa->ifa_addr;
dest = (struct sockaddr_in *)ifa->ifa_dstaddr;
@ -4855,7 +4855,7 @@ sppp_clear_ip_addrs(struct sppp *sp)
* aliases don't make any sense on a p2p link anyway.
*/
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, ifp) {
if (ifa->ifa_addr->sa_family == AF_INET) {
si = (struct sockaddr_in *)ifa->ifa_addr;
dest = (struct sockaddr_in *)ifa->ifa_dstaddr;
@ -4904,7 +4904,7 @@ sppp_get_ip6_addrs(struct sppp *sp, struct in6_addr *src, struct in6_addr *dst,
* aliases don't make any sense on a p2p link anyway.
*/
si = 0;
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
IFADDR_FOREACH(ifa, ifp)
if (ifa->ifa_addr->sa_family == AF_INET6) {
si = (struct sockaddr_in6 *)ifa->ifa_addr;
sm = (struct sockaddr_in6 *)ifa->ifa_netmask;
@ -4957,7 +4957,7 @@ sppp_set_ip6_addr(struct sppp *sp, const struct in6_addr *src)
*/
sin6 = NULL;
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
IFADDR_FOREACH(ifa, ifp)
{
if (ifa->ifa_addr->sa_family == AF_INET6)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_stf.c,v 1.41 2004/12/04 18:31:43 peter Exp $ */
/* $NetBSD: if_stf.c,v 1.42 2005/01/24 21:25:09 matt Exp $ */
/* $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */
/*
@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.41 2004/12/04 18:31:43 peter Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.42 2005/01/24 21:25:09 matt Exp $");
#include "opt_inet.h"
@ -316,7 +316,7 @@ stf_getsrcifa6(ifp)
struct sockaddr_in6 *sin6;
struct in_addr in;
TAILQ_FOREACH(ia, &ifp->if_addrlist, ifa_list)
IFADDR_FOREACH(ifa, ifp)
{
if (ia->ifa_addr == NULL)
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tun.c,v 1.75 2004/12/06 02:59:23 christos Exp $ */
/* $NetBSD: if_tun.c,v 1.76 2005/01/24 21:25:09 matt Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
@ -15,7 +15,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.75 2004/12/06 02:59:23 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.76 2005/01/24 21:25:09 matt Exp $");
#include "opt_inet.h"
#include "opt_ns.h"
@ -356,7 +356,7 @@ tunclose(dev, flag, mode, p)
if (ifp->if_flags & IFF_RUNNING) {
/* find internet addresses and delete routes */
struct ifaddr *ifa;
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, ifp) {
#ifdef INET
if (ifa->ifa_addr->sa_family == AF_INET) {
rtinit(ifa, (int)RTM_DELETE,
@ -393,7 +393,7 @@ tuninit(tp)
ifp->if_flags |= IFF_UP | IFF_RUNNING;
tp->tun_flags &= ~(TUN_IASET|TUN_DSTADDR);
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, ifp) {
#ifdef INET
if (ifa->ifa_addr->sa_family == AF_INET) {
struct sockaddr_in *sin;

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtsock.c,v 1.73 2005/01/23 18:41:57 matt Exp $ */
/* $NetBSD: rtsock.c,v 1.74 2005/01/24 21:25:09 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.73 2005/01/23 18:41:57 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.74 2005/01/24 21:25:09 matt Exp $");
#include "opt_inet.h"
@ -896,7 +896,7 @@ sysctl_iflist(int af, struct walkarg *w, int type)
int len, error = 0;
memset(&info, 0, sizeof(info));
TAILQ_FOREACH(ifp, &ifnet, if_list) {
IFNET_FOREACH(ifp) {
if (w->w_arg && w->w_arg != ifp->if_index)
continue;
ifa = TAILQ_FIRST(&ifp->if_addrlist);

View File

@ -1,4 +1,4 @@
/* $NetBSD: in.c,v 1.100 2004/08/08 09:52:41 yamt Exp $ */
/* $NetBSD: in.c,v 1.101 2005/01/24 21:25:09 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.100 2004/08/08 09:52:41 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.101 2005/01/24 21:25:09 matt Exp $");
#include "opt_inet.h"
#include "opt_inet_conf.h"
@ -736,7 +736,7 @@ in_lifaddr_ioctl(so, cmd, data, ifp, p)
}
}
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, ifp) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
if (!cmp)
@ -1042,7 +1042,7 @@ in_broadcast(in, ifp)
* with a broadcast address.
*/
#define ia (ifatoia(ifa))
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list)
IFADDR_FOREACH(ifa, ifp)
if (ifa->ifa_addr->sa_family == AF_INET &&
!in_hosteq(in, ia->ia_addr.sin_addr) &&
(in_hosteq(in, ia->ia_broadaddr.sin_addr) ||

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_var.h,v 1.53 2004/04/21 17:49:46 itojun Exp $ */
/* $NetBSD: in_var.h,v 1.54 2005/01/24 21:25:09 matt Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -204,7 +204,7 @@ extern const int inetctlerrmap[];
{ \
struct ifaddr *ifa; \
\
TAILQ_FOREACH(ifa, &(ifp)->if_addrlist, ifa_list) { \
IFADDR_FOREACH(ifa, ifp) { \
if (ifa->ifa_addr->sa_family == AF_INET) \
break; \
} \

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_icmp.c,v 1.87 2004/08/03 13:58:59 cube Exp $ */
/* $NetBSD: ip_icmp.c,v 1.88 2005/01/24 21:25:09 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -101,7 +101,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.87 2004/08/03 13:58:59 cube Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.88 2005/01/24 21:25:09 matt Exp $");
#include "opt_ipsec.h"
@ -669,7 +669,7 @@ icmp_reflect(m)
/* look for packet sent to broadcast address */
if (ia == NULL && m->m_pkthdr.rcvif &&
(m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST)) {
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, m->m_pkthdr.rcvif) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
if (in_hosteq(t,ifatoia(ifa)->ia_broadaddr.sin_addr)) {
@ -726,7 +726,7 @@ icmp_reflect(m)
* when the incoming packet was encapsulated
*/
if (sin == (struct sockaddr_in *)0 && m->m_pkthdr.rcvif) {
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, m->m_pkthdr.rcvif) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
sin = &(ifatoia(ifa)->ia_addr);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_input.c,v 1.208 2004/12/19 06:42:24 christos Exp $ */
/* $NetBSD: ip_input.c,v 1.209 2005/01/24 21:25:10 matt Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.208 2004/12/19 06:42:24 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.209 2005/01/24 21:25:10 matt Exp $");
#include "opt_inet.h"
#include "opt_gateway.h"
@ -733,7 +733,7 @@ ip_input(struct mbuf *m)
if (ia != NULL)
goto ours;
if (m->m_pkthdr.rcvif->if_flags & IFF_BROADCAST) {
TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) {
IFADDR_FOREACH(ifa, m->m_pkthdr.rcvif) {
if (ifa->ifa_addr->sa_family != AF_INET)
continue;
ia = ifatoia(ifa);