From cf33d69c641c5a5686bb7f1cd4a5d230de07ec47 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sat, 29 Jun 1996 18:54:12 +0000 Subject: provide if_attachhead(), and make if_loop use it --- sys/net/if.c | 33 ++++++++++++++++++++++++++------- sys/net/if.h | 3 ++- sys/net/if_loop.c | 4 ++-- 3 files changed, 30 insertions(+), 10 deletions(-) (limited to 'sys/net') diff --git a/sys/net/if.c b/sys/net/if.c index b3da97849c1..04828b533e8 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.9 1996/05/10 12:31:07 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.10 1996/06/29 18:54:08 deraadt Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -78,8 +78,8 @@ struct ifaddr **ifnet_addrs; * Attach an interface to the * list of "active" interfaces. */ -void -if_attach(ifp) +static void +if_attachsetup(ifp) struct ifnet *ifp; { unsigned socksize, ifasize; @@ -88,10 +88,6 @@ if_attach(ifp) register struct ifaddr *ifa; static int if_indexlim = 8; - if (if_index == 0) - TAILQ_INIT(&ifnet); - TAILQ_INIT(&ifp->if_addrlist); - TAILQ_INSERT_TAIL(&ifnet, ifp, if_list); ifp->if_index = ++if_index; if (ifnet_addrs == 0 || if_index >= if_indexlim) { unsigned n = (if_indexlim <<= 1) * sizeof(ifa); @@ -135,6 +131,29 @@ if_attach(ifp) while (namelen != 0) sdl->sdl_data[--namelen] = 0xff; } + +void +if_attachhead(ifp) + struct ifnet *ifp; +{ + if (if_index == 0) + TAILQ_INIT(&ifnet); + TAILQ_INIT(&ifp->if_addrlist); + TAILQ_INSERT_HEAD(&ifnet, ifp, if_list); + if_attachsetup(ifp); +} + +void +if_attach(ifp) + struct ifnet *ifp; +{ + if (if_index == 0) + TAILQ_INIT(&ifnet); + TAILQ_INIT(&ifp->if_addrlist); + TAILQ_INSERT_TAIL(&ifnet, ifp, if_list); + if_attachsetup(ifp); +} + /* * Locate an interface based on a complete address. */ diff --git a/sys/net/if.h b/sys/net/if.h index db86882d94d..94dc4f9b932 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.5 1996/05/10 12:31:07 deraadt Exp $ */ +/* $OpenBSD: if.h,v 1.6 1996/06/29 18:54:10 deraadt Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -337,6 +337,7 @@ int ether_output __P((struct ifnet *, char *ether_sprintf __P((u_char *)); void if_attach __P((struct ifnet *)); +void if_attachtail __P((struct ifnet *)); void if_down __P((struct ifnet *)); void if_qflush __P((struct ifqueue *)); void if_slowtimo __P((void *)); diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index a15519e3242..d1e36af3962 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_loop.c,v 1.5 1996/05/10 12:31:09 deraadt Exp $ */ +/* $OpenBSD: if_loop.c,v 1.6 1996/06/29 18:54:11 deraadt Exp $ */ /* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */ /* @@ -107,7 +107,7 @@ loopattach(n) ifp->if_type = IFT_LOOP; ifp->if_hdrlen = 0; ifp->if_addrlen = 0; - if_attach(ifp); + if_attachhead(ifp); #if NBPFILTER > 0 bpfattach(&ifp->if_bpf, ifp, DLT_NULL, sizeof(u_int)); #endif -- cgit v1.2.3