Various cleanup, including: trunk
authormycroft <mycroft@NetBSD.org>
Mon, 12 Jun 1995 00:46:47 +0000
branchtrunk
changeset 14288 3837529501c3
parent 14287 39191bd307d0
child 14289 a9135c098991
Various cleanup, including: * Convert several data structures to use queue.h. * Split in_pcbnotify() into two parts; one for notifying a specific PCB, and one for notifying all PCBs for a particular foreign address.
sys/lib/libsa/if_ether.h
sys/net/if.c
sys/net/if.h
sys/net/if_ethersubr.c
sys/net/raw_cb.c
sys/net/raw_cb.h
sys/net/raw_usrreq.c
sys/net/rtsock.c
sys/netinet/if_arp.c
sys/netinet/if_arp.h
sys/netinet/if_ether.c
sys/netinet/if_ether.h
sys/netinet/if_inarp.h
sys/netinet/in.c
sys/netinet/in_pcb.c
sys/netinet/in_pcb.h
sys/netinet/in_var.h
sys/netinet/ip_icmp.c
sys/netinet/ip_input.c
sys/netinet/ip_output.c
sys/netinet/ip_var.h
sys/netinet/raw_ip.c
sys/netinet/tcp_input.c
sys/netinet/tcp_subr.c
sys/netinet/tcp_timer.c
sys/netinet/tcp_usrreq.c
sys/netinet/tcp_var.h
sys/netinet/udp_usrreq.c
sys/netinet/udp_var.h
sys/nfs/nfs_boot.c
--- a/sys/lib/libsa/if_ether.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/lib/libsa/if_ether.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ether.h,v 1.19 1995/05/16 05:26:36 cgd Exp $	*/
+/*	$NetBSD: if_ether.h,v 1.20 1995/06/12 00:47:27 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -120,13 +120,12 @@
 	struct	 ifnet ac_if;			/* network-visible interface */
 	u_int8_t ac_enaddr[ETHER_ADDR_LEN];	/* ethernet hardware address */
 	struct	 in_addr ac_ipaddr;		/* copy of ip address- XXX */
