diff options
author | ume <ume@FreeBSD.org> | 2003-10-17 15:46:31 +0000 |
---|---|---|
committer | ume <ume@FreeBSD.org> | 2003-10-17 15:46:31 +0000 |
commit | babf2c3ec01f429fc11fe95261ac8db6488c3788 (patch) | |
tree | 7b94f0bf6e27699cee5534d28881bd0e62278adb /sys/net | |
parent | 81586929f375fc23eb8749aebf4eba5c6582b35a (diff) | |
download | FreeBSD-src-babf2c3ec01f429fc11fe95261ac8db6488c3788.zip FreeBSD-src-babf2c3ec01f429fc11fe95261ac8db6488c3788.tar.gz |
- add dom_if{attach,detach} framework.
- transition to use ifp->if_afdata.
Obtained from: KAME
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.c | 48 | ||||
-rw-r--r-- | sys/net/if_var.h | 2 |
2 files changed, 50 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 6f3091b..9423d29 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -54,6 +54,7 @@ #include <sys/sockio.h> #include <sys/syslog.h> #include <sys/sysctl.h> +#include <sys/domain.h> #include <sys/jail.h> #include <machine/stdarg.h> @@ -78,6 +79,8 @@ #include <netinet/if_ether.h> #endif +static void if_attachdomain(void *); +static void if_attachdomain1(struct ifnet *); static int ifconf(u_long, caddr_t); static void if_grow(void); static void if_init(void *); @@ -442,10 +445,48 @@ if_attach(ifp) } ifp->if_broadcastaddr = 0; /* reliably crash if used uninitialized */ + if (domains) + if_attachdomain1(ifp); + /* Announce the interface. */ rt_ifannouncemsg(ifp, IFAN_ARRIVAL); } +static void +if_attachdomain(dummy) + void *dummy; +{ + struct ifnet *ifp; + int s; + + s = splnet(); + for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) + if_attachdomain1(ifp); + splx(s); +} +SYSINIT(domainifattach, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST, + if_attachdomain, NULL); + +static void +if_attachdomain1(ifp) + struct ifnet *ifp; +{ + struct domain *dp; + int s; + + s = splnet(); + + /* 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); + } + + splx(s); +} + /* * Detach an interface, removing it from the * list of "active" interfaces. @@ -458,6 +499,7 @@ if_detach(ifp) struct radix_node_head *rnh; int s; int i; + struct domain *dp; /* * Remove routes and flush queues. @@ -538,6 +580,12 @@ if_detach(ifp) /* Announce that the interface is gone. */ rt_ifannouncemsg(ifp, IFAN_DEPARTURE); + 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]); + } + #ifdef MAC mac_destroy_ifnet(ifp); #endif /* MAC */ diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 4c95804..a1dc0b6 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -178,6 +178,8 @@ struct ifnet { struct ifprefixhead if_prefixhead; /* list of prefixes per if */ u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */ struct label if_label; /* interface MAC label */ + + void *if_afdata[AF_MAX]; }; typedef void if_init_f_t(void *); |