diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2002-05-27 02:59:42 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2002-05-27 02:59:42 +0000 |
commit | 4442bd33a4ad0c7aeef752a21bd59a6e320ad6f9 (patch) | |
tree | d02e6d7ab5d5aa5791a771b736c3b192ac1e7be9 /sys | |
parent | f2f3d4a7bf69e4a39a3cef91f94ff6d74e56a565 (diff) |
framework to add af-dependent data structure to struct ifnet.
as discussed at bsd-api-discuss. sync w/kame
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 21 | ||||
-rw-r--r-- | sys/net/if.h | 4 | ||||
-rw-r--r-- | sys/sys/domain.h | 6 |
3 files changed, 28 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 107850024f8..89765b912a7 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.53 2002/04/24 16:42:59 dhartmei Exp $ */ +/* $OpenBSD: if.c,v 1.54 2002/05/27 02:59:40 itojun Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -77,6 +77,7 @@ #include <sys/protosw.h> #include <sys/kernel.h> #include <sys/ioctl.h> +#include <sys/domain.h> #include <net/if.h> #include <net/if_dl.h> @@ -159,6 +160,7 @@ if_attachsetup(ifp) register struct sockaddr_dl *sdl; register struct ifaddr *ifa; static int if_indexlim = 8; + struct domain *dp; ifp->if_index = ++if_index; @@ -239,6 +241,14 @@ if_attachsetup(ifp) ifp->if_snd.altq_tbr = NULL; ifp->if_snd.altq_ifp = ifp; #endif + + /* address family dependent data region */ + bzero(ifp->if_afdata, sizeof(ifp->if_afdata)); + for (dp = domains; dp; dp = dp->dom_next) { + if (dp->dom_ifattach) + ifp->if_afdata[dp->dom_family] = + (*dp->dom_ifattach)(ifp); + } } void @@ -336,6 +346,7 @@ if_detach(ifp) struct ifaddr *ifa; int i, s = splimp(); struct radix_node_head *rnh; + struct domain *dp; ifp->if_flags &= ~IFF_OACTIVE; ifp->if_start = if_detached_start; @@ -401,7 +412,15 @@ if_detach(ifp) #endif free(ifa, M_IFADDR); } + free(ifp->if_addrhooks, M_TEMP); + + for (dp = domains; dp; dp = dp->dom_next) { + if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family]) + (*dp->dom_ifdetach)(ifp, + ifp->if_afdata[dp->dom_family]); + } + splx(s); } diff --git a/sys/net/if.h b/sys/net/if.h index 55155fc9809..cbfd14b2bab 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.35 2002/04/24 00:51:51 dhartmei Exp $ */ +/* $OpenBSD: if.h,v 1.36 2002/05/27 02:59:40 itojun Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -173,6 +173,8 @@ struct ifnet { /* and the entries */ void (*if_watchdog)(struct ifnet *); struct ifaltq if_snd; /* output queue (includes altq) */ struct ifprefix *if_prefixlist; /* linked list of prefixes per if */ + + void *if_afdata[AF_MAX]; }; #define if_mtu if_data.ifi_mtu #define if_type if_data.ifi_type diff --git a/sys/sys/domain.h b/sys/sys/domain.h index 50984e2aac4..888a6bd873c 100644 --- a/sys/sys/domain.h +++ b/sys/sys/domain.h @@ -1,4 +1,4 @@ -/* $OpenBSD: domain.h,v 1.4 2002/03/15 01:20:04 millert Exp $ */ +/* $OpenBSD: domain.h,v 1.5 2002/05/27 02:59:41 itojun Exp $ */ /* $NetBSD: domain.h,v 1.10 1996/02/09 18:25:07 christos Exp $ */ /* @@ -44,6 +44,7 @@ * Forward structure declarations for function prototypes [sic]. */ struct mbuf; +struct ifnet; struct domain { int dom_family; /* AF_xxx */ @@ -59,6 +60,9 @@ struct domain { int (*dom_rtattach)(void **, int); int dom_rtoffset; /* an arg to rtattach, in bits */ int dom_maxrtkey; /* for routing layer */ + void *(*dom_ifattach) __P((struct ifnet *)); + void (*dom_ifdetach) __P((struct ifnet *, void *)); + /* af-dependent data on ifnet */ }; #ifdef _KERNEL |