-	struct	 ether_multi *ac_multiaddrs; /* list of ether multicast addrs */
+	LIST_HEAD(, ether_multi) ac_multiaddrs;	/* list of ether multicast addrs */
 	int	 ac_multicnt;			/* length of ac_multiaddrs list */
 };
 
 struct llinfo_arp {
-	struct	llinfo_arp *la_next;
-	struct	llinfo_arp *la_prev;
+	LIST_ENTRY(llinfo_arp) la_list;
 	struct	rtentry *la_rt;
 	struct	mbuf *la_hold;		/* last packet until resolved/timeout */
 	long	la_asked;		/* last time we QUERIED for this addr */
@@ -156,8 +155,6 @@
 u_int8_t ether_ipmulticast_max[ETHER_ADDR_LEN];
 struct	ifqueue arpintrq;
 
-struct	llinfo_arp llinfo_arp;		/* head of the llinfo queue */
-
 void	arpwhohas __P((struct arpcom *, struct in_addr *));
 void	arpintr __P((void));
 int	arpresolve __P((struct arpcom *,
@@ -182,7 +179,7 @@
 	u_int8_t enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */
 	struct	 arpcom *enm_ac;	/* back pointer to arpcom */
 	u_int	 enm_refcount;		/* no. claims to this addr/range */
-	struct	 ether_multi *enm_next;	/* ptr to next ether_multi */
+	LIST_ENTRY(ether_multi) enm_list;
 };
 
 /*
@@ -204,11 +201,11 @@
 	/* struct arpcom *ac; */					\
 	/* struct ether_multi *enm; */					\
 {									\
-	for ((enm) = (ac)->ac_multiaddrs;				\
+	for ((enm) = (ac)->ac_multiaddrs.lh_first;			\
 	    (enm) != NULL &&						\
 	    (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 ||	\
 	     bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0);	\
-		(enm) = (enm)->enm_next);				\
+		(enm) = (enm)->enm_list.le_next);			\
 }
 
 /*
@@ -223,7 +220,7 @@
 	/* struct ether_multi *enm; */  \
 { \
 	if (((enm) = (step).e_enm) != NULL) \
-		(step).e_enm = (enm)->enm_next; \
+		(step).e_enm = (enm)->enm_list.le_next; \
 }
 
 #define ETHER_FIRST_MULTI(step, ac, enm) \
@@ -231,6 +228,6 @@
 	/* struct arpcom *ac; */ \
 	/* struct ether_multi *enm; */ \
 { \
-	(step).e_enm = (ac)->ac_multiaddrs; \
+	(step).e_enm = (ac)->ac_multiaddrs.lh_first; \
 	ETHER_NEXT_MULTI((step), (enm)); \
 }
--- a/sys/net/if.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/net/if.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.20 1995/04/22 13:07:12 cgd Exp $	*/
+/*	$NetBSD: if.c,v 1.21 1995/06/12 00:46:47 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -63,7 +63,7 @@
 {
 	register struct ifnet *ifp;
 
-	for (ifp = ifnet; ifp; ifp = ifp->if_next)
+	for (ifp = ifnet.tqh_first; ifp != 0 ; ifp = ifp->if_list.tqe_next)
 		if (ifp->if_snd.ifq_maxlen == 0)
 			ifp->if_snd.ifq_maxlen = ifqmaxlen;
 	if_slowtimo(NULL);
@@ -84,16 +84,14 @@
 	unsigned socksize, ifasize;
 	int namelen, unitlen, masklen;
 	char workbuf[12], *unitname;
-	register struct ifnet **p = &ifnet;
 	register struct sockaddr_dl *sdl;
 	register struct ifaddr *ifa;
 	static int if_indexlim = 8;
 	extern void link_rtrequest();
 
-	while (*p)
-		p = &((*p)->if_next);
-	*p = ifp;
+	TAILQ_INSERT_TAIL(&ifnet, ifp, if_list);
 	ifp->if_index = ++if_index;
+	TAILQ_INIT(&ifp->if_addrlist);
 	if (ifnet_addrs == 0 || if_index >= if_indexlim) {
 		unsigned n = (if_indexlim <<= 1) * sizeof(ifa);
 		struct ifaddr **q = (struct ifaddr **)
@@ -120,8 +118,6 @@
 	socksize = ROUNDUP(socksize);
 	ifasize = sizeof(*ifa) + 2 * socksize;
 	ifa = (struct ifaddr *)malloc(ifasize, M_IFADDR, M_WAITOK);
-	if (ifa == 0)
-		return;
 	bzero((caddr_t)ifa, ifasize);
 	sdl = (struct sockaddr_dl *)(ifa + 1);
 	sdl->sdl_len = socksize;
@@ -133,9 +129,8 @@
 	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;
+	TAILQ_INSERT_HEAD(&ifp->if_addrlist, ifa, ifa_list);
 	ifa->ifa_addr = (struct sockaddr *)sdl;
 	sdl = (struct sockaddr_dl *)(socksize + (caddr_t)sdl);
 	ifa->ifa_netmask = (struct sockaddr *)sdl;
@@ -156,8 +151,8 @@
 
 #define	equal(a1, a2) \
   (bcmp((caddr_t)(a1), (caddr_t)(a2), ((struct sockaddr *)(a1))->sa_len) == 0)
-	for (ifp = ifnet; ifp; ifp = ifp->if_next)
-	    for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
+	for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
+	    for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next) {
 		if (ifa->ifa_addr->sa_family != addr->sa_family)
 			continue;
 		if (equal(addr, ifa->ifa_addr))
@@ -179,9 +174,9 @@
 	register struct ifnet *ifp;
 	register struct ifaddr *ifa;
 
-	for (ifp = ifnet; ifp; ifp = ifp->if_next) 
+	for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
 	    if (ifp->if_flags & IFF_POINTOPOINT)
-		for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
+		for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next) {
 			if (ifa->ifa_addr->sa_family != addr->sa_family)
 				continue;
 			if (equal(addr, ifa->ifa_dstaddr))
@@ -209,8 +204,8 @@
 	    if (sdl->sdl_index && sdl->sdl_index <= if_index)
 		return (ifnet_addrs[sdl->sdl_index - 1]);
 	}
-	for (ifp = ifnet; ifp; ifp = ifp->if_next)
-		for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
+	for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
+		for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next) {
 			register char *cp, *cp2, *cp3;
 
 			if (ifa->ifa_addr->sa_family != af ||
@@ -242,10 +237,10 @@
 	register struct ifnet *ifp;
 	register struct ifaddr *ifa;
 
-	for (ifp = ifnet; ifp; ifp = ifp->if_next)
-	    for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
-		if (ifa->ifa_addr->sa_family == af)
-			return (ifa);
+	for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
+		for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next)
+			if (ifa->ifa_addr->sa_family == af)
+				return (ifa);
 	return ((struct ifaddr *)0);
 }
 
@@ -266,7 +261,7 @@
 
 	if (af >= AF_MAX)
 		return (0);
-	for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next) {
+	for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next) {
 		if (ifa->ifa_addr->sa_family != af)
 			continue;
 		ifa_maybe = ifa;
@@ -330,7 +325,7 @@
 	register struct ifaddr *ifa;
 
 	ifp->if_flags &= ~IFF_UP;
-	for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
+	for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next)
 		pfctlinput(PRC_IFDOWN, ifa->ifa_addr);
 	if_qflush(&ifp->if_snd);
 	rt_ifmsg(ifp);
@@ -350,7 +345,7 @@
 	ifp->if_flags |= IFF_UP;
 #ifdef notyet
 	/* this has no effect on IP, and will kill all ISO connections XXX */
-	for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
+	for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next)
 		pfctlinput(PRC_IFUP, ifa->ifa_addr);
 #endif
 	rt_ifmsg(ifp);
@@ -387,7 +382,7 @@
 	register struct ifnet *ifp;
 	int s = splimp();
 
-	for (ifp = ifnet; ifp; ifp = ifp->if_next) {
+	for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) {
 		if (ifp->if_timer == 0 || --ifp->if_timer)
 			continue;
 		if (ifp->if_watchdog)
@@ -427,7 +422,7 @@
 	for (unit = 0; *cp >= '0' && *cp <= '9'; )
 		unit = unit * 10 + *cp++ - '0';
 	*ep = 0;
-	for (ifp = ifnet; ifp; ifp = ifp->if_next) {
+	for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) {
 		if (bcmp(ifp->if_name, name, len))
 			continue;
 		if (unit == ifp->if_unit)
@@ -578,7 +573,7 @@
 	caddr_t data;
 {
 	register struct ifconf *ifc = (struct ifconf *)data;
-	register struct ifnet *ifp = ifnet;
+	register struct ifnet *ifp;
 	register struct ifaddr *ifa;
 	register char *cp, *ep;
 	struct ifreq ifr, *ifrp;
@@ -586,12 +581,13 @@
 
 	ifrp = ifc->ifc_req;
 	ep = ifr.ifr_name + sizeof (ifr.ifr_name) - 2;
-	for (; space > sizeof (ifr) && ifp; ifp = ifp->if_next) {
+	for (ifp = ifnet.tqh_first;
+	    space > sizeof (ifr) && ifp != 0; ifp = ifp->if_list.tqe_next) {
 		strncpy(ifr.ifr_name, ifp->if_name, sizeof(ifr.ifr_name) - 2);
 		for (cp = ifr.ifr_name; cp < ep && *cp; cp++)
 			continue;
 		*cp++ = '0' + ifp->if_unit; *cp = '\0';
-		if ((ifa = ifp->if_addrlist) == 0) {
+		if ((ifa = ifp->if_addrlist.tqh_first) == 0) {
 			bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
 			error = copyout((caddr_t)&ifr, (caddr_t)ifrp,
 			    sizeof(ifr));
@@ -599,7 +595,7 @@
 				break;
 			space -= sizeof (ifr), ifrp++;
 		} else 
-		    for ( ; space > sizeof (ifr) && ifa; ifa = ifa->ifa_next) {
+		    for (; space > sizeof (ifr) && ifa != 0; ifa = ifa->ifa_list.tqe_next) {
 			register struct sockaddr *sa = ifa->ifa_addr;
 #ifdef COMPAT_43
 			if (cmd == OSIOCGIFCONF) {
--- a/sys/net/if.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/net/if.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.16 1995/04/07 22:20:24 mycroft Exp $	*/
+/*	$NetBSD: if.h,v 1.17 1995/06/12 00:46:50 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -35,6 +35,8 @@
  *	@(#)if.h	8.1 (Berkeley) 6/10/93
  */
 
+#include <sys/queue.h>
+
 /*
  * Structures defining a network interface, providing a packet
  * transport mechanism (ala level 0 of the PUP protocols).
@@ -102,8 +104,8 @@
  */
 struct ifnet {
 	char	*if_name;		/* name, e.g. ``en'' or ``lo'' */
-	struct	ifnet *if_next;		/* all struct ifnets are chained */
-	struct	ifaddr *if_addrlist;	/* linked list of addresses per if */
+	TAILQ_ENTRY(ifnet) if_list;	/* all struct ifnets are chained */
+	TAILQ_HEAD(, ifaddr) if_addrlist; /* linked list of addresses per if */
 	int	if_pcount;		/* number of promiscuous listeners */
 	caddr_t	if_bpf;			/* packet filter structure */
 	u_short	if_index;		/* numeric abbreviation for this if */
@@ -221,7 +223,7 @@
 #define	ifa_broadaddr	ifa_dstaddr	/* broadcast address interface */
 	struct	sockaddr *ifa_netmask;	/* used to determine subnet */
 	struct	ifnet *ifa_ifp;		/* back-pointer to interface */
-	struct	ifaddr *ifa_next;	/* next address for interface */
+	TAILQ_ENTRY(ifaddr) ifa_list;	/* list of addresses for interface */
 	void	(*ifa_rtrequest)();	/* check or clean routes (+ or -)'d */
 	u_short	ifa_flags;		/* mostly rt_flags for cloning */
 	short	ifa_refcnt;		/* count of references */
@@ -314,7 +316,7 @@
 	else \
 		(ifa)->ifa_refcnt--;
 
-struct	ifnet	*ifnet;
+TAILQ_HEAD(, ifnet) ifnet;
 
 void	ether_ifattach __P((struct ifnet *));
 void	ether_input __P((struct ifnet *, struct ether_header *, struct mbuf *));
--- a/sys/net/if_ethersubr.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/net/if_ethersubr.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.12 1995/04/07 22:19:29 mycroft Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.13 1995/06/12 00:46:52 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1989, 1993
@@ -504,7 +504,8 @@
 	ifp->if_hdrlen = 14;
 	ifp->if_mtu = ETHERMTU;
 	ifp->if_output = ether_output;
-	for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
+	for (ifa = ifp->if_addrlist.tqh_first; ifa != 0;
+	    ifa = ifa->ifa_list.tqe_next)
 		if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) &&
 		    sdl->sdl_family == AF_LINK) {
 			sdl->sdl_type = IFT_ETHER;
@@ -513,6 +514,7 @@
 			      LLADDR(sdl), ifp->if_addrlen);
 			break;
 		}
+	LIST_INIT(&((struct arpcom *)ifp)->ac_multiaddrs);
 }
 
 u_char	ether_ipmulticast_min[6] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 };
@@ -595,8 +597,7 @@
 	bcopy(addrhi, enm->enm_addrhi, 6);
 	enm->enm_ac = ac;
 	enm->enm_refcount = 1;
-	enm->enm_next = ac->ac_multiaddrs;
-	ac->ac_multiaddrs = enm;
+	LIST_INSERT_HEAD(&ac->ac_multiaddrs, enm, enm_list);
 	ac->ac_multicnt++;
 	splx(s);
 	/*
@@ -670,11 +671,7 @@
 	/*
 	 * No remaining claims to this record; unlink and free it.
 	 */
-	for (p = &enm->enm_ac->ac_multiaddrs;
-	     *p != enm;
-	     p = &(*p)->enm_next)
-		continue;
-	*p = (*p)->enm_next;
+	LIST_REMOVE(enm, enm_list);
 	free(enm, M_IFMADDR);
 	ac->ac_multicnt--;
 	splx(s);
--- a/sys/net/raw_cb.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/net/raw_cb.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_cb.c,v 1.7 1994/06/29 06:36:37 cgd Exp $	*/
+/*	$NetBSD: raw_cb.c,v 1.8 1995/06/12 00:46:53 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -85,7 +85,7 @@
 	rp->rcb_socket = so;
 	rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family;
 	rp->rcb_proto.sp_protocol = proto;
-	insque(rp, &rawcb);
+	LIST_INSERT_HEAD(&rawcb, rp, rcb_list);
 	return (0);
 }
 
@@ -101,7 +101,7 @@
 
 	so->so_pcb = 0;
 	sofree(so);
-	remque(rp);
+	LIST_REMOVE(rp, rcb_list);
 #ifdef notdef
 	if (rp->rcb_laddr)
 		m_freem(dtom(rp->rcb_laddr));
--- a/sys/net/raw_cb.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/net/raw_cb.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_cb.h,v 1.7 1995/03/26 20:30:18 jtc Exp $	*/
+/*	$NetBSD: raw_cb.h,v 1.8 1995/06/12 00:46:54 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -40,8 +40,7 @@
  * to tie a socket to the generic raw interface.
  */
 struct rawcb {
-	struct	rawcb *rcb_next;	/* doubly linked list */
-	struct	rawcb *rcb_prev;
+	LIST_ENTRY(rawcb) rcb_list;	/* doubly linked list */
 	struct	socket *rcb_socket;	/* back pointer to socket */
 	struct	sockaddr *rcb_faddr;	/* destination address */
 	struct	sockaddr *rcb_laddr;	/* socket's address */
@@ -57,7 +56,7 @@
 #define	RAWRCVQ		8192
 
 #ifdef _KERNEL
-struct rawcb rawcb;			/* head of list */
+LIST_HEAD(, rawcb) rawcb;		/* head of list */
 
 int	 raw_attach __P((struct socket *, int));
 void	 raw_ctlinput __P((int, struct sockaddr *));
--- a/sys/net/raw_usrreq.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/net/raw_usrreq.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_usrreq.c,v 1.9 1995/04/22 13:08:30 cgd Exp $	*/
+/*	$NetBSD: raw_usrreq.c,v 1.10 1995/06/12 00:46:55 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -55,7 +55,7 @@
 raw_init()
 {
 
-	rawcb.rcb_next = rawcb.rcb_prev = &rawcb;
+	LIST_INIT(&rawcb);
 }
 
 
@@ -79,7 +79,7 @@
 	struct socket *last;
 
 	last = 0;
-	for (rp = rawcb.rcb_next; rp != &rawcb; rp = rp->rcb_next) {
+	for (rp = rawcb.lh_first; rp != 0; rp = rp->rcb_list.le_next) {
 		if (rp->rcb_proto.sp_family != proto->sp_family)
 			continue;
 		if (rp->rcb_proto.sp_protocol  &&
--- a/sys/net/rtsock.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/net/rtsock.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock.c,v 1.12 1995/03/08 02:57:16 cgd Exp $	*/
+/*	$NetBSD: rtsock.c,v 1.13 1995/06/12 00:46:57 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1988, 1991, 1993
@@ -224,7 +224,7 @@
 			genmask = rt->rt_genmask;
 			if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) {
 				if (ifp = rt->rt_ifp) {
-					ifpaddr = ifp->if_addrlist->ifa_addr;
+					ifpaddr = ifp->if_addrlist.tqh_first->ifa_addr;
 					ifaaddr = rt->rt_ifa->ifa_addr;
 					rtm->rtm_index = ifp->if_index;
 				} else {
@@ -635,7 +635,7 @@
 			int ncmd = cmd == RTM_ADD ? RTM_NEWADDR : RTM_DELADDR;
 
 			ifaaddr = sa = ifa->ifa_addr;
-			ifpaddr = ifp->if_addrlist->ifa_addr;
+			ifpaddr = ifp->if_addrlist.tqh_first->ifa_addr;
 			netmask = ifa->ifa_netmask;
 			brdaddr = ifa->ifa_dstaddr;
 			if ((m = rt_msg1(ncmd, &info)) == NULL)
@@ -716,10 +716,10 @@
 	int	len, error = 0;
 
 	bzero((caddr_t)&info, sizeof(info));
-	for (ifp = ifnet; ifp; ifp = ifp->if_next) {
+	for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) {
 		if (w->w_arg && w->w_arg != ifp->if_index)
 			continue;
-		ifa = ifp->if_addrlist;
+		ifa = ifp->if_addrlist.tqh_first;
 		ifpaddr = ifa->ifa_addr;
 		len = rt_msg2(RTM_IFINFO, &info, (caddr_t)0, w);
 		ifpaddr = 0;
@@ -735,7 +735,7 @@
 				return (error);
 			w->w_where += len;
 		}
-		while (ifa = ifa->ifa_next) {
+		while (ifa = ifa->ifa_list.tqe_next) {
 			if (af && af != ifa->ifa_addr->sa_family)
 				continue;
 			ifaaddr = ifa->ifa_addr;
--- a/sys/netinet/if_arp.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/if_arp.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.25 1995/06/04 05:06:49 mycroft Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.26 1995/06/12 00:47:23 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
@@ -88,7 +88,7 @@
 static	void in_arpinput __P((struct mbuf *));
 
 extern	struct ifnet loif;
-struct	llinfo_arp llinfo_arp = {&llinfo_arp, &llinfo_arp};
+LIST_HEAD(, llinfo_arp) llinfo_arp;
 struct	ifqueue arpintrq = {0, 0, 0, 50};
 int	arp_inuse, arp_allocated, arp_intimer;
 int	arp_maxtries = 5;
@@ -109,16 +109,17 @@
 arptimer(arg)
 	void *arg;
 {
-	int s = splnet();
-	register struct llinfo_arp *la = llinfo_arp.la_next;
+	int s;
+	register struct llinfo_arp *la, *nla;
 
+	s = splnet();
 	timeout(arptimer, NULL, arpt_prune * hz);
-	while (la != &llinfo_arp) {
+	for (la = llinfo_arp.lh_first; la != 0; la = nla) {
 		register struct rtentry *rt = la->la_rt;
 
-		la = la->la_next;
+		nla = la->la_list.le_next;
 		if (rt->rt_expire && rt->rt_expire <= time.tv_sec)
-			arptfree(la->la_prev); /* timer has expired; clear */
+			arptfree(la); /* timer has expired; clear */
 	}
 	splx(s);
 }
@@ -208,7 +209,7 @@
 		Bzero(la, sizeof(*la));
 		la->la_rt = rt;
 		rt->rt_flags |= RTF_LLINFO;
-		insque(la, &llinfo_arp);
+		LIST_INSERT_HEAD(&llinfo_arp, la, la_list);
 		if (SIN(rt_key(rt))->sin_addr.s_addr ==
 		    (IA_SIN(rt->rt_ifa))->sin_addr.s_addr) {
 			/*
@@ -235,7 +236,7 @@
 		if (la == 0)
 			break;
 		arp_inuse--;
-		remque(la);
+		LIST_REMOVE(la, la_list);
 		rt->rt_llinfo = 0;
 		rt->rt_flags &= ~RTF_LLINFO;
 		if (la->la_hold)
@@ -448,11 +449,11 @@
 	op = ntohs(ea->arp_op);
 	bcopy((caddr_t)ea->arp_spa, (caddr_t)&isaddr, sizeof (isaddr));
 	bcopy((caddr_t)ea->arp_tpa, (caddr_t)&itaddr, sizeof (itaddr));
-	for (ia = in_ifaddr; ia; ia = ia->ia_next)
+	for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
 		if (ia->ia_ifp == &ac->ac_if) {
 			maybe_ia = ia;
-			if ((itaddr.s_addr == ia->ia_addr.sin_addr.s_addr) ||
-			     (isaddr.s_addr == ia->ia_addr.sin_addr.s_addr))
+			if (itaddr.s_addr == ia->ia_addr.sin_addr.s_addr ||
+			    isaddr.s_addr == ia->ia_addr.sin_addr.s_addr)
 				break;
 		}
 	if (maybe_ia == 0)
--- a/sys/netinet/if_arp.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/if_arp.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.h,v 1.19 1995/05/16 05:26:36 cgd Exp $	*/
+/*	$NetBSD: if_arp.h,v 1.20 1995/06/12 00:47:27 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -120,13 +120,12 @@
 	struct	 ifnet ac_if;			/* network-visible interface */
 	u_int8_t ac_enaddr[ETHER_ADDR_LEN];	/* ethernet hardware address */
 	struct	 in_addr ac_ipaddr;		/* copy of ip address- XXX */
-	struct	 ether_multi *ac_multiaddrs; /* list of ether multicast addrs */
+	LIST_HEAD(, ether_multi) ac_multiaddrs;	/* list of ether multicast addrs */
 	int	 ac_multicnt;			/* length of ac_multiaddrs list */
 };
 
 struct llinfo_arp {
-	struct	llinfo_arp *la_next;
-	struct	llinfo_arp *la_prev;
+	LIST_ENTRY(llinfo_arp) la_list;
 	struct	rtentry *la_rt;
 	struct	mbuf *la_hold;		/* last packet until resolved/timeout */
 	long	la_asked;		/* last time we QUERIED for this addr */
@@ -156,8 +155,6 @@
 u_int8_t ether_ipmulticast_max[ETHER_ADDR_LEN];
 struct	ifqueue arpintrq;
 
-struct	llinfo_arp llinfo_arp;		/* head of the llinfo queue */
-
 void	arpwhohas __P((struct arpcom *, struct in_addr *));
 void	arpintr __P((void));
 int	arpresolve __P((struct arpcom *,
@@ -182,7 +179,7 @@
 	u_int8_t enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */
 	struct	 arpcom *enm_ac;	/* back pointer to arpcom */
 	u_int	 enm_refcount;		/* no. claims to this addr/range */
-	struct	 ether_multi *enm_next;	/* ptr to next ether_multi */
+	LIST_ENTRY(ether_multi) enm_list;
 };
 
 /*
@@ -204,11 +201,11 @@
 	/* struct arpcom *ac; */					\
 	/* struct ether_multi *enm; */					\
 {									\
-	for ((enm) = (ac)->ac_multiaddrs;				\
+	for ((enm) = (ac)->ac_multiaddrs.lh_first;			\
 	    (enm) != NULL &&						\
 	    (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 ||	\
 	     bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0);	\
-		(enm) = (enm)->enm_next);				\
+		(enm) = (enm)->enm_list.le_next);			\
 }
 
 /*
@@ -223,7 +220,7 @@
 	/* struct ether_multi *enm; */  \
 { \
 	if (((enm) = (step).e_enm) != NULL) \
-		(step).e_enm = (enm)->enm_next; \
+		(step).e_enm = (enm)->enm_list.le_next; \
 }
 
 #define ETHER_FIRST_MULTI(step, ac, enm) \
@@ -231,6 +228,6 @@
 	/* struct arpcom *ac; */ \
 	/* struct ether_multi *enm; */ \
 { \
-	(step).e_enm = (ac)->ac_multiaddrs; \
+	(step).e_enm = (ac)->ac_multiaddrs.lh_first; \
 	ETHER_NEXT_MULTI((step), (enm)); \
 }
--- a/sys/netinet/if_ether.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/if_ether.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ether.c,v 1.25 1995/06/04 05:06:49 mycroft Exp $	*/
+/*	$NetBSD: if_ether.c,v 1.26 1995/06/12 00:47:23 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
@@ -88,7 +88,7 @@
 static	void in_arpinput __P((struct mbuf *));
 
 extern	struct ifnet loif;
-struct	llinfo_arp llinfo_arp = {&llinfo_arp, &llinfo_arp};
+LIST_HEAD(, llinfo_arp) llinfo_arp;
 struct	ifqueue arpintrq = {0, 0, 0, 50};
 int	arp_inuse, arp_allocated, arp_intimer;
 int	arp_maxtries = 5;
@@ -109,16 +109,17 @@
 arptimer(arg)
 	void *arg;
 {
-	int s = splnet();
-	register struct llinfo_arp *la = llinfo_arp.la_next;
+	int s;
+	register struct llinfo_arp *la, *nla;
 
+	s = splnet();
 	timeout(arptimer, NULL, arpt_prune * hz);
-	while (la != &llinfo_arp) {
+	for (la = llinfo_arp.lh_first; la != 0; la = nla) {
 		register struct rtentry *rt = la->la_rt;
 
-		la = la->la_next;
+		nla = la->la_list.le_next;
 		if (rt->rt_expire && rt->rt_expire <= time.tv_sec)
-			arptfree(la->la_prev); /* timer has expired; clear */
+			arptfree(la); /* timer has expired; clear */
 	}
 	splx(s);
 }
@@ -208,7 +209,7 @@
 		Bzero(la, sizeof(*la));
 		la->la_rt = rt;
 		rt->rt_flags |= RTF_LLINFO;
-		insque(la, &llinfo_arp);
+		LIST_INSERT_HEAD(&llinfo_arp, la, la_list);
 		if (SIN(rt_key(rt))->sin_addr.s_addr ==
 		    (IA_SIN(rt->rt_ifa))->sin_addr.s_addr) {
 			/*
@@ -235,7 +236,7 @@
 		if (la == 0)
 			break;
 		arp_inuse--;
-		remque(la);
+		LIST_REMOVE(la, la_list);
 		rt->rt_llinfo = 0;
 		rt->rt_flags &= ~RTF_LLINFO;
 		if (la->la_hold)
@@ -448,11 +449,11 @@
 	op = ntohs(ea->arp_op);
 	bcopy((caddr_t)ea->arp_spa, (caddr_t)&isaddr, sizeof (isaddr));
 	bcopy((caddr_t)ea->arp_tpa, (caddr_t)&itaddr, sizeof (itaddr));
-	for (ia = in_ifaddr; ia; ia = ia->ia_next)
+	for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
 		if (ia->ia_ifp == &ac->ac_if) {
 			maybe_ia = ia;
-			if ((itaddr.s_addr == ia->ia_addr.sin_addr.s_addr) ||
-			     (isaddr.s_addr == ia->ia_addr.sin_addr.s_addr))
+			if (itaddr.s_addr == ia->ia_addr.sin_addr.s_addr ||
+			    isaddr.s_addr == ia->ia_addr.sin_addr.s_addr)
 				break;
 		}
 	if (maybe_ia == 0)
--- a/sys/netinet/if_ether.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/if_ether.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ether.h,v 1.19 1995/05/16 05:26:36 cgd Exp $	*/
+/*	$NetBSD: if_ether.h,v 1.20 1995/06/12 00:47:27 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -120,13 +120,12 @@
 	struct	 ifnet ac_if;			/* network-visible interface */
 	u_int8_t ac_enaddr[ETHER_ADDR_LEN];	/* ethernet hardware address */
 	struct	 in_addr ac_ipaddr;		/* copy of ip address- XXX */
-	struct	 ether_multi *ac_multiaddrs; /* list of ether multicast addrs */
+	LIST_HEAD(, ether_multi) ac_multiaddrs;	/* list of ether multicast addrs */
 	int	 ac_multicnt;			/* length of ac_multiaddrs list */
 };
 
 struct llinfo_arp {
-	struct	llinfo_arp *la_next;
-	struct	llinfo_arp *la_prev;
+	LIST_ENTRY(llinfo_arp) la_list;
 	struct	rtentry *la_rt;
 	struct	mbuf *la_hold;		/* last packet until resolved/timeout */
 	long	la_asked;		/* last time we QUERIED for this addr */
@@ -156,8 +155,6 @@
 u_int8_t ether_ipmulticast_max[ETHER_ADDR_LEN];
 struct	ifqueue arpintrq;
 
-struct	llinfo_arp llinfo_arp;		/* head of the llinfo queue */
-
 void	arpwhohas __P((struct arpcom *, struct in_addr *));
 void	arpintr __P((void));
 int	arpresolve __P((struct arpcom *,
@@ -182,7 +179,7 @@
 	u_int8_t enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */
 	struct	 arpcom *enm_ac;	/* back pointer to arpcom */
 	u_int	 enm_refcount;		/* no. claims to this addr/range */
-	struct	 ether_multi *enm_next;	/* ptr to next ether_multi */
+	LIST_ENTRY(ether_multi) enm_list;
 };
 
 /*
@@ -204,11 +201,11 @@
 	/* struct arpcom *ac; */					\
 	/* struct ether_multi *enm; */					\
 {									\
-	for ((enm) = (ac)->ac_multiaddrs;				\
+	for ((enm) = (ac)->ac_multiaddrs.lh_first;			\
 	    (enm) != NULL &&						\
 	    (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 ||	\
 	     bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0);	\
-		(enm) = (enm)->enm_next);				\
+		(enm) = (enm)->enm_list.le_next);			\
 }
 
 /*
@@ -223,7 +220,7 @@
 	/* struct ether_multi *enm; */  \
 { \
 	if (((enm) = (step).e_enm) != NULL) \
-		(step).e_enm = (enm)->enm_next; \
+		(step).e_enm = (enm)->enm_list.le_next; \
 }
 
 #define ETHER_FIRST_MULTI(step, ac, enm) \
@@ -231,6 +228,6 @@
 	/* struct arpcom *ac; */ \
 	/* struct ether_multi *enm; */ \
 { \
-	(step).e_enm = (ac)->ac_multiaddrs; \
+	(step).e_enm = (ac)->ac_multiaddrs.lh_first; \
 	ETHER_NEXT_MULTI((step), (enm)); \
 }
--- a/sys/netinet/if_inarp.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/if_inarp.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_inarp.h,v 1.19 1995/05/16 05:26:36 cgd Exp $	*/
+/*	$NetBSD: if_inarp.h,v 1.20 1995/06/12 00:47:27 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -120,13 +120,12 @@
 	struct	 ifnet ac_if;			/* network-visible interface */
 	u_int8_t ac_enaddr[ETHER_ADDR_LEN];	/* ethernet hardware address */
 	struct	 in_addr ac_ipaddr;		/* copy of ip address- XXX */
-	struct	 ether_multi *ac_multiaddrs; /* list of ether multicast addrs */
+	LIST_HEAD(, ether_multi) ac_multiaddrs;	/* list of ether multicast addrs */
 	int	 ac_multicnt;			/* length of ac_multiaddrs list */
 };
 
 struct llinfo_arp {
-	struct	llinfo_arp *la_next;
-	struct	llinfo_arp *la_prev;
+	LIST_ENTRY(llinfo_arp) la_list;
 	struct	rtentry *la_rt;
 	struct	mbuf *la_hold;		/* last packet until resolved/timeout */
 	long	la_asked;		/* last time we QUERIED for this addr */
@@ -156,8 +155,6 @@
 u_int8_t ether_ipmulticast_max[ETHER_ADDR_LEN];
 struct	ifqueue arpintrq;
 
-struct	llinfo_arp llinfo_arp;		/* head of the llinfo queue */
-
 void	arpwhohas __P((struct arpcom *, struct in_addr *));
 void	arpintr __P((void));
 int	arpresolve __P((struct arpcom *,
@@ -182,7 +179,7 @@
 	u_int8_t enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */
 	struct	 arpcom *enm_ac;	/* back pointer to arpcom */
 	u_int	 enm_refcount;		/* no. claims to this addr/range */
-	struct	 ether_multi *enm_next;	/* ptr to next ether_multi */
+	LIST_ENTRY(ether_multi) enm_list;
 };
 
 /*
@@ -204,11 +201,11 @@
 	/* struct arpcom *ac; */					\
 	/* struct ether_multi *enm; */					\
 {									\
-	for ((enm) = (ac)->ac_multiaddrs;				\
+	for ((enm) = (ac)->ac_multiaddrs.lh_first;			\
 	    (enm) != NULL &&						\
 	    (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 ||	\
 	     bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0);	\
-		(enm) = (enm)->enm_next);				\
+		(enm) = (enm)->enm_list.le_next);			\
 }
 
 /*
@@ -223,7 +220,7 @@
 	/* struct ether_multi *enm; */  \
 { \
 	if (((enm) = (step).e_enm) != NULL) \
-		(step).e_enm = (enm)->enm_next; \
+		(step).e_enm = (enm)->enm_list.le_next; \
 }
 
 #define ETHER_FIRST_MULTI(step, ac, enm) \
@@ -231,6 +228,6 @@
 	/* struct arpcom *ac; */ \
 	/* struct ether_multi *enm; */ \
 { \
-	(step).e_enm = (ac)->ac_multiaddrs; \
+	(step).e_enm = (ac)->ac_multiaddrs.lh_first; \
 	ETHER_NEXT_MULTI((step), (enm)); \
 }
--- a/sys/netinet/in.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/in.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: in.c,v 1.23 1995/06/04 06:46:05 mycroft Exp $	*/
+/*	$NetBSD: in.c,v 1.24 1995/06/12 00:47:29 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -72,11 +72,11 @@
 	register struct in_ifaddr *ia;
 
 	if (subnetsarelocal) {
-		for (ia = in_ifaddr; ia; ia = ia->ia_next)
+		for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
 			if ((in.s_addr & ia->ia_netmask) == ia->ia_net)
 				return (1);
 	} else {
-		for (ia = in_ifaddr; ia; ia = ia->ia_next)
+		for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next)
 			if ((in.s_addr & ia->ia_subnetmask) == ia->ia_subnet)
 				return (1);
 	}
@@ -139,7 +139,6 @@
 	register struct ifreq *ifr = (struct ifreq *)data;
 	register struct in_ifaddr *ia = 0;
 	register struct ifaddr *ifa;
-	struct in_ifaddr *oia;
 	struct in_aliasreq *ifra = (struct in_aliasreq *)data;
 	struct sockaddr_in oldaddr;
 	int error, hostIsNew, maskIsNew;
@@ -148,7 +147,7 @@
 	 * Find address for this interface, if it exists.
 	 */
 	if (ifp)
-		for (ia = in_ifaddr; ia; ia = ia->ia_next)
+		for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next)
 			if (ia->ia_ifp == ifp)
 				break;
 
@@ -157,7 +156,7 @@
 	case SIOCAIFADDR:
 	case SIOCDIFADDR:
 		if (ifra->ifra_addr.sin_family == AF_INET)
-		    for (oia = ia; ia; ia = ia->ia_next) {
+		    for (; ia != 0; ia = ia->ia_list.tqe_next) {
 			if (ia->ia_ifp == ifp  &&
 			    ia->ia_addr.sin_addr.s_addr ==
 				ifra->ifra_addr.sin_addr.s_addr)
@@ -175,24 +174,14 @@
 		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 *)0)
+			ia = (struct in_ifaddr *)
+				malloc(sizeof *ia, M_IFADDR, M_WAITOK);
+			if (ia == (struct in_ifaddr *)0)
 				return (ENOBUFS);
-			bzero((caddr_t)oia, sizeof *oia);
-			if (ia = in_ifaddr) {
-				for ( ; ia->ia_next; ia = ia->ia_next)
-					continue;
-				ia->ia_next = oia;
-			} else
-				in_ifaddr = oia;
-			ia = oia;
-			if (ifa = ifp->if_addrlist) {
-				for ( ; ifa->ifa_next; ifa = ifa->ifa_next)
-					continue;
-				ifa->ifa_next = (struct ifaddr *) ia;
-			} else
-				ifp->if_addrlist = (struct ifaddr *) ia;
+			bzero((caddr_t)ia, sizeof *ia);
+			TAILQ_INSERT_TAIL(&in_ifaddr, ia, ia_list);
+			TAILQ_INSERT_TAIL(&ifp->if_addrlist, (struct ifaddr *)ia,
+			    ifa_list);
 			ia->ia_ifa.ifa_addr = sintosa(&ia->ia_addr);
 			ia->ia_ifa.ifa_dstaddr = sintosa(&ia->ia_dstaddr);
 			ia->ia_ifa.ifa_netmask = sintosa(&ia->ia_sockmask);
@@ -202,6 +191,7 @@
 				ia->ia_broadaddr.sin_family = AF_INET;
 			}
 			ia->ia_ifp = ifp;
+			LIST_INIT(&ia->ia_multiaddrs);
 			if ((ifp->if_flags & IFF_LOOPBACK) == 0)
 				in_interfaces++;
 		}
@@ -308,29 +298,9 @@
 
 	case SIOCDIFADDR:
 		in_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 inifaddr from ifp\n");
-		}
-		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");
-		}
-		IFAFREE((&oia->ia_ifa));
+		TAILQ_REMOVE(&ifp->if_addrlist, (struct ifaddr *)ia, ifa_list);
+		TAILQ_REMOVE(&in_ifaddr, ia, ia_list);
+		IFAFREE((&ia->ia_ifa));
 		break;
 
 #ifdef MROUTING
@@ -471,7 +441,7 @@
 	 * with a broadcast address.
 	 */
 #define ia (ifatoia(ifa))
-	for (ifa = ifp->if_addrlist; ifa; ifa = ifa->ifa_next)
+	for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.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 ||
@@ -507,8 +477,7 @@
 		 * Found it; just increment the reference count.
 		 */
 		++inm->inm_refcount;
-	}
-	else {
+	} else {
 		/*
 		 * New address; allocate a new multicast record
 		 * and link it into the interface's multicast list.
@@ -529,8 +498,7 @@
 			return (NULL);
 		}
 		inm->inm_ia = ia;
-		inm->inm_next = ia->ia_multiaddrs;
-		ia->ia_multiaddrs = inm;
+		LIST_INSERT_HEAD(&ia->ia_multiaddrs, inm, inm_list);
 		/*
 		 * Ask the network driver to update its multicast reception
 		 * filter appropriately for the new address.
@@ -540,7 +508,7 @@
 		satosin(&ifr.ifr_addr)->sin_addr = *ap;
 		if ((ifp->if_ioctl == NULL) ||
 		    (*ifp->if_ioctl)(ifp, SIOCADDMULTI,(caddr_t)&ifr) != 0) {
-			ia->ia_multiaddrs = inm->inm_next;
+			LIST_REMOVE(inm, inm_list);
 			free(inm, M_IPMADDR);
 			splx(s);
 			return (NULL);
@@ -561,7 +529,6 @@
 in_delmulti(inm)
 	register struct in_multi *inm;
 {
-	register struct in_multi **p;
 	struct ifreq ifr;
 	int s = splnet();
 
@@ -574,11 +541,7 @@
 		/*
 		 * Unlink from list.
 		 */
-		for (p = &inm->inm_ia->ia_multiaddrs;
-		     *p != inm;
-		     p = &(*p)->inm_next)
-			 continue;
-		*p = (*p)->inm_next;
+		LIST_REMOVE(inm, inm_list);
 		/*
 		 * Notify the network driver to update its multicast reception
 		 * filter.
--- a/sys/netinet/in_pcb.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/in_pcb.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_pcb.c,v 1.17 1995/06/04 06:03:53 mycroft Exp $	*/
+/*	$NetBSD: in_pcb.c,v 1.18 1995/06/12 00:47:33 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -59,10 +59,19 @@
 
 struct	in_addr zeroin_addr;
 
+void
+in_pcbinit(table)
+	struct inpcbtable *table;
+{
+
+	LIST_INIT(&table->inpt_list);
+	table->inpt_lastport = 0;
+}
+
 int
-in_pcballoc(so, head)
+in_pcballoc(so, table)
 	struct socket *so;
-	struct inpcb *head;
+	struct inpcbtable *table;
 {
 	register struct inpcb *inp;
 
@@ -70,9 +79,9 @@
 	if (inp == NULL)
 		return (ENOBUFS);
 	bzero((caddr_t)inp, sizeof(*inp));
-	inp->inp_head = head;
+	inp->inp_table = table;
 	inp->inp_socket = so;
-	insque(inp, head);
+	LIST_INSERT_HEAD(&table->inpt_list, inp, inp_list);
 	so->so_pcb = (caddr_t)inp;
 	return (0);
 }
@@ -83,14 +92,14 @@
 	struct mbuf *nam;
 {
 	register struct socket *so = inp->inp_socket;
-	register struct inpcb *head = inp->inp_head;
+	register struct inpcbtable *table = inp->inp_table;
 	register struct sockaddr_in *sin;
 	struct proc *p = curproc;		/* XXX */
 	u_int16_t lport = 0;
 	int wild = 0, reuseport = (so->so_options & SO_REUSEPORT);
 	int error;
 
-	if (in_ifaddr == 0)
+	if (in_ifaddr.tqh_first == 0)
 		return (EADDRNOTAVAIL);
 	if (inp->inp_lport || inp->inp_laddr.s_addr != INADDR_ANY)
 		return (EINVAL);
@@ -133,7 +142,7 @@
 			if (ntohs(lport) < IPPORT_RESERVED &&
 			    (error = suser(p->p_ucred, &p->p_acflag)))
 				return (EACCES);
-			t = in_pcblookup(head, zeroin_addr, 0,
+			t = in_pcblookup(table, zeroin_addr, 0,
 			    sin->sin_addr, lport, wild);
 			if (t && (reuseport & t->inp_socket->so_options) == 0)
 				return (EADDRINUSE);
@@ -142,11 +151,11 @@
 	}
 	if (lport == 0)
 		do {
-			if (head->inp_lport++ < IPPORT_RESERVED ||
-			    head->inp_lport > IPPORT_USERRESERVED)
-				head->inp_lport = IPPORT_RESERVED;
-			lport = htons(head->inp_lport);
-		} while (in_pcblookup(head,
+			if (table->inpt_lastport++ < IPPORT_RESERVED ||
+			    table->inpt_lastport > IPPORT_USERRESERVED)
+				table->inpt_lastport = IPPORT_RESERVED;
+			lport = htons(table->inpt_lastport);
+		} while (in_pcblookup(table,
 			    zeroin_addr, 0, inp->inp_laddr, lport, wild));
 	inp->inp_lport = lport;
 	return (0);
@@ -173,7 +182,7 @@
 		return (EAFNOSUPPORT);
 	if (sin->sin_port == 0)
 		return (EADDRNOTAVAIL);
-	if (in_ifaddr) {
+	if (in_ifaddr.tqh_first != 0) {
 		/*
 		 * If the destination address is INADDR_ANY,
 		 * use the primary local address.
@@ -182,10 +191,10 @@
 		 * choose the broadcast address for that interface.
 		 */
 		if (sin->sin_addr.s_addr == INADDR_ANY)
-			sin->sin_addr = in_ifaddr->ia_addr.sin_addr;
+			sin->sin_addr = in_ifaddr.tqh_first->ia_addr.sin_addr;
 		else if (sin->sin_addr.s_addr == INADDR_BROADCAST &&
-		  (in_ifaddr->ia_ifp->if_flags & IFF_BROADCAST))
-			sin->sin_addr = in_ifaddr->ia_broadaddr.sin_addr;
+		  (in_ifaddr.tqh_first->ia_ifp->if_flags & IFF_BROADCAST))
+			sin->sin_addr = in_ifaddr.tqh_first->ia_broadaddr.sin_addr;
 	}
 	if (inp->inp_laddr.s_addr == INADDR_ANY) {
 		register struct route *ro;
@@ -229,7 +238,7 @@
 				ia = ifatoia(ifa_ifwithnet(sintosa(sin)));
 			sin->sin_port = fport;
 			if (ia == 0)
-				ia = in_ifaddr;
+				ia = in_ifaddr.tqh_first;
 			if (ia == 0)
 				return (EADDRNOTAVAIL);
 		}
@@ -246,7 +255,8 @@
 			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_ifaddr.tqh_first; ia != 0;
+				    ia = ia->ia_list.tqe_next)
 					if (ia->ia_ifp == ifp)
 						break;
 				if (ia == 0)
@@ -255,7 +265,7 @@
 		}
 		ifaddr = satosin(&ia->ia_addr);
 	}
-	if (in_pcblookup(inp->inp_head,
+	if (in_pcblookup(inp->inp_table,
 	    sin->sin_addr,
 	    sin->sin_port,
 	    inp->inp_laddr.s_addr ? inp->inp_laddr : ifaddr->sin_addr,
@@ -296,7 +306,7 @@
 	if (inp->inp_route.ro_rt)
 		rtfree(inp->inp_route.ro_rt);
 	ip_freemoptions(inp->inp_moptions);
-	remque(inp);
+	LIST_REMOVE(inp, inp_list);
 	FREE(inp, M_PCB);
 }
 
@@ -344,8 +354,8 @@
  * Must be called at splnet.
  */
 int
-in_pcbnotify(head, dst, fport_arg, laddr, lport_arg, cmd, notify)
-	struct inpcb *head;
+in_pcbnotify(table, dst, fport_arg, laddr, lport_arg, cmd, notify)
+	struct inpcbtable *table;
 	struct sockaddr *dst;
 	u_int fport_arg, lport_arg;
 	struct in_addr laddr;
@@ -358,38 +368,56 @@
 	u_int16_t fport = fport_arg, lport = lport_arg;
 	int errno;
 
-	if ((unsigned)cmd > PRC_NCMDS || dst->sa_family != AF_INET)
+	if (dst->sa_family != AF_INET)
 		return;
 	faddr = satosin(dst)->sin_addr;
 	if (faddr.s_addr == INADDR_ANY)
 		return;
 
-	/*
-	 * Redirects go to all references to the destination,
-	 * and use in_rtchange to invalidate the route cache.
-	 * Dead host indications: notify all references to the destination.
-	 * Otherwise, if we have knowledge of the local port and address,
-	 * deliver only to that socket.
-	 */
-	if (PRC_IS_REDIRECT(cmd) || cmd == PRC_HOSTDEAD) {
-		fport = 0;
-		lport = 0;
-		laddr.s_addr = 0;
-		if (cmd != PRC_HOSTDEAD)
-			notify = in_rtchange;
-	}
 	errno = inetctlerrmap[cmd];
-	for (inp = head->inp_next; inp != head;) {
+	for (inp = table->inpt_list.lh_first; inp != 0;) {
 		if (inp->inp_faddr.s_addr != faddr.s_addr ||
 		    inp->inp_socket == 0 ||
-		    (lport && inp->inp_lport != lport) ||
-		    (laddr.s_addr && inp->inp_laddr.s_addr != laddr.s_addr) ||
-		    (fport && inp->inp_fport != fport)) {
-			inp = inp->inp_next;
+		    inp->inp_fport != fport ||
+		    inp->inp_lport != lport ||
+		    inp->inp_laddr.s_addr != laddr.s_addr) {
+			inp = inp->inp_list.le_next;
 			continue;
 		}
 		oinp = inp;
-		inp = inp->inp_next;
+		inp = inp->inp_list.le_next;
+		if (notify)
+			(*notify)(oinp, errno);
+	}
+}
+
+int
+in_pcbnotifyall(table, dst, cmd, notify)
+	struct inpcbtable *table;
+	struct sockaddr *dst;
+	int cmd;
+	void (*notify) __P((struct inpcb *, int));
+{
+	extern u_char inetctlerrmap[];
+	register struct inpcb *inp, *oinp;
+	struct in_addr faddr;
+	int errno;
+
+	if (dst->sa_family != AF_INET)
+		return;
+	faddr = satosin(dst)->sin_addr;
+	if (faddr.s_addr == INADDR_ANY)
+		return;
+
+	errno = inetctlerrmap[cmd];
+	for (inp = table->inpt_list.lh_first; inp != 0;) {
+		if (inp->inp_faddr.s_addr != faddr.s_addr ||
+		    inp->inp_socket == 0) {
+			inp = inp->inp_list.le_next;
+			continue;
+		}
+		oinp = inp;
+		inp = inp->inp_list.le_next;
 		if (notify)
 			(*notify)(oinp, errno);
 	}
@@ -448,8 +476,8 @@
 }
 
 struct inpcb *
-in_pcblookup(head, faddr, fport_arg, laddr, lport_arg, flags)
-	struct inpcb *head;
+in_pcblookup(table, faddr, fport_arg, laddr, lport_arg, flags)
+	struct inpcbtable *table;
 	struct in_addr faddr, laddr;
 	u_int fport_arg, lport_arg;
 	int flags;
@@ -458,7 +486,8 @@
 	int matchwild = 3, wildcard;
 	u_int16_t fport = fport_arg, lport = lport_arg;
 
-	for (inp = head->inp_next; inp != head; inp = inp->inp_next) {
+	for (inp = table->inpt_list.lh_first; inp != 0;
+	    inp = inp->inp_list.le_next) {
 		if (inp->inp_lport != lport)
 			continue;
 		wildcard = 0;
--- a/sys/netinet/in_pcb.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/in_pcb.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_pcb.h,v 1.9 1995/04/13 06:28:48 cgd Exp $	*/
+/*	$NetBSD: in_pcb.h,v 1.10 1995/06/12 00:47:35 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -35,6 +35,8 @@
  *	@(#)in_pcb.h	8.1 (Berkeley) 6/10/93
  */
 
+#include <sys/queue.h>
+
 /*
  * Common structure pcb for internet protocol implementation.
  * Here are stored pointers to local and foreign host table
@@ -43,13 +45,11 @@
  * control block.
  */
 struct inpcb {
-	struct	  inpcb *inp_next,*inp_prev;
-					/* pointers to other pcb's */
-	struct	  inpcb *inp_head;	/* pointer back to chain of inpcb's
-					   for this protocol */
+	LIST_ENTRY(inpcb) inp_list;
+	struct	  inpcbtable *inp_table;
 	struct	  in_addr inp_faddr;	/* foreign host table entry */
+	struct	  in_addr inp_laddr;	/* local host table entry */
 	u_int16_t inp_fport;		/* foreign port */
-	struct	  in_addr inp_laddr;	/* local host table entry */
 	u_int16_t inp_lport;		/* local port */
 	struct	  socket *inp_socket;	/* back pointer to socket */
 	caddr_t	  inp_ppcb;		/* pointer to per-protocol pcb */
@@ -60,6 +60,11 @@
 	struct	  ip_moptions *inp_moptions; /* IP multicast options */
 };
 
+struct inpcbtable {
+	LIST_HEAD(inpcbhead, inpcb) inpt_list;
+	u_int16_t inpt_lastport;
+};
+
 /* flags in inp_flags: */
 #define	INP_RECVOPTS		0x01	/* receive incoming IP options */
 #define	INP_RECVRETOPTS		0x02	/* receive IP options for reply */
@@ -74,16 +79,19 @@
 
 #ifdef _KERNEL
 int	 in_losing __P((struct inpcb *));
-int	 in_pcballoc __P((struct socket *, struct inpcb *));
+int	 in_pcballoc __P((struct socket *, struct inpcbtable *));
 int	 in_pcbbind __P((struct inpcb *, struct mbuf *));
 int	 in_pcbconnect __P((struct inpcb *, struct mbuf *));
 int	 in_pcbdetach __P((struct inpcb *));
 int	 in_pcbdisconnect __P((struct inpcb *));
+void	 in_pcbinit __P((struct inpcbtable *));
 struct inpcb *
-	 in_pcblookup __P((struct inpcb *,
+	 in_pcblookup __P((struct inpcbtable *,
 	    struct in_addr, u_int, struct in_addr, u_int, int));
-int	 in_pcbnotify __P((struct inpcb *, struct sockaddr *,
+int	 in_pcbnotify __P((struct inpcbtable *, struct sockaddr *,
 	    u_int, struct in_addr, u_int, int, void (*)(struct inpcb *, int)));
+int	 in_pcbnotifyall __P((struct inpcbtable *, struct sockaddr *,
+	    int, void (*)(struct inpcb *, int)));
 void	 in_rtchange __P((struct inpcb *, int));
 int	 in_setpeeraddr __P((struct inpcb *, struct mbuf *));
 int	 in_setsockaddr __P((struct inpcb *, struct mbuf *));
--- a/sys/netinet/in_var.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/in_var.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_var.h,v 1.14 1995/06/04 05:58:23 mycroft Exp $	*/
+/*	$NetBSD: in_var.h,v 1.15 1995/06/12 00:47:37 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1985, 1986, 1993
@@ -35,6 +35,8 @@
  *	@(#)in_var.h	8.1 (Berkeley) 6/10/93
  */
 
+#include <sys/queue.h>
+
 /*
  * Interface address, Internet version.  One of these structures
  * is allocated for each interface with an Internet address.
@@ -51,12 +53,12 @@
 	u_int32_t ia_subnet;		/* subnet number, including net */
 	u_int32_t ia_subnetmask;	/* mask of subnet part */
 	struct	in_addr ia_netbroadcast; /* to recognize net broadcasts */
-	struct	in_ifaddr *ia_next;	/* next in list of internet addresses */
+	TAILQ_ENTRY(in_ifaddr) ia_list;	/* list of internet addresses */
 	struct	sockaddr_in ia_addr;	/* reserve space for interface name */
 	struct	sockaddr_in ia_dstaddr;	/* reserve space for broadcast addr */
 #define	ia_broadaddr	ia_dstaddr
 	struct	sockaddr_in ia_sockmask; /* reserve space for general netmask */
-	struct	in_multi *ia_multiaddrs; /* list of multicast addresses */
+	LIST_HEAD(, in_multi) ia_multiaddrs; /* list of multicast addresses */
 };
 
 struct	in_aliasreq {
@@ -74,7 +76,8 @@
 
 
 #ifdef	_KERNEL
-extern	struct	in_ifaddr *in_ifaddr;
+TAILQ_HEAD(in_ifaddrhead, in_ifaddr);
+extern	struct	in_ifaddrhead in_ifaddr;
 extern	struct	ifqueue	ipintrq;		/* ip packet input queue */
 void	in_socktrim __P((struct sockaddr_in *));
 
@@ -89,9 +92,9 @@
 { \
 	register struct in_ifaddr *ia; \
 \
-	for (ia = in_ifaddr; \
+	for (ia = in_ifaddr.tqh_first; \
 	    ia != NULL && ia->ia_addr.sin_addr.s_addr != (addr).s_addr; \
-	    ia = ia->ia_next) \
+	    ia = ia->ia_list.tqe_next) \
 		 continue; \
 	(ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
 }
@@ -104,9 +107,9 @@
 	/* struct ifnet *ifp; */ \
 	/* struct in_ifaddr *ia; */ \
 { \
-	for ((ia) = in_ifaddr; \
+	for ((ia) = in_ifaddr.tqh_first; \
 	    (ia) != NULL && (ia)->ia_ifp != (ifp); \
-	    (ia) = (ia)->ia_next) \
+	    (ia) = (ia)->ia_list.tqe_next) \
 		continue; \
 }
 #endif
@@ -133,7 +136,7 @@
 	struct	in_ifaddr *inm_ia;	/* back pointer to in_ifaddr */
 	u_int	inm_refcount;		/* no. membership claims by sockets */
 	u_int	inm_timer;		/* IGMP membership report timer */
-	struct	in_multi *inm_next;	/* ptr to next multicast address */
+	LIST_ENTRY(in_multi) inm_list;	/* list of multicast addresses */
 	u_int	inm_state;		/* state of membership */
 	struct	router_info *inm_rti;	/* router version info */
 };
@@ -163,9 +166,9 @@
 	if (ia == NULL) \
 		(inm) = NULL; \
 	else \
-		for ((inm) = ia->ia_multiaddrs; \
+		for ((inm) = ia->ia_multiaddrs.lh_first; \
 		    (inm) != NULL && (inm)->inm_addr.s_addr != (addr).s_addr; \
-		     (inm) = inm->inm_next) \
+		     (inm) = inm->inm_list.le_next) \
 			 continue; \
 }
 
@@ -181,13 +184,13 @@
 	/* struct in_multi *inm; */ \
 { \
 	if (((inm) = (step).i_inm) != NULL) \
-		(step).i_inm = (inm)->inm_next; \
+		(step).i_inm = (inm)->inm_list.le_next; \
 	else \
 		while ((step).i_ia != NULL) { \
-			(inm) = (step).i_ia->ia_multiaddrs; \
-			(step).i_ia = (step).i_ia->ia_next; \
+			(inm) = (step).i_ia->ia_multiaddrs.lh_first; \
+			(step).i_ia = (step).i_ia->ia_list.tqe_next; \
 			if ((inm) != NULL) { \
-				(step).i_inm = (inm)->inm_next; \
+				(step).i_inm = (inm)->inm_list.le_next; \
 				break; \
 			} \
 		} \
@@ -197,7 +200,7 @@
 	/* struct in_multistep step; */ \
 	/* struct in_multi *inm; */ \
 { \
-	(step).i_ia = in_ifaddr; \
+	(step).i_ia = in_ifaddr.tqh_first; \
 	(step).i_inm = NULL; \
 	IN_NEXT_MULTI((step), (inm)); \
 }
--- a/sys/netinet/ip_icmp.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/ip_icmp.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_icmp.c,v 1.17 1995/06/04 05:58:25 mycroft Exp $	*/
+/*	$NetBSD: ip_icmp.c,v 1.18 1995/06/12 00:47:39 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
@@ -427,7 +427,7 @@
 	 * or anonymous), use the address which corresponds
 	 * to the incoming interface.
 	 */
-	for (ia = in_ifaddr; ia; ia = ia->ia_next) {
+	for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
 		if (t.s_addr == ia->ia_addr.sin_addr.s_addr)
 			break;
 		if ((ia->ia_ifp->if_flags & IFF_BROADCAST) &&
@@ -443,7 +443,7 @@
 	 * and was received on an interface with no IP address.
 	 */
 	if (ia == (struct in_ifaddr *)0)
-		ia = in_ifaddr;
+		ia = in_ifaddr.tqh_first;
 	t = ia->ia_addr.sin_addr;
 	ip->ip_src = t;
 	ip->ip_ttl = MAXTTL;
--- a/sys/netinet/ip_input.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/ip_input.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_input.c,v 1.21 1995/06/07 16:01:15 mycroft Exp $	*/
+/*	$NetBSD: ip_input.c,v 1.22 1995/06/12 00:47:41 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
@@ -78,7 +78,7 @@
 extern	struct protosw inetsw[];
 u_char	ip_protox[IPPROTO_MAX];
 int	ipqmaxlen = IFQ_MAXLEN;
-struct	in_ifaddr *in_ifaddr;			/* first inet address */
+struct	in_ifaddrhead in_ifaddr;
 struct	ifqueue ipintrq;
 
 /*
@@ -120,6 +120,7 @@
 	ipq.next = ipq.prev = &ipq;
 	ip_id = time.tv_sec & 0xffff;
 	ipintrq.ifq_maxlen = ipqmaxlen;
+	TAILQ_INIT(&in_ifaddr);
 }
 
 struct	sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET };
@@ -156,7 +157,7 @@
 	 * If no IP addresses have been set yet but the interfaces
 	 * are receiving, can't do anything with incoming packets yet.
 	 */
-	if (in_ifaddr == NULL)
+	if (in_ifaddr.tqh_first == 0)
 		goto bad;
 	ipstat.ips_total++;
 	if (m->m_len < sizeof (struct ip) &&
@@ -228,7 +229,7 @@
 	/*
 	 * 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_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
 		if (ip->ip_dst.s_addr == ia->ia_addr.sin_addr.s_addr)
 			goto ours;
 		if (
--- a/sys/netinet/ip_output.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/ip_output.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_output.c,v 1.25 1995/06/04 05:58:28 mycroft Exp $	*/
+/*	$NetBSD: ip_output.c,v 1.26 1995/06/12 00:47:44 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -189,7 +189,7 @@
 		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_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next)
 				if (ia->ia_ifp == ifp) {
 					ip->ip_src = ia->ia_addr.sin_addr;
 					break;
--- a/sys/netinet/ip_var.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/ip_var.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_var.h,v 1.13 1995/05/14 08:23:03 cgd Exp $	*/
+/*	$NetBSD: ip_var.h,v 1.14 1995/06/12 00:47:47 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -54,13 +54,13 @@
  * be reclaimed if memory becomes tight.
  */
 struct ipq {
-	struct	  ipq *next,*prev;	/* to other reass headers */
+	struct	  ipq *next, *prev;	/* to other reass headers */
 	u_int8_t  ipq_ttl;		/* time for reass q to live */
 	u_int8_t  ipq_p;		/* protocol of this fragment */
 	u_int16_t ipq_id;		/* sequence id for reassembly */
-	struct	  ipasfrag *ipq_next,*ipq_prev;
+	struct	  ipasfrag *ipq_next, *ipq_prev;
 					/* to ip headers of fragments */
-	struct	  in_addr ipq_src,ipq_dst;
+	struct	  in_addr ipq_src, ipq_dst;
 };
 
 /*
@@ -86,8 +86,8 @@
 	u_int8_t  ip_ttl;
 	u_int8_t  ip_p;
 	u_int16_t ip_sum;
-	struct	  ipasfrag *ipf_next;	/* next fragment */
-	struct	  ipasfrag *ipf_prev;	/* previous fragment */
+	struct	  ipasfrag *ipf_next, *ipf_prev;
+					/* list of fragments */
 };
 
 /*
--- a/sys/netinet/raw_ip.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/raw_ip.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip.c,v 1.19 1995/06/04 05:07:11 mycroft Exp $	*/
+/*	$NetBSD: raw_ip.c,v 1.20 1995/06/12 00:47:49 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
@@ -54,7 +54,7 @@
 #include <netinet/ip_mroute.h>
 #include <netinet/in_pcb.h>
 
-struct inpcb rawinpcb;
+struct inpcbtable rawcbtable;
 
 /*
  * Nominal space allocated to a raw ip socket.
@@ -73,7 +73,7 @@
 rip_init()
 {
 
-	rawinpcb.inp_next = rawinpcb.inp_prev = &rawinpcb;
+	in_pcbinit(&rawcbtable);
 }
 
 struct	sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
@@ -91,7 +91,8 @@
 	struct socket *last = 0;
 
 	ripsrc.sin_addr = ip->ip_src;
-	for (inp = rawinpcb.inp_next; inp != &rawinpcb; inp = inp->inp_next) {
+	for (inp = rawcbtable.inpt_list.lh_first; inp != 0;
+	    inp = inp->inp_list.le_next) {
 		if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != ip->ip_p)
 			continue;
 		if (inp->inp_laddr.s_addr &&
@@ -263,7 +264,7 @@
 			break;
 		}
 		if ((error = soreserve(so, rip_sendspace, rip_recvspace)) ||
-		    (error = in_pcballoc(so, &rawinpcb)))
+		    (error = in_pcballoc(so, &rawcbtable)))
 			break;
 		inp = (struct inpcb *)so->so_pcb;
 		inp->inp_ip.ip_p = (long)nam;
@@ -296,7 +297,7 @@
 			error = EINVAL;
 			break;
 		}
-		if ((ifnet == 0) ||
+		if ((ifnet.tqh_first == 0) ||
 		    ((addr->sin_family != AF_INET) &&
 		     (addr->sin_family != AF_IMPLINK)) ||
 		    (addr->sin_addr.s_addr &&
@@ -315,7 +316,7 @@
 			error = EINVAL;
 			break;
 		}
-		if (ifnet == 0) {
+		if (ifnet.tqh_first == 0) {
 			error = EADDRNOTAVAIL;
 			break;
 		}
--- a/sys/netinet/tcp_input.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/tcp_input.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.17 1995/06/11 21:36:04 mycroft Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.18 1995/06/12 00:47:52 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994
@@ -63,7 +63,7 @@
 
 int	tcprexmtthresh = 3;
 struct	tcpiphdr tcp_saveti;
-struct	inpcb *tcp_last_inpcb = &tcb;
+struct	inpcb *tcp_last_inpcb = 0;
 
 extern u_long sb_max;
 
@@ -321,25 +321,25 @@
 	 */
 findpcb:
 	inp = tcp_last_inpcb;
-	if (inp->inp_lport != ti->ti_dport ||
+	if (inp == 0 ||
+	    inp->inp_lport != ti->ti_dport ||
 	    inp->inp_fport != ti->ti_sport ||
 	    inp->inp_faddr.s_addr != ti->ti_src.s_addr ||
 	    inp->inp_laddr.s_addr != ti->ti_dst.s_addr) {
-		inp = in_pcblookup(&tcb, ti->ti_src, ti->ti_sport,
+		++tcpstat.tcps_pcbcachemiss;
+		inp = in_pcblookup(&tcbtable, ti->ti_src, ti->ti_sport,
 		    ti->ti_dst, ti->ti_dport, INPLOOKUP_WILDCARD);
-		if (inp)
-			tcp_last_inpcb = inp;
-		++tcpstat.tcps_pcbcachemiss;
+		/*
+		 * If the state is CLOSED (i.e., TCB does not exist) then
+		 * all data in the incoming segment is discarded.
+		 * If the TCB exists but is in CLOSED state, it is embryonic,
+		 * but should either do a listen or a connect soon.
+		 */
+		if (inp == 0)
+			goto dropwithreset;
+		tcp_last_inpcb = inp;
 	}
 
-	/*
-	 * If the state is CLOSED (i.e., TCB does not exist) then
-	 * all data in the incoming segment is discarded.
-	 * If the TCB exists but is in CLOSED state, it is embryonic,
-	 * but should either do a listen or a connect soon.
-	 */
-	if (inp == 0)
-		goto dropwithreset;
 	tp = intotcpcb(inp);
 	if (tp == 0)
 		goto dropwithreset;
--- a/sys/netinet/tcp_subr.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/tcp_subr.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_subr.c,v 1.15 1995/06/11 20:39:25 mycroft Exp $	*/
+/*	$NetBSD: tcp_subr.c,v 1.16 1995/06/12 00:47:55 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -76,7 +76,7 @@
 {
 
 	tcp_iss = 1;		/* wrong */
-	tcb.inp_next = tcb.inp_prev = &tcb;
+	in_pcbinit(&tcbtable);
 	if (max_protohdr < sizeof(struct tcpiphdr))
 		max_protohdr = sizeof(struct tcpiphdr);
 	if (max_linkhdr + sizeof(struct tcpiphdr) > MHLEN)
@@ -360,7 +360,7 @@
 	soisdisconnected(so);
 	/* clobber input pcb cache if we're closing the cached connection */
 	if (inp == tcp_last_inpcb)
-		tcp_last_inpcb = &tcb;
+		tcp_last_inpcb = 0;
 	in_pcbdetach(inp);
 	tcpstat.tcps_closed++;
 	return ((struct tcpcb *)0);
@@ -417,17 +417,21 @@
 	extern u_char inetctlerrmap[];
 	void (*notify) __P((struct inpcb *, int)) = tcp_notify;
 
-	if (cmd == PRC_QUENCH)
-		notify = tcp_quench;
-	else if (!PRC_IS_REDIRECT(cmd) &&
-		 ((unsigned)cmd > PRC_NCMDS || inetctlerrmap[cmd] == 0))
+	if (PRC_IS_REDIRECT(cmd))
+		notify = in_rtchange;
+	else if (cmd == PRC_HOSTDEAD)
+		;
+	else if ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0)
 		return;
-	if (ip) {
+	else if (ip) {
+		if (cmd == PRC_QUENCH)
+			notify = tcp_quench;
 		th = (struct tcphdr *)((caddr_t)ip + (ip->ip_hl << 2));
-		in_pcbnotify(&tcb, sa, th->th_dport, ip->ip_src, th->th_sport,
-			cmd, notify);
-	} else
-		in_pcbnotify(&tcb, sa, 0, zeroin_addr, 0, cmd, notify);
+		in_pcbnotify(&tcbtable, sa, th->th_dport, ip->ip_src,
+		    th->th_sport, cmd, notify);
+		return;
+	}
+	in_pcbnotifyall(&tcbtable, sa, cmd, notify);
 }
 
 /*
--- a/sys/netinet/tcp_timer.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/tcp_timer.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_timer.c,v 1.10 1995/04/13 06:36:49 cgd Exp $	*/
+/*	$NetBSD: tcp_timer.c,v 1.11 1995/06/12 00:47:58 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -72,11 +72,11 @@
 {
 	register struct inpcb *inp;
 	register struct tcpcb *tp;
-	int s = splnet();
+	int s;
 
-	inp = tcb.inp_next;
-	if (inp)
-	for (; inp != &tcb; inp = inp->inp_next)
+	s = splnet();
+	for (inp = tcbtable.inpt_list.lh_first; inp != 0;
+	    inp = inp->inp_list.le_next) {
 		if ((tp = (struct tcpcb *)inp->inp_ppcb) &&
 		    (tp->t_flags & TF_DELACK)) {
 			tp->t_flags &= ~TF_DELACK;
@@ -84,6 +84,7 @@
 			tcpstat.tcps_delack++;
 			(void) tcp_output(tp);
 		}
+	}
 	splx(s);
 }
 
@@ -97,20 +98,16 @@
 {
 	register struct inpcb *ip, *ipnxt;
 	register struct tcpcb *tp;
-	int s = splnet();
+	int s;
 	register long i;
 
+	s = splnet();
 	tcp_maxidle = TCPTV_KEEPCNT * tcp_keepintvl;
 	/*
 	 * Search through tcb's and update active timers.
 	 */
-	ip = tcb.inp_next;
-	if (ip == 0) {
-		splx(s);
-		return;
-	}
-	for (; ip != &tcb; ip = ipnxt) {
-		ipnxt = ip->inp_next;
+	for (ip = tcbtable.inpt_list.lh_first; ip != 0; ip = ipnxt) {
+		ipnxt = ip->inp_list.le_next;
 		tp = intotcpcb(ip);
 		if (tp == 0)
 			continue;
@@ -119,7 +116,8 @@
 				(void) tcp_usrreq(tp->t_inpcb->inp_socket,
 				    PRU_SLOWTIMO, (struct mbuf *)0,
 				    (struct mbuf *)i, (struct mbuf *)0);
-				if (ipnxt->inp_prev != ip)
+				if (ipnxt->inp_list.le_prev !=
+				    &ip->inp_list.le_next)
 					goto tpgone;
 			}
 		}
--- a/sys/netinet/tcp_usrreq.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/tcp_usrreq.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_usrreq.c,v 1.14 1995/04/13 06:36:53 cgd Exp $	*/
+/*	$NetBSD: tcp_usrreq.c,v 1.15 1995/06/12 00:48:00 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1993
@@ -443,7 +443,7 @@
 		if (error)
 			return (error);
 	}
-	error = in_pcballoc(so, &tcb);
+	error = in_pcballoc(so, &tcbtable);
 	if (error)
 		return (error);
 	inp = sotoinpcb(so);
--- a/sys/netinet/tcp_var.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/tcp_var.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_var.h,v 1.12 1995/06/11 20:39:26 mycroft Exp $	*/
+/*	$NetBSD: tcp_var.h,v 1.13 1995/06/12 00:48:03 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993, 1994
@@ -43,8 +43,8 @@
  * Tcp control block, one per tcp; fields:
  */
 struct tcpcb {
-	struct	tcpiphdr *seg_next;	/* sequencing queue */
-	struct	tcpiphdr *seg_prev;
+	struct	tcpiphdr *seg_next, *seg_prev;
+					/* list of control blocks */
 	short	t_state;		/* state of this connection */
 	short	t_timer[TCPT_NTIMERS];	/* tcp timers */
 	short	t_rxtshift;		/* log(2) of rexmt exp. backoff */
@@ -234,7 +234,7 @@
 };
 
 #ifdef _KERNEL
-struct	inpcb tcb;		/* head of queue of active tcpcb's */
+struct	inpcbtable tcbtable;	/* head of queue of active tcpcb's */
 struct	tcpstat tcpstat;	/* tcp statistics */
 u_int32_t tcp_now;		/* for RFC 1323 timestamps */
 
--- a/sys/netinet/udp_usrreq.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/udp_usrreq.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: udp_usrreq.c,v 1.17 1995/06/04 05:07:20 mycroft Exp $	*/
+/*	$NetBSD: udp_usrreq.c,v 1.18 1995/06/12 00:48:06 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -68,7 +68,7 @@
 #endif
 
 struct	sockaddr_in udp_in = { sizeof(udp_in), AF_INET };
-struct	inpcb *udp_last_inpcb = &udb;
+struct	inpcb *udp_last_inpcb = 0;
 
 static	void udp_detach __P((struct inpcb *));
 static	void udp_notify __P((struct inpcb *, int));
@@ -77,7 +77,8 @@
 void
 udp_init()
 {
-	udb.inp_next = udb.inp_prev = &udb;
+
+	in_pcbinit(&udbtable);
 }
 
 void
@@ -183,7 +184,8 @@
 		 * (Algorithm copied from raw_intr().)
 		 */
 		last = NULL;
-		for (inp = udb.inp_next; inp != &udb; inp = inp->inp_next) {
+		for (inp = udbtable.inpt_list.lh_first; inp != 0;
+		    inp = inp->inp_list.le_next) {
 			if (inp->inp_lport != uh->uh_dport)
 				continue;
 			if (inp->inp_laddr.s_addr != INADDR_ANY) {
@@ -245,26 +247,26 @@
 	 * Locate pcb for datagram.
 	 */
 	inp = udp_last_inpcb;
-	if (inp->inp_lport != uh->uh_dport ||
+	if (inp == 0 ||
+	    inp->inp_lport != uh->uh_dport ||
 	    inp->inp_fport != uh->uh_sport ||
 	    inp->inp_faddr.s_addr != ip->ip_src.s_addr ||
 	    inp->inp_laddr.s_addr != ip->ip_dst.s_addr) {
-		inp = in_pcblookup(&udb, ip->ip_src, uh->uh_sport,
+		udpstat.udpps_pcbcachemiss++;
+		inp = in_pcblookup(&udbtable, ip->ip_src, uh->uh_sport,
 		    ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD);
-		if (inp)
-			udp_last_inpcb = inp;
-		udpstat.udpps_pcbcachemiss++;
-	}
-	if (inp == 0) {
-		udpstat.udps_noport++;
-		if (m->m_flags & (M_BCAST | M_MCAST)) {
-			udpstat.udps_noportbcast++;
-			goto bad;
+		if (inp == 0) {
+			udpstat.udps_noport++;
+			if (m->m_flags & (M_BCAST | M_MCAST)) {
+				udpstat.udps_noportbcast++;
+				goto bad;
+			}
+			*ip = save_ip;
+			ip->ip_len += iphlen;
+			icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
+			return;
 		}
-		*ip = save_ip;
-		ip->ip_len += iphlen;
-		icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0);
-		return;
+		udp_last_inpcb = inp;
 	}
 
 	/*
@@ -364,16 +366,21 @@
 	register struct udphdr *uh;
 	extern struct in_addr zeroin_addr;
 	extern u_char inetctlerrmap[];
+	void (*notify) __P((struct inpcb *, int)) = udp_notify;
 
-	if (!PRC_IS_REDIRECT(cmd) &&
-	    ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0))
+	if (PRC_IS_REDIRECT(cmd))
+		notify = in_rtchange;
+	else if (cmd == PRC_HOSTDEAD)
+		;
+	else if ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0)
 		return;
-	if (ip) {
+	else if (ip) {
 		uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2));
-		in_pcbnotify(&udb, sa, uh->uh_dport, ip->ip_src, uh->uh_sport,
-			cmd, udp_notify);
-	} else
-		in_pcbnotify(&udb, sa, 0, zeroin_addr, 0, cmd, udp_notify);
+		in_pcbnotify(&udbtable, sa, uh->uh_dport, ip->ip_src,
+		    uh->uh_sport, cmd, notify);
+		return;
+	}
+	in_pcbnotifyall(&udbtable, sa, cmd, notify);
 }
 
 int
@@ -498,7 +505,7 @@
 			break;
 		}
 		s = splnet();
-		error = in_pcballoc(so, &udb);
+		error = in_pcballoc(so, &udbtable);
 		splx(s);
 		if (error)
 			break;
@@ -613,7 +620,7 @@
 	int s = splnet();
 
 	if (inp == udp_last_inpcb)
-		udp_last_inpcb = &udb;
+		udp_last_inpcb = 0;
 	in_pcbdetach(inp);
 	splx(s);
 }
--- a/sys/netinet/udp_var.h	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/netinet/udp_var.h	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: udp_var.h,v 1.8 1995/03/26 20:32:42 jtc Exp $	*/
+/*	$NetBSD: udp_var.h,v 1.9 1995/06/12 00:48:09 mycroft Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -80,7 +80,7 @@
 }
 
 #ifdef _KERNEL
-struct	inpcb udb;
+struct	inpcbtable udbtable;
 struct	udpstat udpstat;
 
 void	 udp_ctlinput __P((int, struct sockaddr *, struct ip *));
--- a/sys/nfs/nfs_boot.c	Mon Jun 12 00:09:42 1995 +0000
+++ b/sys/nfs/nfs_boot.c	Mon Jun 12 00:46:47 1995 +0000
@@ -1,4 +1,4 @@
-/*    $NetBSD: nfs_boot.c,v 1.18 1995/05/23 00:14:06 cgd Exp $ */
+/*    $NetBSD: nfs_boot.c,v 1.19 1995/06/12 00:48:31 mycroft Exp $ */
 
 /*
  * Copyright (c) 1995 Adam Glass, Gordon Ross
@@ -131,7 +131,7 @@
 	if (nfsbootdevname)
 		ifp = ifunit(nfsbootdevname);
 	else
-		for (ifp = ifnet; ifp; ifp = ifp->if_next)
+		for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
 			if ((ifp->if_flags &
 			     (IFF_LOOPBACK|IFF_POINTOPOINT)) == 0)
 				break;