summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1996-12-13 21:29:07 +0000
committerwollman <wollman@FreeBSD.org>1996-12-13 21:29:07 +0000
commit3417f9411098d1cd19c5db539c0768e778b83a1c (patch)
tree782c07e423375f5e3235e7a677261301a91e59c6
parent4ad813db29ba756a35db6540961c86a4c1f5592b (diff)
downloadFreeBSD-src-3417f9411098d1cd19c5db539c0768e778b83a1c.zip
FreeBSD-src-3417f9411098d1cd19c5db539c0768e778b83a1c.tar.gz
Convert the interface address and IP interface address structures
to TAILQs. Fix places which referenced these for no good reason that I can see (the references remain, but were fixed to compile again; they are still questionable).
-rw-r--r--sys/dev/ed/if_ed.c4
-rw-r--r--sys/dev/ep/if_ep.c21
-rw-r--r--sys/dev/fe/if_fe.c4
-rw-r--r--sys/dev/lnc/if_lnc.c2
-rw-r--r--sys/i386/isa/if_ed.c4
-rw-r--r--sys/i386/isa/if_el.c19
-rw-r--r--sys/i386/isa/if_ep.c21
-rw-r--r--sys/i386/isa/if_fe.c4
-rw-r--r--sys/i386/isa/if_lnc.c2
-rw-r--r--sys/i386/isa/if_ze.c4
-rw-r--r--sys/i386/isa/if_zp.c4
-rw-r--r--sys/net/if.c34
-rw-r--r--sys/net/if.h20
-rw-r--r--sys/net/if_ethersubr.c22
-rw-r--r--sys/net/if_fddisubr.c16
-rw-r--r--sys/net/if_spppsubr.c5
-rw-r--r--sys/net/if_tun.c6
-rw-r--r--sys/net/rtsock.c10
-rw-r--r--sys/netatalk/aarp.c27
-rw-r--r--sys/netatalk/at_control.c35
-rw-r--r--sys/netatalk/at_extern.h2
-rw-r--r--sys/netinet/in.c76
-rw-r--r--sys/netinet/in_pcb.c17
-rw-r--r--sys/netinet/in_var.h33
-rw-r--r--sys/netinet/ip_divert.c6
-rw-r--r--sys/netinet/ip_fw.c7
-rw-r--r--sys/netinet/ip_icmp.c6
-rw-r--r--sys/netinet/ip_input.c11
-rw-r--r--sys/netinet/ip_output.c5
-rw-r--r--sys/netipx/ipx.c31
-rw-r--r--sys/netipx/ipx_input.c6
-rw-r--r--sys/netipx/ipx_ip.c7
-rw-r--r--sys/netipx/ipx_usrreq.c5
-rw-r--r--sys/nfs/nfs_vnops.c6
-rw-r--r--sys/nfsclient/nfs_vnops.c6
35 files changed, 194 insertions, 294 deletions
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c
index 6bed04e..95a4859 100644
--- a/sys/dev/ed/if_ed.c
+++ b/sys/dev/ed/if_ed.c
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: if_ed.c,v 1.109 1996/12/03 16:08:00 phk Exp $
+ * $Id: if_ed.c,v 1.110 1996/12/10 07:29:39 davidg Exp $
*/
/*
@@ -1872,7 +1872,7 @@ ed_init(xsc)
return;
/* address not known */
- if (ifp->if_addrlist == (struct ifaddr *) 0)
+ if (TAILQ_EMPTY(&ifp->if_addrhead)) /* unlikely? XXX */
return;
/*
diff --git a/sys/dev/ep/if_ep.c b/sys/dev/ep/if_ep.c
index 7840e8b..6efbe85 100644
--- a/sys/dev/ep/if_ep.c
+++ b/sys/dev/ep/if_ep.c
@@ -38,7 +38,7 @@
*/
/*
- * $Id: if_ep.c,v 1.52 1996/07/27 12:40:31 amurai Exp $
+ * $Id: if_ep.c,v 1.53 1996/09/06 23:07:33 phk Exp $
*
* Promiscuous mode added and interrupt logic slightly changed
* to reduce the number of adapter failures. Transceiver select
@@ -655,25 +655,6 @@ ep_attach(sc)
ether_ifattach(ifp);
}
- /* device attach does transition from UNCONFIGURED to IDLE state */
-
- /*
- * Fill the hardware address into ifa_addr if we find an AF_LINK entry.
- * We need to do this so bpf's can get the hardware addr of this card.
- * netstat likes this too!
- */
- ifa = ifp->if_addrlist;
- while ((ifa != 0) && (ifa->ifa_addr != 0) &&
- (ifa->ifa_addr->sa_family != AF_LINK))
- ifa = ifa->ifa_next;
-
- if ((ifa != 0) && (ifa->ifa_addr != 0)) {
- sdl = (struct sockaddr_dl *) ifa->ifa_addr;
- sdl->sdl_type = IFT_ETHER;
- sdl->sdl_alen = ETHER_ADDR_LEN;
- sdl->sdl_slen = 0;
- bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN);
- }
/* we give some initial parameters */
sc->rx_avg_pkt = 128;
diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c
index a8fdc3c..9c2cf8e 100644
--- a/sys/dev/fe/if_fe.c
+++ b/sys/dev/fe/if_fe.c
@@ -21,7 +21,7 @@
*/
/*
- * $Id: if_fe.c,v 1.20 1996/10/07 17:50:00 wollman Exp $
+ * $Id: if_fe.c,v 1.21 1996/11/15 16:15:56 wollman Exp $
*
* Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards.
* To be used with FreeBSD 2.x
@@ -1701,7 +1701,7 @@ fe_init ( int unit )
#endif
/* We need an address. */
- if (sc->sc_if.if_addrlist == 0) {
+ if (TAILQ_EMPTY(&sc->sc_if.if_addrhead)) { /* XXX unlikely */
#if FE_DEBUG >= 1
log( LOG_ERR, "fe%d: init() without any address\n",
sc->sc_unit );
diff --git a/sys/dev/lnc/if_lnc.c b/sys/dev/lnc/if_lnc.c
index 20201e4..0df6bbe 100644
--- a/sys/dev/lnc/if_lnc.c
+++ b/sys/dev/lnc/if_lnc.c
@@ -1212,7 +1212,7 @@ lnc_init(struct lnc_softc *sc)
/* Check that interface has valid address */
- if (!sc->arpcom.ac_if.if_addrlist)
+ if (TAILQ_EMPTY(&sc->arpcom.ac_if.if_addrhead)) /* XXX unlikely */
return;
/* Shut down interface */
diff --git a/sys/i386/isa/if_ed.c b/sys/i386/isa/if_ed.c
index 6bed04e..95a4859 100644
--- a/sys/i386/isa/if_ed.c
+++ b/sys/i386/isa/if_ed.c
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: if_ed.c,v 1.109 1996/12/03 16:08:00 phk Exp $
+ * $Id: if_ed.c,v 1.110 1996/12/10 07:29:39 davidg Exp $
*/
/*
@@ -1872,7 +1872,7 @@ ed_init(xsc)
return;
/* address not known */
- if (ifp->if_addrlist == (struct ifaddr *) 0)
+ if (TAILQ_EMPTY(&ifp->if_addrhead)) /* unlikely? XXX */
return;
/*
diff --git a/sys/i386/isa/if_el.c b/sys/i386/isa/if_el.c
index afa08ae..3338aee 100644
--- a/sys/i386/isa/if_el.c
+++ b/sys/i386/isa/if_el.c
@@ -6,7 +6,7 @@
*
* Questions, comments, bug reports and fixes to kimmel@cs.umass.edu.
*
- * $Id: if_el.c,v 1.25 1996/08/06 21:14:04 phk Exp $
+ * $Id: if_el.c,v 1.26 1996/09/06 23:07:32 phk Exp $
*/
/* Except of course for the portions of code lifted from other FreeBSD
* drivers (mainly elread, elget and el_ioctl)
@@ -191,21 +191,6 @@ el_attach(struct isa_device *idev)
if_attach(ifp);
ether_ifattach(ifp);
- /* Put the station address in the ifa address list's AF_LINK
- * entry, if any.
- */
- ifa = ifp->if_addrlist;
- while ((ifa != NULL) && (ifa->ifa_addr != NULL) &&
- (ifa->ifa_addr->sa_family != AF_LINK))
- ifa = ifa->ifa_next;
- if((ifa != NULL) && (ifa->ifa_addr != NULL)) {
- sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- sdl->sdl_type = IFT_ETHER;
- sdl->sdl_alen = ETHER_ADDR_LEN;
- sdl->sdl_slen = 0;
- bcopy(sc->arpcom.ac_enaddr,LLADDR(sdl),ETHER_ADDR_LEN);
- }
-
/* Print out some information for the user */
printf("el%d: 3c501 address %6D\n",idev->id_unit,
sc->arpcom.ac_enaddr, ":");
@@ -278,7 +263,7 @@ el_init(int unit)
base = sc->el_base;
/* If address not known, do nothing. */
- if(ifp->if_addrlist == (struct ifaddr *)0)
+ if(TAILQ_EMPTY(&ifp->if_addrhead)) /* XXX unlikely */
return;
s = splimp();
diff --git a/sys/i386/isa/if_ep.c b/sys/i386/isa/if_ep.c
index 7840e8b..6efbe85 100644
--- a/sys/i386/isa/if_ep.c
+++ b/sys/i386/isa/if_ep.c
@@ -38,7 +38,7 @@
*/
/*
- * $Id: if_ep.c,v 1.52 1996/07/27 12:40:31 amurai Exp $
+ * $Id: if_ep.c,v 1.53 1996/09/06 23:07:33 phk Exp $
*
* Promiscuous mode added and interrupt logic slightly changed
* to reduce the number of adapter failures. Transceiver select
@@ -655,25 +655,6 @@ ep_attach(sc)
ether_ifattach(ifp);
}
- /* device attach does transition from UNCONFIGURED to IDLE state */
-
- /*
- * Fill the hardware address into ifa_addr if we find an AF_LINK entry.
- * We need to do this so bpf's can get the hardware addr of this card.
- * netstat likes this too!
- */
- ifa = ifp->if_addrlist;
- while ((ifa != 0) && (ifa->ifa_addr != 0) &&
- (ifa->ifa_addr->sa_family != AF_LINK))
- ifa = ifa->ifa_next;
-
- if ((ifa != 0) && (ifa->ifa_addr != 0)) {
- sdl = (struct sockaddr_dl *) ifa->ifa_addr;
- sdl->sdl_type = IFT_ETHER;
- sdl->sdl_alen = ETHER_ADDR_LEN;
- sdl->sdl_slen = 0;
- bcopy(sc->arpcom.ac_enaddr, LLADDR(sdl), ETHER_ADDR_LEN);
- }
/* we give some initial parameters */
sc->rx_avg_pkt = 128;
diff --git a/sys/i386/isa/if_fe.c b/sys/i386/isa/if_fe.c
index a8fdc3c..9c2cf8e 100644
--- a/sys/i386/isa/if_fe.c
+++ b/sys/i386/isa/if_fe.c
@@ -21,7 +21,7 @@
*/
/*
- * $Id: if_fe.c,v 1.20 1996/10/07 17:50:00 wollman Exp $
+ * $Id: if_fe.c,v 1.21 1996/11/15 16:15:56 wollman Exp $
*
* Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards.
* To be used with FreeBSD 2.x
@@ -1701,7 +1701,7 @@ fe_init ( int unit )
#endif
/* We need an address. */
- if (sc->sc_if.if_addrlist == 0) {
+ if (TAILQ_EMPTY(&sc->sc_if.if_addrhead)) { /* XXX unlikely */
#if FE_DEBUG >= 1
log( LOG_ERR, "fe%d: init() without any address\n",
sc->sc_unit );
diff --git a/sys/i386/isa/if_lnc.c b/sys/i386/isa/if_lnc.c
index 20201e4..0df6bbe 100644
--- a/sys/i386/isa/if_lnc.c
+++ b/sys/i386/isa/if_lnc.c
@@ -1212,7 +1212,7 @@ lnc_init(struct lnc_softc *sc)
/* Check that interface has valid address */
- if (!sc->arpcom.ac_if.if_addrlist)
+ if (TAILQ_EMPTY(&sc->arpcom.ac_if.if_addrhead)) /* XXX unlikely */
return;
/* Shut down interface */
diff --git a/sys/i386/isa/if_ze.c b/sys/i386/isa/if_ze.c
index 7eb6abe..1b7e1ab 100644
--- a/sys/i386/isa/if_ze.c
+++ b/sys/i386/isa/if_ze.c
@@ -47,7 +47,7 @@
*/
/*
- * $Id: if_ze.c,v 1.32 1996/07/12 04:11:23 bde Exp $
+ * $Id: if_ze.c,v 1.33 1996/08/06 21:14:11 phk Exp $
*/
#include "ze.h"
@@ -763,7 +763,7 @@ ze_init(unit)
Debugger("here!!");
ze_setup(sc);
/* address not known */
- if (ifp->if_addrlist == (struct ifaddr *)0) return;
+ if (TAILQ_EMPTY(&ifp->if_addrhead)) return; /* XXX unlikely! */
/*
* Initialize the NIC in the exact order outlined in the NS manual.
diff --git a/sys/i386/isa/if_zp.c b/sys/i386/isa/if_zp.c
index f4b1a7b..d76bd88 100644
--- a/sys/i386/isa/if_zp.c
+++ b/sys/i386/isa/if_zp.c
@@ -34,7 +34,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* From: if_ep.c,v 1.9 1994/01/25 10:46:29 deraadt Exp $
- * $Id: if_zp.c,v 1.26 1996/09/11 16:11:21 nate Exp $
+ * $Id: if_zp.c,v 1.27 1996/11/11 17:11:08 bde Exp $
*/
/*-
* TODO:
@@ -581,7 +581,7 @@ zpinit(unit)
register struct ifnet *ifp = &sc->arpcom.ac_if;
int s, i;
- if (ifp->if_addrlist == (struct ifaddr *) 0)
+ if (TAILQ_EMPTY(&ifp->if_addrhead)) /* XXX unlikely */
return;
s = splimp();
diff --git a/sys/net/if.c b/sys/net/if.c
index 78a98d8..65ec137 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.c 8.3 (Berkeley) 1/4/94
- * $Id: if.c,v 1.36 1996/08/07 04:09:05 julian Exp $
+ * $Id: if.c,v 1.37 1996/12/11 20:38:14 wollman Exp $
*/
#include <sys/param.h>
@@ -117,6 +117,14 @@ if_attach(ifp)
TAILQ_INSERT_TAIL(&ifnet, ifp, if_link);
ifp->if_index = ++if_index;
+ /*
+ * XXX -
+ * The old code would work if the interface passed a pre-existing
+ * chain of ifaddrs to this code. We don't trust our callers to
+ * properly initialize the tailq, however, so we no longer allow
+ * this unlikely case.
+ */
+ TAILQ_INIT(&ifp->if_addrhead);
microtime(&ifp->if_lastchange);
if (ifnet_addrs == 0 || if_index >= if_indexlim) {
unsigned n = (if_indexlim <<= 1) * sizeof(ifa);
@@ -153,16 +161,14 @@ if_attach(ifp)
sdl->sdl_type = ifp->if_type;
ifnet_addrs[if_index - 1] = ifa;
ifa->ifa_ifp = ifp;
- ifa->ifa_next = ifp->if_addrlist;
ifa->ifa_rtrequest = link_rtrequest;
- ifp->if_addrlist = ifa;
ifa->ifa_addr = (struct sockaddr *)sdl;
-
sdl = (struct sockaddr_dl *)(socksize + (caddr_t)sdl);
ifa->ifa_netmask = (struct sockaddr *)sdl;
sdl->sdl_len = masklen;
while (namelen != 0)
sdl->sdl_data[--namelen] = 0xff;
+ TAILQ_INSERT_HEAD(&ifp->if_addrhead, ifa, ifa_link);
}
}
/*
@@ -179,7 +185,8 @@ ifa_ifwithaddr(addr)
#define equal(a1, a2) \
(bcmp((caddr_t)(a1), (caddr_t)(a2), ((struct sockaddr *)(a1))->sa_len) == 0)
for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_link.tqe_next)
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
+ for (ifa = ifp->if_addrhead.tqh_first; ifa;
+ ifa = ifa->ifa_link.tqe_next) {
if (ifa->ifa_addr->sa_family != addr->sa_family)
continue;
if (equal(addr, ifa->ifa_addr))
@@ -203,7 +210,8 @@ ifa_ifwithdstaddr(addr)
for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_link.tqe_next)
if (ifp->if_flags & IFF_POINTOPOINT)
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
+ for (ifa = ifp->if_addrhead.tqh_first; ifa;
+ ifa = ifa->ifa_link.tqe_next) {
if (ifa->ifa_addr->sa_family != addr->sa_family)
continue;
if (ifa->ifa_dstaddr && equal(addr, ifa->ifa_dstaddr))
@@ -232,7 +240,8 @@ ifa_ifwithnet(addr)
return (ifnet_addrs[sdl->sdl_index - 1]);
}
for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_link.tqe_next) {
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
+ for (ifa = ifp->if_addrhead.tqh_first; ifa;
+ ifa = ifa->ifa_link.tqe_next) {
register char *cp, *cp2, *cp3;
if (ifa->ifa_addr->sa_family != af)
@@ -278,7 +287,8 @@ ifaof_ifpforaddr(addr, ifp)
if (af >= AF_MAX)
return (0);
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
+ for (ifa = ifp->if_addrhead.tqh_first; ifa;
+ ifa = ifa->ifa_link.tqe_next) {
if (ifa->ifa_addr->sa_family != af)
continue;
if (ifa_maybe == 0)
@@ -350,7 +360,8 @@ if_down(ifp)
ifp->if_flags &= ~IFF_UP;
microtime(&ifp->if_lastchange);
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
+ for (ifa = ifp->if_addrhead.tqh_first; ifa;
+ ifa = ifa->ifa_link.tqe_next)
pfctlinput(PRC_IFDOWN, ifa->ifa_addr);
if_qflush(&ifp->if_snd);
rt_ifmsg(ifp);
@@ -699,7 +710,7 @@ ifconf(cmd, data)
strcpy(ifr.ifr_name, workbuf);
}
- if ((ifa = ifp->if_addrlist) == 0) {
+ if ((ifa = ifp->if_addrhead.tqh_first) == 0) {
bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
sizeof (ifr));
@@ -707,7 +718,8 @@ ifconf(cmd, data)
break;
space -= sizeof (ifr), ifrp++;
} else
- for ( ; space > sizeof (ifr) && ifa; ifa = ifa->ifa_next) {
+ for ( ; space > sizeof (ifr) && ifa;
+ ifa = ifa->ifa_link.tqe_next) {
register struct sockaddr *sa = ifa->ifa_addr;
#ifdef COMPAT_43
if (cmd == OSIOCGIFCONF) {
diff --git a/sys/net/if.h b/sys/net/if.h
index 267c5b0..09b6bc9 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.h 8.1 (Berkeley) 6/10/93
- * $Id: if.h,v 1.38 1996/12/10 18:03:51 wollman Exp $
+ * $Id: if.h,v 1.40 1996/12/11 20:38:14 wollman Exp $
*/
#ifndef _NET_IF_H_
@@ -73,7 +73,10 @@ struct socket;
struct ether_header;
#endif
-#include <sys/queue.h> /* get LIST macros */
+#include <sys/queue.h> /* get TAILQ macros */
+
+TAILQ_HEAD(ifnethead, ifnet); /* we use TAILQs so that the order of */
+TAILQ_HEAD(ifaddrhead, ifaddr); /* instantiation is preserved in the list */
/*
* Structure describing information about an interface
@@ -127,11 +130,7 @@ struct ifnet {
void *if_softc; /* pointer to driver state */
char *if_name; /* name, e.g. ``en'' or ``lo'' */
TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */
-#if 0
- LIST_HEAD(, ifaddr) if_addrlist;
-#else
- struct ifaddr *if_addrlist; /* linked list of addresses per if */
-#endif
+ struct ifaddrhead if_addrhead; /* linked list of addresses per if */
int if_pcount; /* number of promiscuous listeners */
struct bpf_if *if_bpf; /* packet filter structure */
u_short if_index; /* numeric abbreviation for this if */
@@ -168,7 +167,6 @@ struct ifnet {
struct ifqueue *if_poll_slowq; /* input queue for slow devices */
};
typedef void if_init_f_t __P((void *));
-TAILQ_HEAD(ifnethead, ifnet);
#define if_mtu if_data.ifi_mtu
#define if_type if_data.ifi_type
@@ -310,11 +308,7 @@ struct ifaddr {
#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
struct sockaddr *ifa_netmask; /* used to determine subnet */
struct ifnet *ifa_ifp; /* back-pointer to interface */
-#if 0
- LIST_ENTRY(ifaddr) ifa_link;
-#else
- struct ifaddr *ifa_next; /* next address for interface */
-#endif
+ TAILQ_ENTRY(ifaddr) ifa_link; /* queue macro glue */
void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */
__P((int, struct rtentry *, struct sockaddr *));
u_short ifa_flags; /* mostly rt_flags for cloning */
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index bdcdde7..3aefabe 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93
- * $Id: if_ethersubr.c,v 1.27 1996/11/18 04:55:44 davidg Exp $
+ * $Id: if_ethersubr.c,v 1.28 1996/12/10 07:29:48 davidg Exp $
*/
#include <sys/param.h>
@@ -197,7 +197,7 @@ ether_output(ifp, m0, dst, rt0)
* ifaddr is the first thing in at_ifaddr
*/
if ((aa = (struct at_ifaddr *)at_ifawithnet(
- (struct sockaddr_at *)dst, ifp->if_addrlist))
+ (struct sockaddr_at *)dst, &ifp->if_addrhead))
== 0)
goto bad;
@@ -653,15 +653,15 @@ ether_ifattach(ifp)
ifp->if_mtu = ETHERMTU;
if (ifp->if_baudrate == 0)
ifp->if_baudrate = 10000000;
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
- if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) &&
- sdl->sdl_family == AF_LINK) {
- sdl->sdl_type = IFT_ETHER;
- sdl->sdl_alen = ifp->if_addrlen;
- bcopy((caddr_t)((struct arpcom *)ifp)->ac_enaddr,
- LLADDR(sdl), ifp->if_addrlen);
- break;
- }
+ ifa = ifnet_addrs[ifp->if_index - 1];
+ if (ifa == 0) {
+ printf("ether_ifattach: no lladdr!\n");
+ return;
+ }
+ sdl = (struct sockaddr_dl *)ifa->ifa_addr;
+ sdl->sdl_type = IFT_ETHER;
+ sdl->sdl_alen = ifp->if_addrlen;
+ bcopy(((struct arpcom *)ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen);
}
static u_char ether_ipmulticast_min[6] =
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index 1d13de2..f910e56 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: if_ethersubr.c,v 1.5 1994/12/13 22:31:45 wollman Exp
- * $Id: if_fddisubr.c,v 1.9 1996/06/10 23:07:31 gpalmer Exp $
+ * $Id: if_fddisubr.c,v 1.10 1996/11/12 08:43:32 davidg Exp $
*/
#include <sys/param.h>
@@ -567,13 +567,9 @@ fddi_ifattach(ifp)
ifp->if_hdrlen = 21;
ifp->if_mtu = FDDIMTU;
ifp->if_baudrate = 100000000;
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
- if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) &&
- sdl->sdl_family == AF_LINK) {
- sdl->sdl_type = IFT_FDDI;
- sdl->sdl_alen = ifp->if_addrlen;
- bcopy((caddr_t)((struct arpcom *)ifp)->ac_enaddr,
- LLADDR(sdl), ifp->if_addrlen);
- break;
- }
+ ifa = ifnet_addrs[ifp->if_index - 1];
+ sdl = (struct sockaddr_dl *)ifa->ifa_addr;
+ sdl->sdl_type = IFT_FDDI;
+ sdl->sdl_alen = ifp->if_addrlen;
+ bcopy(((struct arpcom *)ifp)->ac_enaddr, LLADDR(sdl), ifp->if_addrlen);
}
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index e295cbd..88208009 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -14,7 +14,7 @@
*
* Version 1.9, Wed Oct 4 18:58:15 MSK 1995
*
- * $Id: if_spppsubr.c,v 1.12 1996/06/10 23:17:45 gpalmer Exp $
+ * $Id: if_spppsubr.c,v 1.13 1996/08/30 16:44:36 jhay Exp $
*/
#undef DEBUG
@@ -898,7 +898,8 @@ sppp_cisco_input (struct sppp *sp, struct mbuf *m)
}
break;
case CISCO_ADDR_REQ:
- for (ifa=ifp->if_addrlist; ifa; ifa=ifa->ifa_next)
+ for (ifa=ifp->if_addrhead.tqh_first; ifa;
+ ifa=ifa->ifa_link.tqe_next)
if (ifa->ifa_addr->sa_family == AF_INET)
break;
if (! ifa) {
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 9518c31..0b740e5 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -197,7 +197,8 @@ tunclose(dev_t dev, int foo, int bar, struct proc *p)
if (ifp->if_flags & IFF_RUNNING) {
/* find internet addresses and delete routes */
register struct ifaddr *ifa;
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
+ for (ifa = ifp->if_addrhead.tqh_first; ifa;
+ ifa = ifa->ifa_link.tqe_next) {
if (ifa->ifa_addr->sa_family == AF_INET) {
rtinit(ifa, (int)RTM_DELETE,
tp->tun_flags & TUN_DSTADDR ? RTF_HOST : 0);
@@ -226,7 +227,8 @@ tuninit(unit)
ifp->if_flags |= IFF_UP | IFF_RUNNING;
microtime(&ifp->if_lastchange);
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
+ for (ifa = ifp->if_addrhead.tqh_first; ifa;
+ ifa = ifa->ifa_link.tqe_next)
if (ifa->ifa_addr->sa_family == AF_INET) {
struct sockaddr_in *si;
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 582ff7c..eb786fa 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)rtsock.c 8.5 (Berkeley) 11/2/94
- * $Id: rtsock.c,v 1.20 1996/07/10 01:34:36 fenner Exp $
+ * $Id: rtsock.c,v 1.21 1996/12/11 20:38:16 wollman Exp $
*/
#include <sys/param.h>
@@ -235,7 +235,7 @@ route_output(m, so)
if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) {
ifp = rt->rt_ifp;
if (ifp) {
- ifpaddr = ifp->if_addrlist->ifa_addr;
+ ifpaddr = ifp->if_addrhead.tqh_first->ifa_addr;
ifaaddr = rt->rt_ifa->ifa_addr;
rtm->rtm_index = ifp->if_index;
} else {
@@ -604,7 +604,7 @@ rt_newaddrmsg(cmd, ifa, error, rt)
int ncmd = cmd == RTM_ADD ? RTM_NEWADDR : RTM_DELADDR;
ifaaddr = sa = ifa->ifa_addr;
- ifpaddr = ifp->if_addrlist->ifa_addr;
+ ifpaddr = ifp->if_addrhead.tqh_first->ifa_addr;
netmask = ifa->ifa_netmask;
brdaddr = ifa->ifa_dstaddr;
if ((m = rt_msg1(ncmd, &info)) == NULL)
@@ -688,7 +688,7 @@ sysctl_iflist(af, w)
for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_link.tqe_next) {
if (w->w_arg && w->w_arg != ifp->if_index)
continue;
- ifa = ifp->if_addrlist;
+ ifa = ifp->if_addrhead.tqh_first;
ifpaddr = ifa->ifa_addr;
len = rt_msg2(RTM_IFINFO, &info, (caddr_t)0, w);
ifpaddr = 0;
@@ -704,7 +704,7 @@ sysctl_iflist(af, w)
if (error)
return (error);
}
- while ((ifa = ifa->ifa_next) != 0) {
+ while ((ifa = ifa->ifa_link.tqe_next) != 0) {
if (af && af != ifa->ifa_addr->sa_family)
continue;
ifaaddr = ifa->ifa_addr;
diff --git a/sys/netatalk/aarp.c b/sys/netatalk/aarp.c
index 1d7e029..d81d177 100644
--- a/sys/netatalk/aarp.c
+++ b/sys/netatalk/aarp.c
@@ -95,14 +95,15 @@ aarptimer(void *ignored)
* consideration.
*/
struct ifaddr *
-at_ifawithnet( sat, ifa )
+at_ifawithnet( sat, ifah )
struct sockaddr_at *sat;
- struct ifaddr *ifa;
+ struct ifaddrhead *ifah;
{
struct sockaddr_at *sat2;
struct netrange *nr;
+ struct ifaddr *ifa;
- for (; ifa; ifa = ifa->ifa_next ) {
+ for (ifa = ifah->tqh_first; ifa; ifa = ifa->ifa_link.tqe_next ) {
if ( ifa->ifa_addr->sa_family != AF_APPLETALK ) {
continue;
}
@@ -155,8 +156,8 @@ aarpwhohas( struct arpcom *ac, struct sockaddr_at *sat )
* interface with the same address as we're looking for. If the
* net is phase 2, generate an 802.2 and SNAP header.
*/
- if (( aa = (struct at_ifaddr *)at_ifawithnet( sat, ac->ac_if.if_addrlist ))
- == NULL ) {
+ if ((aa = (struct at_ifaddr *)at_ifawithnet(sat, &ac->ac_if.if_addrhead))
+ == NULL) {
m_freem( m );
return;
}
@@ -213,8 +214,8 @@ aarpresolve( ac, m, destsat, desten )
int s;
if ( at_broadcast( destsat )) {
- if (( aa = (struct at_ifaddr *)at_ifawithnet( destsat,
- ((struct ifnet *)ac)->if_addrlist )) == NULL ) {
+ if ((aa = (struct at_ifaddr *)at_ifawithnet(destsat,
+ &((struct ifnet *)ac)->if_addrhead)) == NULL) {
m_freem( m );
return( 0 );
}
@@ -325,8 +326,8 @@ at_aarpinput( struct arpcom *ac, struct mbuf *m)
sat.sat_len = sizeof(struct sockaddr_at);
sat.sat_family = AF_APPLETALK;
sat.sat_addr.s_net = net;
- if (( aa = (struct at_ifaddr *)at_ifawithnet( &sat,
- ac->ac_if.if_addrlist )) == NULL ) {
+ if ((aa = (struct at_ifaddr *)at_ifawithnet(&sat,
+ &ac->ac_if.if_addrhead)) == NULL) {
m_freem( m );
return;
}
@@ -337,8 +338,8 @@ at_aarpinput( struct arpcom *ac, struct mbuf *m)
* Since we don't know the net, we just look for the first
* phase 1 address on the interface.
*/
- for ( aa = (struct at_ifaddr *)ac->ac_if.if_addrlist; aa;
- aa = (struct at_ifaddr *)aa->aa_ifa.ifa_next ) {
+ for (aa = (struct at_ifaddr *)ac->ac_if.if_addrhead.tqh_first; aa;
+ aa = (struct at_ifaddr *)aa->aa_ifa.ifa_link.tqe_next) {
if ( AA_SAT( aa )->sat_family == AF_APPLETALK &&
( aa->aa_flags & AFA_PHASE2 ) == 0 ) {
break;
@@ -533,8 +534,8 @@ aarpprobe( struct arpcom *ac )
* interface with the same address as we're looking for. If the
* net is phase 2, generate an 802.2 and SNAP header.
*/
- for ( aa = (struct at_ifaddr *)ac->ac_if.if_addrlist; aa;
- aa = (struct at_ifaddr *)aa->aa_ifa.ifa_next ) {
+ for (aa = (struct at_ifaddr *)ac->ac_if.if_addrhead.tqh_first; aa;
+ aa = (struct at_ifaddr *)aa->aa_ifa.ifa_link.tqe_next) {
if ( AA_SAT( aa )->sat_family == AF_APPLETALK &&
( aa->aa_flags & AFA_PROBING )) {
break;
diff --git a/sys/netatalk/at_control.c b/sys/netatalk/at_control.c
index 65608b7..4d8f8fa 100644
--- a/sys/netatalk/at_control.c
+++ b/sys/netatalk/at_control.c
@@ -173,25 +173,21 @@ at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p )
* Find the end of the interface's addresses
* and link our new one on the end
*/
- if (( ifa = ifp->if_addrlist ) != NULL ) {
- for ( ; ifa->ifa_next; ifa = ifa->ifa_next )
- ;
- ifa->ifa_next = (struct ifaddr *)aa;
- } else {
- ifp->if_addrlist = (struct ifaddr *)aa;
- }
+ ifa = (struct ifaddr *)aa;
+ TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link);
+
/*
* Add a reference for the linking into the ifp_if_addrlist.
*/
- aa->aa_ifa.ifa_refcnt++;
+ ifa->ifa_refcnt++;
/*
* As the at_ifaddr contains the actual sockaddrs,
* and the ifaddr itself, link them al together correctly.
*/
- aa->aa_ifa.ifa_addr = (struct sockaddr *)&aa->aa_addr;
- aa->aa_ifa.ifa_dstaddr = (struct sockaddr *)&aa->aa_addr;
- aa->aa_ifa.ifa_netmask = (struct sockaddr *)&aa->aa_netmask;
+ ifa->ifa_addr = (struct sockaddr *)&aa->aa_addr;
+ ifa->ifa_dstaddr = (struct sockaddr *)&aa->aa_addr;
+ ifa->ifa_netmask = (struct sockaddr *)&aa->aa_netmask;
/*
* Set/clear the phase 2 bit.
@@ -285,23 +281,8 @@ at_control( int cmd, caddr_t data, struct ifnet *ifp, struct proc *p )
* remove the ifaddr from the interface
*/
ifa0 = (struct ifaddr *)aa;
- if (( ifa = ifp->if_addrlist ) == ifa0 ) {
- ifp->if_addrlist = ifa->ifa_next;
- } else {
- while ( ifa->ifa_next && ( ifa->ifa_next != ifa0 )) {
- ifa = ifa->ifa_next;
- }
+ TAILQ_REMOVE(&ifp->if_addrhead, ifa0, ifa_link);
- /*
- * if we found it, remove it, otherwise we screwed up.
- * decrement the reference count by one.
- */
- if ( ifa->ifa_next ) {
- ifa = ifa->ifa_next = ifa0->ifa_next;
- } else {
- panic( "at_control" );
- }
- }
/*
* refs goes from 1->0 if no external refs. note..
* This will not free it ... looks for -1.
diff --git a/sys/netatalk/at_extern.h b/sys/netatalk/at_extern.h
index 18badf4..bed1022 100644
--- a/sys/netatalk/at_extern.h
+++ b/sys/netatalk/at_extern.h
@@ -25,7 +25,7 @@ extern int ddp_usrreq __P(( struct socket *so, int req,
struct mbuf *rights));
extern void ddp_init __P((void ));
extern struct ifaddr *at_ifawithnet __P((struct sockaddr_at *,
- struct ifaddr *));
+ struct ifaddrhead *));
#ifdef _NETATALK_DDP_VAR_H_
extern int ddp_output __P(( struct ddpcb *ddp, struct mbuf *m));
#endif
diff --git a/sys/netinet/in.c b/sys/netinet/in.c
index 878f3bb..4e1df85 100644
--- a/sys/netinet/in.c
+++ b/sys/netinet/in.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in.c 8.4 (Berkeley) 1/9/95
- * $Id: in.c,v 1.24 1996/04/07 06:59:52 davidg Exp $
+ * $Id: in.c,v 1.25 1996/09/09 20:17:24 wollman Exp $
*/
#include <sys/param.h>
@@ -89,11 +89,13 @@ in_localaddr(in)
register struct in_ifaddr *ia;
if (subnetsarelocal) {
- for (ia = in_ifaddr; ia; ia = ia->ia_next)
+ for (ia = in_ifaddrhead.tqh_first; ia;
+ ia = ia->ia_link.tqe_next)
if ((i & ia->ia_netmask) == ia->ia_net)
return (1);
} else {
- for (ia = in_ifaddr; ia; ia = ia->ia_next)
+ for (ia = in_ifaddrhead.tqh_first; ia;
+ ia = ia->ia_link.tqe_next)
if ((i & ia->ia_subnetmask) == ia->ia_subnet)
return (1);
}
@@ -171,7 +173,8 @@ in_control(so, cmd, data, ifp)
* the first one on the interface.
*/
if (ifp)
- for (iap = in_ifaddr; iap; iap = iap->ia_next)
+ for (iap = in_ifaddrhead.tqh_first; iap;
+ iap = iap->ia_link.tqe_next)
if (iap->ia_ifp == ifp) {
if (((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr.s_addr ==
iap->ia_addr.sin_addr.s_addr) {
@@ -214,37 +217,24 @@ in_control(so, cmd, data, ifp)
if (ifp == 0)
panic("in_control");
if (ia == (struct in_ifaddr *)0) {
- oia = (struct in_ifaddr *)
- malloc(sizeof *oia, M_IFADDR, M_WAITOK);
- if (oia == (struct in_ifaddr *)NULL)
+ ia = (struct in_ifaddr *)
+ malloc(sizeof *ia, M_IFADDR, M_WAITOK);
+ if (ia == (struct in_ifaddr *)NULL)
return (ENOBUFS);
- bzero((caddr_t)oia, sizeof *oia);
- ia = in_ifaddr;
+ bzero((caddr_t)ia, sizeof *ia);
/*
* Protect from ipintr() traversing address list
* while we're modifying it.
*/
s = splnet();
-
- if (ia) {
- for ( ; ia->ia_next; ia = ia->ia_next)
- continue;
- ia->ia_next = oia;
- } else
- in_ifaddr = oia;
- ia = oia;
- ifa = ifp->if_addrlist;
- if (ifa) {
- for ( ; ifa->ifa_next; ifa = ifa->ifa_next)
- continue;
- ifa->ifa_next = (struct ifaddr *) ia;
- } else
- ifp->if_addrlist = (struct ifaddr *) ia;
- ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr;
- ia->ia_ifa.ifa_dstaddr
- = (struct sockaddr *)&ia->ia_dstaddr;
- ia->ia_ifa.ifa_netmask
- = (struct sockaddr *)&ia->ia_sockmask;
+
+ TAILQ_INSERT_TAIL(&in_ifaddrhead, ia, ia_link);
+ ifa = &ia->ia_ifa;
+ TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link);
+
+ ifa->ifa_addr = (struct sockaddr *)&ia->ia_addr;
+ ifa->ifa_dstaddr = (struct sockaddr *)&ia->ia_dstaddr;
+ ifa->ifa_netmask = (struct sockaddr *)&ia->ia_sockmask;
ia->ia_sockmask.sin_len = 8;
if (ifp->if_flags & IFF_BROADCAST) {
ia->ia_broadaddr.sin_len = sizeof(ia->ia_addr);
@@ -371,29 +361,10 @@ in_control(so, cmd, data, ifp)
*/
s = splnet();
- if ((ifa = ifp->if_addrlist) == (struct ifaddr *)ia)
- ifp->if_addrlist = ifa->ifa_next;
- else {
- while (ifa->ifa_next &&
- (ifa->ifa_next != (struct ifaddr *)ia))
- ifa = ifa->ifa_next;
- if (ifa->ifa_next)
- ifa->ifa_next = ((struct ifaddr *)ia)->ifa_next;
- else
- printf("Couldn't unlink inifaddr from ifp\n");
- }
+ ifa = &ia->ia_ifa;
+ TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
oia = ia;
- if (oia == (ia = in_ifaddr))
- in_ifaddr = ia->ia_next;
- else {
- while (ia->ia_next && (ia->ia_next != oia))
- ia = ia->ia_next;
- if (ia->ia_next)
- ia->ia_next = oia->ia_next;
- else
- printf("Didn't unlink inifadr from list\n");
- }
-
+ TAILQ_REMOVE(&in_ifaddrhead, oia, ia_link);
if (!oia->ia_multiaddrs.lh_first) {
IFAFREE(&oia->ia_ifa);
FREE(mk, M_IPMADDR);
@@ -603,7 +574,8 @@ in_broadcast(in, ifp)
* with a broadcast address.
*/
#define ia ((struct in_ifaddr *)ifa)
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
+ for (ifa = ifp->if_addrhead.tqh_first; ifa;
+ ifa = ifa->ifa_link.tqe_next)
if (ifa->ifa_addr->sa_family == AF_INET &&
(in.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
in.s_addr == ia->ia_netbroadcast.s_addr ||
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index e5da5fc..31fceab 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in_pcb.c 8.4 (Berkeley) 5/24/95
- * $Id: in_pcb.c,v 1.22 1996/10/07 19:06:07 davidg Exp $
+ * $Id: in_pcb.c,v 1.23 1996/10/30 06:13:09 peter Exp $
*/
#include <sys/param.h>
@@ -147,7 +147,7 @@ in_pcbbind(inp, nam)
int wild = 0, reuseport = (so->so_options & SO_REUSEPORT);
int error;
- if (in_ifaddr == 0)
+ if (TAILQ_EMPTY(&in_ifaddrhead)) /* XXX broken! */
return (EADDRNOTAVAIL);
if (inp->inp_lport || inp->inp_laddr.s_addr != INADDR_ANY)
return (EINVAL);
@@ -289,7 +289,7 @@ in_pcbladdr(inp, nam, plocal_sin)
return (EAFNOSUPPORT);
if (sin->sin_port == 0)
return (EADDRNOTAVAIL);
- if (in_ifaddr) {
+ if (!TAILQ_EMPTY(&in_ifaddrhead)) {
/*
* If the destination address is INADDR_ANY,
* use the primary local address.
@@ -301,10 +301,10 @@ in_pcbladdr(inp, nam, plocal_sin)
#define sintosa(sin) ((struct sockaddr *)(sin))
#define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
if (sin->sin_addr.s_addr == INADDR_ANY)
- sin->sin_addr = IA_SIN(in_ifaddr)->sin_addr;
+ sin->sin_addr = IA_SIN(in_ifaddrhead.tqh_first)->sin_addr;
else if (sin->sin_addr.s_addr == (u_long)INADDR_BROADCAST &&
- (in_ifaddr->ia_ifp->if_flags & IFF_BROADCAST))
- sin->sin_addr = satosin(&in_ifaddr->ia_broadaddr)->sin_addr;
+ (in_ifaddrhead.tqh_first->ia_ifp->if_flags & IFF_BROADCAST))
+ sin->sin_addr = satosin(&in_ifaddrhead.tqh_first->ia_broadaddr)->sin_addr;
}
if (inp->inp_laddr.s_addr == INADDR_ANY) {
register struct route *ro;
@@ -349,7 +349,7 @@ in_pcbladdr(inp, nam, plocal_sin)
ia = ifatoia(ifa_ifwithnet(sintosa(sin)));
sin->sin_port = fport;
if (ia == 0)
- ia = in_ifaddr;
+ ia = in_ifaddrhead.tqh_first;
if (ia == 0)
return (EADDRNOTAVAIL);
}
@@ -366,7 +366,8 @@ in_pcbladdr(inp, nam, plocal_sin)
imo = inp->inp_moptions;
if (imo->imo_multicast_ifp != NULL) {
ifp = imo->imo_multicast_ifp;
- for (ia = in_ifaddr; ia; ia = ia->ia_next)
+ for (ia = in_ifaddrhead.tqh_first; ia;
+ ia = ia->ia_link.tqe_next)
if (ia->ia_ifp == ifp)
break;
if (ia == 0)
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index c71c85a..f349a41 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)in_var.h 8.2 (Berkeley) 1/9/95
- * $Id: in_var.h,v 1.16 1996/02/05 20:35:59 wollman Exp $
+ * $Id: in_var.h,v 1.17 1996/03/14 16:59:19 fenner Exp $
*/
#ifndef _NETINET_IN_VAR_H_
@@ -55,6 +55,7 @@ struct in_ifaddr {
u_long ia_subnet; /* subnet number, including net */
u_long ia_subnetmask; /* mask of subnet part */
struct in_addr ia_netbroadcast; /* to recognize net broadcasts */
+ TAILQ_ENTRY(in_ifaddr) ia_link; /* tailq macro glue */
struct in_ifaddr *ia_next; /* next in list of internet addresses */
struct sockaddr_in ia_addr; /* reserve space for interface name */
struct sockaddr_in ia_dstaddr; /* reserve space for broadcast addr */
@@ -83,7 +84,7 @@ struct in_aliasreq {
#ifdef KERNEL
-extern struct in_ifaddr *in_ifaddr;
+extern TAILQ_HEAD(in_ifaddrhead, in_ifaddr) in_ifaddrhead;
extern struct ifqueue ipintrq; /* ip packet input queue */
extern struct in_addr zeroin_addr;
extern u_char inetctlerrmap[];
@@ -101,15 +102,15 @@ extern int rtq_toomany; /* XXX */
{ \
register struct in_ifaddr *ia; \
\
- for (ia = in_ifaddr; \
+ for (ia = in_ifaddrhead.tqh_first; \
ia != NULL && ((ia->ia_ifp->if_flags & IFF_POINTOPOINT)? \
IA_DSTSIN(ia):IA_SIN(ia))->sin_addr.s_addr != (addr).s_addr; \
- ia = ia->ia_next) \
+ ia = ia->ia_link.tqe_next) \
continue; \
if (ia == NULL) \
- for (ia = in_ifaddr; \
+ for (ia = in_ifaddrhead.tqh_first; \
ia != NULL; \
- ia = ia->ia_next) \
+ ia = ia->ia_link.tqe_next) \
if (ia->ia_ifp->if_flags & IFF_POINTOPOINT && \
IA_SIN(ia)->sin_addr.s_addr == (addr).s_addr) \
break; \
@@ -124,9 +125,9 @@ extern int rtq_toomany; /* XXX */
/* struct ifnet *ifp; */ \
/* struct in_ifaddr *ia; */ \
{ \
- for ((ia) = in_ifaddr; \
+ for ((ia) = in_ifaddrhead.tqh_first; \
(ia) != NULL && (ia)->ia_ifp != (ifp); \
- (ia) = (ia)->ia_next) \
+ (ia) = (ia)->ia_link.tqe_next) \
continue; \
}
#endif
@@ -178,7 +179,7 @@ struct in_multistep {
/* struct in_addr addr; */ \
/* struct ifnet *ifp; */ \
/* struct in_multi *inm; */ \
-{ \
+do { \
register struct in_ifaddr *ia; \
\
IFP_TO_IA((ifp), ia); \
@@ -189,7 +190,7 @@ struct in_multistep {
(inm) != NULL && (inm)->inm_addr.s_addr != (addr).s_addr; \
(inm) = inm->inm_entry.le_next) \
continue; \
-}
+} while(0)
/*
* Macro to step through all of the in_multi records, one at a time.
@@ -201,28 +202,28 @@ struct in_multistep {
#define IN_NEXT_MULTI(step, inm) \
/* struct in_multistep step; */ \
/* struct in_multi *inm; */ \
-{ \
+do { \
if (((inm) = (step).i_inm) != NULL) \
(step).i_inm = (inm)->inm_entry.le_next; \
else \
while ((step).i_ia != NULL) { \
(inm) = (step).i_ia->ia_multiaddrs.lh_first; \
- (step).i_ia = (step).i_ia->ia_next; \
+ (step).i_ia = (step).i_ia->ia_link.tqe_next; \
if ((inm) != NULL) { \
(step).i_inm = (inm)->inm_entry.le_next; \
break; \
} \
} \
-}
+} while(0)
#define IN_FIRST_MULTI(step, inm) \
/* struct in_multistep step; */ \
/* struct in_multi *inm; */ \
-{ \
- (step).i_ia = in_ifaddr; \
+do { \
+ (step).i_ia = in_ifaddrhead.tqh_first; \
(step).i_inm = NULL; \
IN_NEXT_MULTI((step), (inm)); \
-}
+} while(0)
struct in_multi *in_addmulti __P((struct in_addr *, struct ifnet *));
void in_delmulti __P((struct in_multi *));
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index 7720f84..4e3afa8 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ip_divert.c,v 1.2 1996/06/14 00:28:38 archie Exp $
+ * $Id: ip_divert.c,v 1.1 1996/07/10 19:44:22 julian Exp $
*/
#include <sys/param.h>
@@ -148,8 +148,8 @@ div_input(struct mbuf *m, int hlen)
HTONS(ip->ip_id);
/* Find IP address for recieve interface */
- for (ifa = m->m_pkthdr.rcvif->if_addrlist;
- ifa != NULL; ifa = ifa->ifa_next) {
+ for (ifa = m->m_pkthdr.rcvif->if_addrhead.tqh_first;
+ ifa != NULL; ifa = ifa->ifa_link.tqe_next) {
if (ifa->ifa_addr == NULL)
continue;
if (ifa->ifa_addr->sa_family != AF_INET)
diff --git a/sys/netinet/ip_fw.c b/sys/netinet/ip_fw.c
index 77739b4..d85041f 100644
--- a/sys/netinet/ip_fw.c
+++ b/sys/netinet/ip_fw.c
@@ -12,7 +12,7 @@
*
* This software is provided ``AS IS'' without any warranties of any kind.
*
- * $Id: ip_fw.c,v 1.50 1996/10/12 19:38:50 alex Exp $
+ * $Id: ip_fw.c,v 1.51 1996/10/12 19:49:36 bde Exp $
*/
/*
@@ -299,7 +299,7 @@ ip_fw_chk(struct ip **pip, int hlen,
* first adress
*/
if (rif != NULL)
- ia = rif->if_addrlist;
+ ia = rif->if_addrhead.tqh_first;
/*
* Go down the chain, looking for enlightment
@@ -347,7 +347,8 @@ ip_fw_chk(struct ip **pip, int hlen,
if (!(f->fw_flg & IP_FW_F_IFNAME) && f->fw_via_ip.s_addr) {
int match = 0;
- for (ia_p = ia; ia_p != NULL; ia_p = ia_p->ifa_next) {
+ for (ia_p = ia; ia_p != NULL;
+ ia_p = ia_p->ifa_link.tqe_next) {
if ((ia_p->ifa_addr == NULL))
continue;
if (ia_p->ifa_addr->sa_family != AF_INET)
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 8fc9eaa..1dbcc43 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94
- * $Id: ip_icmp.c,v 1.21 1996/07/24 18:46:17 wollman Exp $
+ * $Id: ip_icmp.c,v 1.22 1996/09/20 08:23:54 pst Exp $
*/
#include <sys/param.h>
@@ -509,7 +509,7 @@ icmp_reflect(m)
* or anonymous), use the address which corresponds
* to the incoming interface.
*/
- for (ia = in_ifaddr; ia; ia = ia->ia_next) {
+ for (ia = in_ifaddrhead.tqh_first; ia; ia = ia->ia_link.tqe_next) {
if (t.s_addr == IA_SIN(ia)->sin_addr.s_addr)
break;
if (ia->ia_ifp && (ia->ia_ifp->if_flags & IFF_BROADCAST) &&
@@ -525,7 +525,7 @@ icmp_reflect(m)
* and was received on an interface with no IP address.
*/
if (ia == (struct in_ifaddr *)0)
- ia = in_ifaddr;
+ ia = in_ifaddrhead.tqh_first;
t = IA_SIN(ia)->sin_addr;
ip->ip_src = t;
ip->ip_ttl = MAXTTL;
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 20256b8..969834c 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ip_input.c 8.2 (Berkeley) 1/4/94
- * $Id: ip_input.c,v 1.51 1996/11/11 04:56:15 fenner Exp $
+ * $Id: ip_input.c,v 1.52 1996/12/11 03:26:36 davidg Exp $
* $ANA: ip_input.c,v 1.5 1996/09/18 14:34:59 wollman Exp $
*/
@@ -102,7 +102,7 @@ extern struct domain inetdomain;
extern struct protosw inetsw[];
u_char ip_protox[IPPROTO_MAX];
static int ipqmaxlen = IFQ_MAXLEN;
-struct in_ifaddr *in_ifaddr; /* first inet address */
+struct in_ifaddrhead in_ifaddrhead; /* first inet address */
struct ifqueue ipintrq;
SYSCTL_INT(_net_inet_ip, IPCTL_INTRQMAXLEN, intr_queue_maxlen, CTLFLAG_RD,
&ipintrq.ifq_maxlen, 0, "");
@@ -179,6 +179,7 @@ ip_init()
register struct protosw *pr;
register int i;
+ TAILQ_INIT(&in_ifaddrhead);
pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
if (pr == 0)
panic("ip_init");
@@ -223,8 +224,10 @@ ip_input(struct mbuf *m)
/*
* If no IP addresses have been set yet but the interfaces
* are receiving, can't do anything with incoming packets yet.
+ * XXX This is broken! We should be able to receive broadcasts
+ * and multicasts even without any local addresses configured.
*/
- if (in_ifaddr == NULL)
+ if (TAILQ_EMPTY(&in_ifaddrhead))
goto bad;
ipstat.ips_total++;
@@ -358,7 +361,7 @@ tooshort:
/*
* Check our list of addresses, to see if the packet is for us.
*/
- for (ia = in_ifaddr; ia; ia = ia->ia_next) {
+ for (ia = in_ifaddrhead.tqh_first; ia; ia = ia->ia_link.tqe_next) {
#define satosin(sa) ((struct sockaddr_in *)(sa))
if (IA_SIN(ia)->sin_addr.s_addr == ip->ip_dst.s_addr)
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index 8addbe6..ba5b4bd 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ip_output.c 8.3 (Berkeley) 1/21/94
- * $Id: ip_output.c,v 1.44 1996/10/22 22:26:02 sos Exp $
+ * $Id: ip_output.c,v 1.45 1996/11/11 04:56:19 fenner Exp $
*/
#define _IP_VHL
@@ -227,7 +227,8 @@ ip_output(m0, opt, ro, flags, imo)
if (ip->ip_src.s_addr == INADDR_ANY) {
register struct in_ifaddr *ia;
- for (ia = in_ifaddr; ia; ia = ia->ia_next)
+ for (ia = in_ifaddrhead.tqh_first; ia;
+ ia = ia->ia_link.tqe_next)
if (ia->ia_ifp == ifp) {
ip->ip_src = IA_SIN(ia)->sin_addr;
break;
diff --git a/sys/netipx/ipx.c b/sys/netipx/ipx.c
index b33a7ac..764e597 100644
--- a/sys/netipx/ipx.c
+++ b/sys/netipx/ipx.c
@@ -33,7 +33,7 @@
*
* @(#)ipx.c
*
- * $Id: ipx.c,v 1.3 1995/11/04 09:02:34 julian Exp $
+ * $Id: ipx.c,v 1.4 1996/03/11 15:13:46 davidg Exp $
*/
#include <sys/param.h>
@@ -142,20 +142,14 @@ ipx_control(so, cmd, data, ifp)
} else
ipx_ifaddr = oia;
ia = oia;
- if ((ifa = ifp->if_addrlist)) {
- for ( ; ifa->ifa_next; ifa = ifa->ifa_next)
- ;
- ifa->ifa_next = (struct ifaddr *) ia;
- } else
- ifp->if_addrlist = (struct ifaddr *) ia;
+ ifa = (struct ifaddr *)ia;
+ TAILQ_INSERT_TAIL(&ifp->if_addrhead, ifa, ifa_link);
ia->ia_ifp = ifp;
- ia->ia_ifa.ifa_addr = (struct sockaddr *)&ia->ia_addr;
+ ifa->ifa_addr = (struct sockaddr *)&ia->ia_addr;
- ia->ia_ifa.ifa_netmask =
- (struct sockaddr *)&ipx_netmask;
+ ifa->ifa_netmask = (struct sockaddr *)&ipx_netmask;
- ia->ia_ifa.ifa_dstaddr =
- (struct sockaddr *)&ia->ia_dstaddr;
+ ifa->ifa_dstaddr = (struct sockaddr *)&ia->ia_dstaddr;
if (ifp->if_flags & IFF_BROADCAST) {
ia->ia_broadaddr.sipx_family = AF_IPX;
ia->ia_broadaddr.sipx_len = sizeof(ia->ia_addr);
@@ -188,17 +182,8 @@ ipx_control(so, cmd, data, ifp)
case SIOCDIFADDR:
ipx_ifscrub(ifp, ia);
- if ((ifa = ifp->if_addrlist) == (struct ifaddr *)ia)
- ifp->if_addrlist = ifa->ifa_next;
- else {
- while (ifa->ifa_next &&
- (ifa->ifa_next != (struct ifaddr *)ia))
- ifa = ifa->ifa_next;
- if (ifa->ifa_next)
- ifa->ifa_next = ((struct ifaddr *)ia)->ifa_next;
- else
- printf("Couldn't unlink ipxifaddr from ifp\n");
- }
+ ifa = (struct ifaddr *)ia;
+ TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
oia = ia;
if (oia == (ia = ipx_ifaddr)) {
ipx_ifaddr = ia->ia_next;
diff --git a/sys/netipx/ipx_input.c b/sys/netipx/ipx_input.c
index b49c79d..e1b5b8b 100644
--- a/sys/netipx/ipx_input.c
+++ b/sys/netipx/ipx_input.c
@@ -33,7 +33,7 @@
*
* @(#)ipx_input.c
*
- * $Id: ipx_input.c,v 1.8 1996/03/11 15:13:48 davidg Exp $
+ * $Id: ipx_input.c,v 1.9 1996/08/18 08:38:15 jhay Exp $
*/
#include <sys/param.h>
@@ -512,8 +512,8 @@ struct ifnet *ifp;
ipx->ipx_sna.x_net = ipx_zeronet;
ipx->ipx_sna.x_host = ipx_thishost;
if (ifp && (ifp->if_flags & IFF_POINTOPOINT))
- for(ifa = ifp->if_addrlist; ifa;
- ifa = ifa->ifa_next) {
+ for(ifa = ifp->if_addrhead.tqh_first; ifa;
+ ifa = ifa->ifa_link.tqe_next) {
if (ifa->ifa_addr->sa_family==AF_IPX) {
ipx->ipx_sna = IA_SIPX(ifa)->sipx_addr;
break;
diff --git a/sys/netipx/ipx_ip.c b/sys/netipx/ipx_ip.c
index e336205..d12a8ef 100644
--- a/sys/netipx/ipx_ip.c
+++ b/sys/netipx/ipx_ip.c
@@ -33,7 +33,7 @@
*
* @(#)ipx_ip.c
*
- * $Id: ipx_ip.c,v 1.8 1996/05/08 19:31:45 jhay Exp $
+ * $Id: ipx_ip.c,v 1.9 1996/06/12 05:10:27 gpalmer Exp $
*/
/*
@@ -334,11 +334,12 @@ ipxip_route(so, m)
register struct in_ifaddr *ia;
struct ifnet *ifp = ro.ro_rt->rt_ifp;
- for (ia = in_ifaddr; ia; ia = ia->ia_next)
+ for (ia = in_ifaddrhead.tqh_first; ia;
+ ia = ia->ia_link.tqe_next)
if (ia->ia_ifp == ifp)
break;
if (ia == 0)
- ia = in_ifaddr;
+ ia = in_ifaddrhead.tqh_first;
if (ia == 0) {
RTFREE(ro.ro_rt);
return (EADDRNOTAVAIL);
diff --git a/sys/netipx/ipx_usrreq.c b/sys/netipx/ipx_usrreq.c
index 9746f47..0601e93 100644
--- a/sys/netipx/ipx_usrreq.c
+++ b/sys/netipx/ipx_usrreq.c
@@ -33,7 +33,7 @@
*
* @(#)ipx_usrreq.c
*
- * $Id: ipx_usrreq.c,v 1.7 1996/05/08 19:31:48 jhay Exp $
+ * $Id: ipx_usrreq.c,v 1.8 1996/11/24 08:25:48 jhay Exp $
*/
#include <sys/param.h>
@@ -100,7 +100,8 @@ ipx_input(m, ipxp)
if (ipx_neteqnn(ipx->ipx_sna.x_net, ipx_zeronet) && ifp) {
register struct ifaddr *ifa;
- for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
+ for (ifa = ifp->if_addrhead.tqh_first; ifa;
+ ifa = ifa->ifa_link.tqe_next) {
if (ifa->ifa_addr->sa_family == AF_IPX) {
ipx_ipx.sipx_addr.x_net =
IA_SIPX(ifa)->sipx_addr.x_net;
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c
index 8a6bb0d..4405179 100644
--- a/sys/nfs/nfs_vnops.c
+++ b/sys/nfs/nfs_vnops.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94
- * $Id: nfs_vnops.c,v 1.36 1996/10/21 10:07:52 dfr Exp $
+ * $Id: nfs_vnops.c,v 1.37 1996/11/06 10:53:12 dfr Exp $
*/
/*
@@ -1391,8 +1391,8 @@ again:
if (fmode & O_EXCL) {
*tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE);
nfsm_build(tl, u_long *, NFSX_V3CREATEVERF);
- if (in_ifaddr)
- *tl++ = IA_SIN(in_ifaddr)->sin_addr.s_addr;
+ if (!TAILQ_EMPTY(&in_ifaddrhead))
+ *tl++ = IA_SIN(in_ifaddrhead.tqh_first)->sin_addr.s_addr;
else
*tl++ = create_verf;
*tl = ++create_verf;
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
index 8a6bb0d..4405179 100644
--- a/sys/nfsclient/nfs_vnops.c
+++ b/sys/nfsclient/nfs_vnops.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94
- * $Id: nfs_vnops.c,v 1.36 1996/10/21 10:07:52 dfr Exp $
+ * $Id: nfs_vnops.c,v 1.37 1996/11/06 10:53:12 dfr Exp $
*/
/*
@@ -1391,8 +1391,8 @@ again:
if (fmode & O_EXCL) {
*tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE);
nfsm_build(tl, u_long *, NFSX_V3CREATEVERF);
- if (in_ifaddr)
- *tl++ = IA_SIN(in_ifaddr)->sin_addr.s_addr;
+ if (!TAILQ_EMPTY(&in_ifaddrhead))
+ *tl++ = IA_SIN(in_ifaddrhead.tqh_first)->sin_addr.s_addr;
else
*tl++ = create_verf;
*tl = ++create_verf;
OpenPOWER on IntegriCloud