diff options
author | zec <zec@FreeBSD.org> | 2008-10-02 15:37:58 +0000 |
---|---|---|
committer | zec <zec@FreeBSD.org> | 2008-10-02 15:37:58 +0000 |
commit | 8797d4caecd5881e312923ee1d07be3de68755dc (patch) | |
tree | 53fef93d1ff076abec439159e0a765427992dee1 /sys/netinet6 | |
parent | e682bfadb0a191a81290af2b846d8610ef3aff5c (diff) | |
download | FreeBSD-src-8797d4caecd5881e312923ee1d07be3de68755dc.zip FreeBSD-src-8797d4caecd5881e312923ee1d07be3de68755dc.tar.gz |
Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit
Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.
Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().
Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).
All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).
(*) netipsec/keysock.c did not validate depending on compile time options.
Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/dest6.c | 1 | ||||
-rw-r--r-- | sys/netinet6/frag6.c | 66 | ||||
-rw-r--r-- | sys/netinet6/icmp6.c | 19 | ||||
-rw-r--r-- | sys/netinet6/in6.c | 10 | ||||
-rw-r--r-- | sys/netinet6/in6_gif.c | 2 | ||||
-rw-r--r-- | sys/netinet6/in6_ifattach.c | 12 | ||||
-rw-r--r-- | sys/netinet6/in6_pcb.c | 3 | ||||
-rw-r--r-- | sys/netinet6/in6_proto.c | 159 | ||||
-rw-r--r-- | sys/netinet6/in6_rmx.c | 12 | ||||
-rw-r--r-- | sys/netinet6/in6_src.c | 12 | ||||
-rw-r--r-- | sys/netinet6/ip6_forward.c | 2 | ||||
-rw-r--r-- | sys/netinet6/ip6_input.c | 7 | ||||
-rw-r--r-- | sys/netinet6/ip6_ipsec.c | 3 | ||||
-rw-r--r-- | sys/netinet6/ip6_mroute.c | 10 | ||||
-rw-r--r-- | sys/netinet6/ip6_output.c | 7 | ||||
-rw-r--r-- | sys/netinet6/mld6.c | 3 | ||||
-rw-r--r-- | sys/netinet6/nd6.c | 34 | ||||
-rw-r--r-- | sys/netinet6/nd6_nbr.c | 12 | ||||
-rw-r--r-- | sys/netinet6/nd6_rtr.c | 20 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 16 | ||||
-rw-r--r-- | sys/netinet6/route6.c | 2 | ||||
-rw-r--r-- | sys/netinet6/scope6.c | 9 | ||||
-rw-r--r-- | sys/netinet6/udp6_usrreq.c | 17 | ||||
-rw-r--r-- | sys/netinet6/vinet6.h | 259 |
24 files changed, 591 insertions, 106 deletions
diff --git a/sys/netinet6/dest6.c b/sys/netinet6/dest6.c index 20b5e9d..6ac30ed 100644 --- a/sys/netinet6/dest6.c +++ b/sys/netinet6/dest6.c @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$"); int dest6_input(struct mbuf **mp, int *offp, int proto) { + INIT_VNET_INET6(curvnet); struct mbuf *m = *mp; int off = *offp, dstoptlen, optlen; struct ip6_dest *dstopts; diff --git a/sys/netinet6/frag6.c b/sys/netinet6/frag6.c index bad4410..fca85c5 100644 --- a/sys/netinet6/frag6.c +++ b/sys/netinet6/frag6.c @@ -91,6 +91,7 @@ static MALLOC_DEFINE(M_FTABLE, "fragment", "fragment reassembly header"); static void frag6_change(void *tag) { + INIT_VNET_INET6(curvnet); V_ip6_maxfragpackets = nmbclusters / 4; V_ip6_maxfrags = nmbclusters / 4; @@ -99,6 +100,7 @@ frag6_change(void *tag) void frag6_init(void) { + INIT_VNET_INET6(curvnet); V_ip6_maxfragpackets = nmbclusters / 4; V_ip6_maxfrags = nmbclusters / 4; @@ -145,6 +147,7 @@ frag6_init(void) int frag6_input(struct mbuf **mp, int *offp, int proto) { + INIT_VNET_INET6(curvnet); struct mbuf *m = *mp, *t; struct ip6_hdr *ip6; struct ip6_frag *ip6f; @@ -586,6 +589,7 @@ insert: void frag6_freef(struct ip6q *q6) { + INIT_VNET_INET6(curvnet); struct ip6asfrag *af6, *down6; IP6Q_LOCK_ASSERT(); @@ -682,31 +686,39 @@ frag6_remque(struct ip6q *p6) void frag6_slowtimo(void) { + VNET_ITERATOR_DECL(vnet_iter); struct ip6q *q6; IP6Q_LOCK(); - q6 = V_ip6q.ip6q_next; - if (q6) - while (q6 != &V_ip6q) { - --q6->ip6q_ttl; - q6 = q6->ip6q_next; - if (q6->ip6q_prev->ip6q_ttl == 0) { - V_ip6stat.ip6s_fragtimeout++; - /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */ - frag6_freef(q6->ip6q_prev); + VNET_LIST_RLOCK(); + VNET_FOREACH(vnet_iter) { + CURVNET_SET(vnet_iter); + INIT_VNET_INET6(vnet_iter); + q6 = V_ip6q.ip6q_next; + if (q6) + while (q6 != &V_ip6q) { + --q6->ip6q_ttl; + q6 = q6->ip6q_next; + if (q6->ip6q_prev->ip6q_ttl == 0) { + V_ip6stat.ip6s_fragtimeout++; + /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */ + frag6_freef(q6->ip6q_prev); + } } + /* + * If we are over the maximum number of fragments + * (due to the limit being lowered), drain off + * enough to get down to the new limit. + */ + while (V_frag6_nfragpackets > (u_int)V_ip6_maxfragpackets && + V_ip6q.ip6q_prev) { + V_ip6stat.ip6s_fragoverflow++; + /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */ + frag6_freef(V_ip6q.ip6q_prev); } - /* - * If we are over the maximum number of fragments - * (due to the limit being lowered), drain off - * enough to get down to the new limit. - */ - while (V_frag6_nfragpackets > (u_int)V_ip6_maxfragpackets && - V_ip6q.ip6q_prev) { - V_ip6stat.ip6s_fragoverflow++; - /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */ - frag6_freef(V_ip6q.ip6q_prev); + CURVNET_RESTORE(); } + VNET_LIST_RUNLOCK(); IP6Q_UNLOCK(); #if 0 @@ -732,13 +744,21 @@ frag6_slowtimo(void) void frag6_drain(void) { + VNET_ITERATOR_DECL(vnet_iter); if (IP6Q_TRYLOCK() == 0) return; - while (V_ip6q.ip6q_next != &V_ip6q) { - V_ip6stat.ip6s_fragdropped++; - /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */ - frag6_freef(V_ip6q.ip6q_next); + VNET_LIST_RLOCK(); + VNET_FOREACH(vnet_iter) { + CURVNET_SET(vnet_iter); + INIT_VNET_INET6(vnet_iter); + while (V_ip6q.ip6q_next != &V_ip6q) { + V_ip6stat.ip6s_fragdropped++; + /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */ + frag6_freef(V_ip6q.ip6q_next); + } + CURVNET_RESTORE(); } + VNET_LIST_RUNLOCK(); IP6Q_UNLOCK(); } diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index c4651ef..65ef96c 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -136,6 +136,7 @@ static int icmp6_notify_error(struct mbuf **, int, int, int); void icmp6_init(void) { + INIT_VNET_INET6(curvnet); mld6_init(); } @@ -204,6 +205,7 @@ void icmp6_error2(struct mbuf *m, int type, int code, int param, struct ifnet *ifp) { + INIT_VNET_INET6(curvnet); struct ip6_hdr *ip6; if (ifp == NULL) @@ -235,6 +237,7 @@ icmp6_error2(struct mbuf *m, int type, int code, int param, void icmp6_error(struct mbuf *m, int type, int code, int param) { + INIT_VNET_INET6(curvnet); struct ip6_hdr *oip6, *nip6; struct icmp6_hdr *icmp6; u_int preplen; @@ -389,6 +392,8 @@ icmp6_error(struct mbuf *m, int type, int code, int param) int icmp6_input(struct mbuf **mp, int *offp, int proto) { + INIT_VNET_INET6(curvnet); + INIT_VPROCG(TD_TO_VPROCG(curthread)); /* XXX V_hostname needs this */ struct mbuf *m = *mp, *n; struct ip6_hdr *ip6, *nip6; struct icmp6_hdr *icmp6, *nicmp6; @@ -862,6 +867,7 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) static int icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code) { + INIT_VNET_INET6(curvnet); struct mbuf *m = *mp; struct icmp6_hdr *icmp6; struct ip6_hdr *eip6; @@ -1093,6 +1099,7 @@ icmp6_notify_error(struct mbuf **mp, int off, int icmp6len, int code) void icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated) { + INIT_VNET_INET6(curvnet); struct in6_addr *dst = ip6cp->ip6c_finaldst; struct icmp6_hdr *icmp6 = ip6cp->ip6c_icmp6; struct mbuf *m = ip6cp->ip6c_m; /* will be necessary for scope issue */ @@ -1158,6 +1165,8 @@ icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated) static struct mbuf * ni6_input(struct mbuf *m, int off) { + INIT_VNET_INET6(curvnet); + INIT_VPROCG(TD_TO_VPROCG(curthread)); /* XXX V_hostname needs this */ struct icmp6_nodeinfo *ni6, *nni6; struct mbuf *n = NULL; u_int16_t qtype; @@ -1643,6 +1652,8 @@ static int ni6_addrs(struct icmp6_nodeinfo *ni6, struct mbuf *m, struct ifnet **ifpp, struct in6_addr *subj) { + INIT_VNET_NET(curvnet); + INIT_VNET_INET6(curvnet); struct ifnet *ifp; struct in6_ifaddr *ifa6; struct ifaddr *ifa; @@ -1734,6 +1745,8 @@ static int ni6_store_addrs(struct icmp6_nodeinfo *ni6, struct icmp6_nodeinfo *nni6, struct ifnet *ifp0, int resid) { + INIT_VNET_NET(curvnet); + INIT_VNET_INET6(curvnet); struct ifnet *ifp = ifp0 ? ifp0 : TAILQ_FIRST(&V_ifnet); struct in6_ifaddr *ifa6; struct ifaddr *ifa; @@ -1873,6 +1886,8 @@ ni6_store_addrs(struct icmp6_nodeinfo *ni6, struct icmp6_nodeinfo *nni6, static int icmp6_rip6_input(struct mbuf **mp, int off) { + INIT_VNET_INET(curvnet); + INIT_VNET_INET6(curvnet); struct mbuf *m = *mp; struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct in6pcb *in6p; @@ -2033,6 +2048,7 @@ icmp6_rip6_input(struct mbuf **mp, int off) void icmp6_reflect(struct mbuf *m, size_t off) { + INIT_VNET_INET6(curvnet); struct ip6_hdr *ip6; struct icmp6_hdr *icmp6; struct in6_ifaddr *ia; @@ -2212,6 +2228,7 @@ icmp6_redirect_diag(struct in6_addr *src6, struct in6_addr *dst6, void icmp6_redirect_input(struct mbuf *m, int off) { + INIT_VNET_INET6(curvnet); struct ifnet *ifp; struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct nd_redirect *nd_rd; @@ -2419,6 +2436,7 @@ icmp6_redirect_input(struct mbuf *m, int off) void icmp6_redirect_output(struct mbuf *m0, struct rtentry *rt) { + INIT_VNET_INET6(curvnet); struct ifnet *ifp; /* my outgoing interface */ struct in6_addr *ifp_ll6; struct in6_addr *router_ll6; @@ -2785,6 +2803,7 @@ static int icmp6_ratelimit(const struct in6_addr *dst, const int type, const int code) { + INIT_VNET_INET6(curvnet); int ret; ret = 0; /* okay to send */ diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index a6cac29..19fba30 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -231,6 +231,7 @@ in6_ifaddloop(struct ifaddr *ifa) void in6_ifremloop(struct ifaddr *ifa) { + INIT_VNET_INET6(curvnet); struct in6_ifaddr *ia; struct rtentry *rt; int ia_count = 0; @@ -322,6 +323,7 @@ int in6_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, struct thread *td) { + INIT_VNET_INET6(curvnet); struct in6_ifreq *ifr = (struct in6_ifreq *)data; struct in6_ifaddr *ia = NULL; struct in6_aliasreq *ifra = (struct in6_aliasreq *)data; @@ -795,6 +797,8 @@ int in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra, struct in6_ifaddr *ia, int flags) { + INIT_VNET_INET6(ifp->if_vnet); + INIT_VPROCG(TD_TO_VPROCG(curthread)); /* XXX V_hostname needs this */ int error = 0, hostIsNew = 0, plen = -1; struct in6_ifaddr *oia; struct sockaddr_in6 dst6; @@ -1323,6 +1327,7 @@ in6_purgeaddr(struct ifaddr *ifa) static void in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp) { + INIT_VNET_INET6(ifp->if_vnet); struct in6_ifaddr *oia; int s = splnet(); @@ -1890,6 +1895,7 @@ ip6_sprintf(char *ip6buf, const struct in6_addr *addr) int in6_localaddr(struct in6_addr *in6) { + INIT_VNET_INET6(curvnet); struct in6_ifaddr *ia; if (IN6_IS_ADDR_LOOPBACK(in6) || IN6_IS_ADDR_LINKLOCAL(in6)) @@ -1908,6 +1914,7 @@ in6_localaddr(struct in6_addr *in6) int in6_is_addr_deprecated(struct sockaddr_in6 *sa6) { + INIT_VNET_INET6(curvnet); struct in6_ifaddr *ia; for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) { @@ -2000,6 +2007,7 @@ in6_prefixlen2mask(struct in6_addr *maskp, int len) struct in6_ifaddr * in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst) { + INIT_VNET_INET6(curvnet); int dst_scope = in6_addrscope(dst), blen = -1, tlen; struct ifaddr *ifa; struct in6_ifaddr *besta = 0; @@ -2148,6 +2156,8 @@ in6if_do_dad(struct ifnet *ifp) void in6_setmaxmtu(void) { + INIT_VNET_NET(curvnet); + INIT_VNET_INET6(curvnet); unsigned long maxmtu = 0; struct ifnet *ifp; diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c index bdee674..a0bdda8 100644 --- a/sys/netinet6/in6_gif.c +++ b/sys/netinet6/in6_gif.c @@ -87,6 +87,7 @@ in6_gif_output(struct ifnet *ifp, int family, /* family of the packet to be encapsulate */ struct mbuf *m) { + INIT_VNET_GIF(ifp->if_vnet); struct gif_softc *sc = ifp->if_softc; struct sockaddr_in6 *dst = (struct sockaddr_in6 *)&sc->gif_ro6.ro_dst; struct sockaddr_in6 *sin6_src = (struct sockaddr_in6 *)sc->gif_psrc; @@ -246,6 +247,7 @@ in6_gif_output(struct ifnet *ifp, int in6_gif_input(struct mbuf **mp, int *offp, int proto) { + INIT_VNET_INET6(curvnet); struct mbuf *m = *mp; struct ifnet *gifp = NULL; struct gif_softc *sc; diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 4f40a7a..a51f59c 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -104,6 +104,7 @@ static void in6_purgemaddrs(struct ifnet *); static int get_rand_ifid(struct ifnet *ifp, struct in6_addr *in6) { + INIT_VPROCG(TD_TO_VPROCG(curthread)); /* XXX V_hostname needs this */ MD5_CTX ctxt; u_int8_t digest[16]; int hostnamelen; @@ -139,6 +140,7 @@ get_rand_ifid(struct ifnet *ifp, struct in6_addr *in6) static int generate_tmp_ifid(u_int8_t *seed0, const u_int8_t *seed1, u_int8_t *ret) { + INIT_VNET_INET6(curvnet); MD5_CTX ctxt; u_int8_t seed[16], digest[16], nullbuf[8]; u_int32_t val32; @@ -358,6 +360,8 @@ static int get_ifid(struct ifnet *ifp0, struct ifnet *altifp, struct in6_addr *in6) { + INIT_VNET_NET(ifp0->if_vnet); + INIT_VNET_INET6(ifp0->if_vnet); struct ifnet *ifp; /* first, try to get it from the interface itself */ @@ -421,6 +425,7 @@ success: static int in6_ifattach_linklocal(struct ifnet *ifp, struct ifnet *altifp) { + INIT_VNET_INET6(curvnet); struct in6_ifaddr *ia; struct in6_aliasreq ifra; struct nd_prefixctl pr0; @@ -537,6 +542,7 @@ in6_ifattach_linklocal(struct ifnet *ifp, struct ifnet *altifp) static int in6_ifattach_loopback(struct ifnet *ifp) { + INIT_VNET_INET6(curvnet); struct in6_aliasreq ifra; int error; @@ -648,6 +654,7 @@ in6_nigroup(struct ifnet *ifp, const char *name, int namelen, void in6_ifattach(struct ifnet *ifp, struct ifnet *altifp) { + INIT_VNET_INET6(ifp->if_vnet); struct in6_ifaddr *ia; struct in6_addr in6; @@ -730,6 +737,9 @@ statinit: void in6_ifdetach(struct ifnet *ifp) { + INIT_VNET_NET(ifp->if_vnet); + INIT_VNET_INET(ifp->if_vnet); + INIT_VNET_INET6(ifp->if_vnet); struct in6_ifaddr *ia, *oia; struct ifaddr *ifa, *next; struct rtentry *rt; @@ -865,6 +875,8 @@ in6_get_tmpifid(struct ifnet *ifp, u_int8_t *retbuf, void in6_tmpaddrtimer(void *ignored_arg) { + INIT_VNET_NET(curvnet); + INIT_VNET_INET6(curvnet); struct nd_ifinfo *ndi; u_int8_t nullbuf[8]; struct ifnet *ifp; diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 979ddbd..404335b 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -117,6 +117,8 @@ int in6_pcbbind(register struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) { + INIT_VNET_INET6(inp->inp_vnet); + INIT_VNET_INET(inp->inp_vnet); struct socket *so = inp->inp_socket; struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)NULL; struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; @@ -284,6 +286,7 @@ int in6_pcbladdr(register struct inpcb *inp, struct sockaddr *nam, struct in6_addr **plocal_addr6) { + INIT_VNET_INET6(inp->inp_vnet); register struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; int error = 0; struct ifnet *ifp = NULL; diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index c1caaa5..ca221fe 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -458,6 +458,7 @@ SYSCTL_NODE(_net_inet6, IPPROTO_ESP, ipsec6, CTLFLAG_RW, 0, "IPSEC6"); static int sysctl_ip6_temppltime(SYSCTL_HANDLER_ARGS) { + INIT_VNET_INET6(curvnet); int error = 0; int old; @@ -477,6 +478,7 @@ sysctl_ip6_temppltime(SYSCTL_HANDLER_ARGS) static int sysctl_ip6_tempvltime(SYSCTL_HANDLER_ARGS) { + INIT_VNET_INET6(curvnet); int error = 0; int old; @@ -492,91 +494,92 @@ sysctl_ip6_tempvltime(SYSCTL_HANDLER_ARGS) return (error); } -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_FORWARDING, - forwarding, CTLFLAG_RW, &ip6_forwarding, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_SENDREDIRECTS, - redirect, CTLFLAG_RW, &ip6_sendredirects, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFHLIM, - hlim, CTLFLAG_RW, &ip6_defhlim, 0, ""); -SYSCTL_STRUCT(_net_inet6_ip6, IPV6CTL_STATS, stats, CTLFLAG_RD, - &ip6stat, ip6stat, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS, - maxfragpackets, CTLFLAG_RW, &ip6_maxfragpackets, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_ACCEPT_RTADV, - accept_rtadv, CTLFLAG_RW, &ip6_accept_rtadv, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_KEEPFAITH, - keepfaith, CTLFLAG_RW, &ip6_keepfaith, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_LOG_INTERVAL, - log_interval, CTLFLAG_RW, &ip6_log_interval, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_HDRNESTLIMIT, - hdrnestlimit, CTLFLAG_RW, &ip6_hdrnestlimit, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DAD_COUNT, - dad_count, CTLFLAG_RW, &ip6_dad_count, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_FLOWLABEL, - auto_flowlabel, CTLFLAG_RW, &ip6_auto_flowlabel, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_DEFMCASTHLIM, - defmcasthlim, CTLFLAG_RW, &ip6_defmcasthlim, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_GIF_HLIM, - gifhlim, CTLFLAG_RW, &ip6_gif_hlim, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_FORWARDING, + forwarding, CTLFLAG_RW, ip6_forwarding, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_SENDREDIRECTS, + redirect, CTLFLAG_RW, ip6_sendredirects, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_DEFHLIM, + hlim, CTLFLAG_RW, ip6_defhlim, 0, ""); +SYSCTL_V_STRUCT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_STATS, stats, + CTLFLAG_RD, ip6stat, ip6stat, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_MAXFRAGPACKETS, + maxfragpackets, CTLFLAG_RW, ip6_maxfragpackets, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_ACCEPT_RTADV, + accept_rtadv, CTLFLAG_RW, ip6_accept_rtadv, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_KEEPFAITH, + keepfaith, CTLFLAG_RW, ip6_keepfaith, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_LOG_INTERVAL, + log_interval, CTLFLAG_RW, ip6_log_interval, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_HDRNESTLIMIT, + hdrnestlimit, CTLFLAG_RW, ip6_hdrnestlimit, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_DAD_COUNT, + dad_count, CTLFLAG_RW, ip6_dad_count, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_AUTO_FLOWLABEL, + auto_flowlabel, CTLFLAG_RW, ip6_auto_flowlabel, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_DEFMCASTHLIM, + defmcasthlim, CTLFLAG_RW, ip6_defmcasthlim, 0, ""); SYSCTL_STRING(_net_inet6_ip6, IPV6CTL_KAME_VERSION, kame_version, CTLFLAG_RD, __KAME_VERSION, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEPRECATED, - use_deprecated, CTLFLAG_RW, &ip6_use_deprecated, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_RR_PRUNE, - rr_prune, CTLFLAG_RW, &ip6_rr_prune, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USETEMPADDR, - use_tempaddr, CTLFLAG_RW, &ip6_use_tempaddr, 0, ""); -SYSCTL_OID(_net_inet6_ip6, IPV6CTL_TEMPPLTIME, temppltime, - CTLTYPE_INT|CTLFLAG_RW, &ip6_temp_preferred_lifetime, 0, - sysctl_ip6_temppltime, "I", ""); -SYSCTL_OID(_net_inet6_ip6, IPV6CTL_TEMPVLTIME, tempvltime, - CTLTYPE_INT|CTLFLAG_RW, &ip6_temp_valid_lifetime, 0, - sysctl_ip6_tempvltime, "I", ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_V6ONLY, - v6only, CTLFLAG_RW, &ip6_v6only, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_USE_DEPRECATED, + use_deprecated, CTLFLAG_RW, ip6_use_deprecated, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_RR_PRUNE, + rr_prune, CTLFLAG_RW, ip6_rr_prune, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_USETEMPADDR, + use_tempaddr, CTLFLAG_RW, ip6_use_tempaddr, 0, ""); +SYSCTL_V_OID(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_TEMPPLTIME, temppltime, + CTLTYPE_INT|CTLFLAG_RW, ip6_temp_preferred_lifetime, 0, + sysctl_ip6_temppltime, "I", ""); +SYSCTL_V_OID(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_TEMPVLTIME, tempvltime, + CTLTYPE_INT|CTLFLAG_RW, ip6_temp_valid_lifetime, 0, + sysctl_ip6_tempvltime, "I", ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_V6ONLY, + v6only, CTLFLAG_RW, ip6_v6only, 0, ""); +#ifndef VIMAGE TUNABLE_INT("net.inet6.ip6.auto_linklocal", &ip6_auto_linklocal); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_AUTO_LINKLOCAL, - auto_linklocal, CTLFLAG_RW, &ip6_auto_linklocal, 0, ""); -SYSCTL_STRUCT(_net_inet6_ip6, IPV6CTL_RIP6STATS, rip6stats, CTLFLAG_RD, - &rip6stat, rip6stat, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_PREFER_TEMPADDR, - prefer_tempaddr, CTLFLAG_RW, &ip6_prefer_tempaddr, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_USE_DEFAULTZONE, - use_defaultzone, CTLFLAG_RW, &ip6_use_defzone, 0,""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MAXFRAGS, - maxfrags, CTLFLAG_RW, &ip6_maxfrags, 0, ""); -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_MCAST_PMTU, - mcast_pmtu, CTLFLAG_RW, &ip6_mcast_pmtu, 0, ""); +#endif +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_AUTO_LINKLOCAL, + auto_linklocal, CTLFLAG_RW, ip6_auto_linklocal, 0, ""); +SYSCTL_V_STRUCT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_RIP6STATS, + rip6stats, CTLFLAG_RD, rip6stat, rip6stat, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_PREFER_TEMPADDR, + prefer_tempaddr, CTLFLAG_RW, ip6_prefer_tempaddr, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_USE_DEFAULTZONE, + use_defaultzone, CTLFLAG_RW, ip6_use_defzone, 0,""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_MAXFRAGS, + maxfrags, CTLFLAG_RW, ip6_maxfrags, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_MCAST_PMTU, + mcast_pmtu, CTLFLAG_RW, ip6_mcast_pmtu, 0, ""); #ifdef IPSTEALTH -SYSCTL_INT(_net_inet6_ip6, IPV6CTL_STEALTH, stealth, CTLFLAG_RW, - &ip6stealth, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_ip6, IPV6CTL_STEALTH, + stealth, CTLFLAG_RW, ip6stealth, 0, ""); #endif /* net.inet6.icmp6 */ -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, - rediraccept, CTLFLAG_RW, &icmp6_rediraccept, 0, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, - redirtimeout, CTLFLAG_RW, &icmp6_redirtimeout, 0, ""); -SYSCTL_STRUCT(_net_inet6_icmp6, ICMPV6CTL_STATS, stats, CTLFLAG_RD, - &icmp6stat, icmp6stat, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, - nd6_prune, CTLFLAG_RW, &nd6_prune, 0, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, - nd6_delay, CTLFLAG_RW, &nd6_delay, 0, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES, - nd6_umaxtries, CTLFLAG_RW, &nd6_umaxtries, 0, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES, - nd6_mmaxtries, CTLFLAG_RW, &nd6_mmaxtries, 0, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK, - nd6_useloopback, CTLFLAG_RW, &nd6_useloopback, 0, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_NODEINFO, - nodeinfo, CTLFLAG_RW, &icmp6_nodeinfo, 0, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT, - errppslimit, CTLFLAG_RW, &icmp6errppslim, 0, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXNUDHINT, - nd6_maxnudhint, CTLFLAG_RW, &nd6_maxnudhint, 0, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG, - nd6_debug, CTLFLAG_RW, &nd6_debug, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_REDIRACCEPT, + rediraccept, CTLFLAG_RW, icmp6_rediraccept, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_REDIRTIMEOUT, + redirtimeout, CTLFLAG_RW, icmp6_redirtimeout, 0, ""); +SYSCTL_V_STRUCT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_STATS, + stats, CTLFLAG_RD, icmp6stat, icmp6stat, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_PRUNE, + nd6_prune, CTLFLAG_RW, nd6_prune, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_DELAY, + nd6_delay, CTLFLAG_RW, nd6_delay, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_UMAXTRIES, + nd6_umaxtries, CTLFLAG_RW, nd6_umaxtries, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_MMAXTRIES, + nd6_mmaxtries, CTLFLAG_RW, nd6_mmaxtries, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_USELOOPBACK, + nd6_useloopback, CTLFLAG_RW, nd6_useloopback, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_NODEINFO, + nodeinfo, CTLFLAG_RW, icmp6_nodeinfo, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ERRPPSLIMIT, + errppslimit, CTLFLAG_RW, icmp6errppslim, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_MAXNUDHINT, + nd6_maxnudhint, CTLFLAG_RW, nd6_maxnudhint, 0, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_DEBUG, + nd6_debug, CTLFLAG_RW, nd6_debug, 0, ""); + SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_ONLINKNSRFC4861, nd6_onlink_ns_rfc4861, CTLFLAG_RW, &nd6_onlink_ns_rfc4861, 0, "Accept 'on-link' nd6 NS in compliance with RFC 4861."); diff --git a/sys/netinet6/in6_rmx.c b/sys/netinet6/in6_rmx.c index 6a719ca..ff426dc 100644 --- a/sys/netinet6/in6_rmx.c +++ b/sys/netinet6/in6_rmx.c @@ -242,6 +242,7 @@ SYSCTL_INT(_net_inet6_ip6, IPV6CTL_RTMAXCACHE, rtmaxcache, static void in6_clsroute(struct radix_node *rn, struct radix_node_head *head) { + INIT_VNET_INET6(curvnet); struct rtentry *rt = (struct rtentry *)rn; RT_LOCK_ASSERT(rt); @@ -286,6 +287,7 @@ struct rtqk_arg { static int in6_rtqkill(struct radix_node *rn, void *rock) { + INIT_VNET_INET6(curvnet); struct rtqk_arg *ap = rock; struct rtentry *rt = (struct rtentry *)rn; int err; @@ -328,6 +330,9 @@ static struct callout rtq_timer6; static void in6_rtqtimo(void *rock) { + CURVNET_SET_QUIET((struct vnet *) rock); + INIT_VNET_NET((struct vnet *) rock); + INIT_VNET_INET6((struct vnet *) rock); struct radix_node_head *rnh = rock; struct rtqk_arg arg; struct timeval atv; @@ -372,6 +377,7 @@ in6_rtqtimo(void *rock) atv.tv_usec = 0; atv.tv_sec = arg.nextstop - time_uptime; callout_reset(&V_rtq_timer6, tvtohz(&atv), in6_rtqtimo, rock); + CURVNET_RESTORE(); } /* @@ -410,6 +416,9 @@ in6_mtuexpire(struct radix_node *rn, void *rock) static void in6_mtutimo(void *rock) { + CURVNET_SET_QUIET((struct vnet *) rock); + INIT_VNET_NET((struct vnet *) rock); + INIT_VNET_INET6((struct vnet *) rock); struct radix_node_head *rnh = rock; struct mtuex_arg arg; struct timeval atv; @@ -428,12 +437,14 @@ in6_mtutimo(void *rock) atv.tv_sec = 30; } callout_reset(&V_rtq_mtutimer, tvtohz(&atv), in6_mtutimo, rock); + CURVNET_RESTORE(); } #if 0 void in6_rtqdrain(void) { + INIT_VNET_NET(curvnet); struct radix_node_head *rnh = V_rt_tables[AF_INET6]; struct rtqk_arg arg; @@ -458,6 +469,7 @@ in6_rtqdrain(void) int in6_inithead(void **head, int off) { + INIT_VNET_INET6(curvnet); struct radix_node_head *rnh; if (!rn_inithead(head, offsetof(struct sockaddr_in6, sin6_addr) << 3)) diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index 7a0d7d1..cb2ad89 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -174,6 +174,7 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, struct inpcb *inp, struct route_in6 *ro, struct ucred *cred, struct ifnet **ifpp, int *errorp) { + INIT_VNET_INET6(curvnet); struct in6_addr dst; struct ifnet *ifp = NULL; struct in6_ifaddr *ia = NULL, *ia_best = NULL; @@ -456,6 +457,8 @@ selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, struct ifnet **retifp, struct rtentry **retrt, int clone, int norouteok) { + INIT_VNET_NET(curvnet); + INIT_VNET_INET6(curvnet); int error = 0; struct ifnet *ifp = NULL; struct rtentry *rt = NULL; @@ -735,6 +738,7 @@ in6_selectroute(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, int in6_selecthlim(struct in6pcb *in6p, struct ifnet *ifp) { + INIT_VNET_INET6(curvnet); if (in6p && in6p->in6p_hops >= 0) return (in6p->in6p_hops); @@ -767,6 +771,7 @@ in6_selecthlim(struct in6pcb *in6p, struct ifnet *ifp) int in6_pcbsetport(struct in6_addr *laddr, struct inpcb *inp, struct ucred *cred) { + INIT_VNET_INET(curvnet); struct socket *so = inp->inp_socket; u_int16_t lport = 0, first, last, *lastport; int count, error = 0, wild = 0; @@ -863,6 +868,7 @@ addrsel_policy_init(void) { ADDRSEL_LOCK_INIT(); ADDRSEL_SXLOCK_INIT(); + INIT_VNET_INET6(curvnet); init_policy_queue(); @@ -874,6 +880,7 @@ addrsel_policy_init(void) static struct in6_addrpolicy * lookup_addrsel_policy(struct sockaddr_in6 *key) { + INIT_VNET_INET6(curvnet); struct in6_addrpolicy *match = NULL; ADDRSEL_LOCK(); @@ -965,6 +972,7 @@ struct addrsel_policyhead addrsel_policytab; static void init_policy_queue(void) { + INIT_VNET_INET6(curvnet); TAILQ_INIT(&V_addrsel_policytab); } @@ -972,6 +980,7 @@ init_policy_queue(void) static int add_addrsel_policyent(struct in6_addrpolicy *newpolicy) { + INIT_VNET_INET6(curvnet); struct addrsel_policyent *new, *pol; MALLOC(new, struct addrsel_policyent *, sizeof(*new), M_IFADDR, @@ -1007,6 +1016,7 @@ add_addrsel_policyent(struct in6_addrpolicy *newpolicy) static int delete_addrsel_policyent(struct in6_addrpolicy *key) { + INIT_VNET_INET6(curvnet); struct addrsel_policyent *pol; ADDRSEL_XLOCK(); @@ -1038,6 +1048,7 @@ static int walk_addrsel_policy(int (*callback)(struct in6_addrpolicy *, void *), void *w) { + INIT_VNET_INET6(curvnet); struct addrsel_policyent *pol; int error = 0; @@ -1066,6 +1077,7 @@ dump_addrsel_policyent(struct in6_addrpolicy *pol, void *arg) static struct in6_addrpolicy * match_addrsel_policy(struct sockaddr_in6 *key) { + INIT_VNET_INET6(curvnet); struct addrsel_policyent *pent; struct in6_addrpolicy *bestpol = NULL, *pol; int matchlen, bestmatchlen = -1; diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c index ec25a31..8745b08 100644 --- a/sys/netinet6/ip6_forward.c +++ b/sys/netinet6/ip6_forward.c @@ -93,6 +93,7 @@ struct route_in6 ip6_forward_rt; void ip6_forward(struct mbuf *m, int srcrt) { + INIT_VNET_INET6(curvnet); struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct sockaddr_in6 *dst = NULL; struct rtentry *rt = NULL; @@ -102,6 +103,7 @@ ip6_forward(struct mbuf *m, int srcrt) u_int32_t inzone, outzone; struct in6_addr src_in6, dst_in6; #ifdef IPSEC + INIT_VNET_IPSEC(curvnet); struct secpolicy *sp = NULL; int ipsecrt = 0; #endif diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 6bd9557..8bd178f 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -145,6 +145,7 @@ static struct mbuf *ip6_pullexthdr(struct mbuf *, size_t, int); void ip6_init(void) { + INIT_VNET_INET6(curvnet); struct ip6protosw *pr; int i; @@ -192,6 +193,7 @@ ip6_init(void) static void ip6_init2(void *dummy) { + INIT_VNET_INET6(curvnet); /* nd6_timer_init */ callout_init(&V_nd6_timer_ch, 0); @@ -214,6 +216,8 @@ extern struct route_in6 ip6_forward_rt; void ip6_input(struct mbuf *m) { + INIT_VNET_NET(curvnet); + INIT_VNET_INET6(curvnet); struct ip6_hdr *ip6; int off = sizeof(struct ip6_hdr), nest; u_int32_t plen; @@ -813,6 +817,7 @@ static int ip6_hopopts_input(u_int32_t *plenp, u_int32_t *rtalertp, struct mbuf **mp, int *offp) { + INIT_VNET_INET6(curvnet); struct mbuf *m = *mp; int off = *offp, hbhlen; struct ip6_hbh *hbh; @@ -868,6 +873,7 @@ int ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen, u_int32_t *rtalertp, u_int32_t *plenp) { + INIT_VNET_INET6(curvnet); struct ip6_hdr *ip6; int optlen = 0; u_int8_t *opt = opthead; @@ -1000,6 +1006,7 @@ ip6_process_hopopts(struct mbuf *m, u_int8_t *opthead, int hbhlen, int ip6_unknown_opt(u_int8_t *optp, struct mbuf *m, int off) { + INIT_VNET_INET6(curvnet); struct ip6_hdr *ip6; switch (IP6OPT_TYPE(*optp)) { diff --git a/sys/netinet6/ip6_ipsec.c b/sys/netinet6/ip6_ipsec.c index a8aaedb..23f4e26 100644 --- a/sys/netinet6/ip6_ipsec.c +++ b/sys/netinet6/ip6_ipsec.c @@ -103,6 +103,8 @@ int ip6_ipsec_fwd(struct mbuf *m) { #ifdef IPSEC + INIT_VNET_INET6(curvnet); + INIT_VNET_IPSEC(curvnet); struct m_tag *mtag; struct tdb_ident *tdbi; struct secpolicy *sp; @@ -148,6 +150,7 @@ int ip6_ipsec_input(struct mbuf *m, int nxt) { #ifdef IPSEC + INIT_VNET_IPSEC(curvnet); struct m_tag *mtag; struct tdb_ident *tdbi; struct secpolicy *sp; diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index 1b234c7..61a6e5c 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -376,6 +376,7 @@ X_ip6_mrouter_set(struct socket *so, struct sockopt *sopt) int X_ip6_mrouter_get(struct socket *so, struct sockopt *sopt) { + INIT_VNET_INET6(curvnet); int error = 0; if (so != ip6_mrouter) @@ -452,6 +453,7 @@ get_mif6_cnt(struct sioc_mif_req6 *req) static int set_pim6(int *i) { + INIT_VNET_INET6(curvnet); if ((*i != 1) && (*i != 0)) return (EINVAL); @@ -466,6 +468,8 @@ set_pim6(int *i) static int ip6_mrouter_init(struct socket *so, int v, int cmd) { + INIT_VNET_INET6(curvnet); + #ifdef MRT6DEBUG if (V_mrt6debug) log(LOG_DEBUG, @@ -509,6 +513,7 @@ ip6_mrouter_init(struct socket *so, int v, int cmd) int X_ip6_mrouter_done(void) { + INIT_VNET_INET6(curvnet); mifi_t mifi; int i; struct mf6c *rt; @@ -601,6 +606,7 @@ static struct sockaddr_in6 sin6 = { sizeof(sin6), AF_INET6 }; static int add_m6if(struct mif6ctl *mifcp) { + INIT_VNET_NET(curvnet); struct mif6 *mifp; struct ifnet *ifp; int error, s; @@ -1002,6 +1008,7 @@ socket_send(struct socket *s, struct mbuf *mm, struct sockaddr_in6 *src) int X_ip6_mforward(struct ip6_hdr *ip6, struct ifnet *ifp, struct mbuf *m) { + INIT_VNET_INET6(curvnet); struct mf6c *rt; struct mif6 *mifp; struct mbuf *mm; @@ -1327,6 +1334,7 @@ expire_upcalls(void *unused) static int ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt) { + INIT_VNET_INET6(curvnet); struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); mifi_t mifi, iif; struct mif6 *mifp; @@ -1505,6 +1513,7 @@ ip6_mdq(struct mbuf *m, struct ifnet *ifp, struct mf6c *rt) static void phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m) { + INIT_VNET_INET6(curvnet); struct mbuf *mb_copy; struct ifnet *ifp = mifp->m6_ifp; int error = 0; @@ -1692,6 +1701,7 @@ register_send(struct ip6_hdr *ip6, struct mif6 *mif, struct mbuf *m) int pim6_input(struct mbuf **mp, int *offp, int proto) { + INIT_VNET_INET6(curvnet); struct pim *pim; /* pointer to a pim struct */ struct ip6_hdr *ip6; int pimlen; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 7c07bdf..311d772 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -189,6 +189,8 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, struct route_in6 *ro, int flags, struct ip6_moptions *im6o, struct ifnet **ifpp, struct inpcb *inp) { + INIT_VNET_NET(curvnet); + INIT_VNET_INET6(curvnet); struct ip6_hdr *ip6, *mhip6; struct ifnet *ifp, *origifp; struct mbuf *m = m0; @@ -2420,6 +2422,8 @@ ip6_freepcbopts(struct ip6_pktopts *pktopt) static int ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m) { + INIT_VNET_NET(curvnet); + INIT_VNET_INET6(curvnet); int error = 0; u_int loop, ifindex; struct ipv6_mreq *mreq; @@ -2721,6 +2725,7 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m) static int ip6_getmoptions(int optname, struct ip6_moptions *im6o, struct mbuf **mp) { + INIT_VNET_INET6(curvnet); u_int *hlim, *loop, *ifindex; *mp = m_get(M_WAIT, MT_HEADER); /* XXX */ @@ -2850,6 +2855,8 @@ static int ip6_setpktopt(int optname, u_char *buf, int len, struct ip6_pktopts *opt, struct ucred *cred, int sticky, int cmsg, int uproto) { + INIT_VNET_NET(curvnet); + INIT_VNET_INET6(curvnet); int minmtupolicy, preftemp; int error; diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index 6ca9d0c..7bfd2c4 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -115,6 +115,7 @@ static u_long mld_timerresid(struct in6_multi *); void mld6_init(void) { + INIT_VNET_INET6(curvnet); static u_int8_t hbh_buf[8]; struct ip6_hbh *hbh = (struct ip6_hbh *)hbh_buf; u_int16_t rtalert_code = htons((u_int16_t)IP6OPT_RTALERT_MLD); @@ -268,6 +269,7 @@ mld6_stop_listening(struct in6_multi *in6m) void mld6_input(struct mbuf *m, int off) { + INIT_VNET_INET6(curvnet); struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct mld_hdr *mldh; struct ifnet *ifp = m->m_pkthdr.rcvif; @@ -438,6 +440,7 @@ mld6_input(struct mbuf *m, int off) static void mld6_sendpkt(struct in6_multi *in6m, int type, const struct in6_addr *dst) { + INIT_VNET_INET6(curvnet); struct mbuf *mh, *md; struct mld_hdr *mldh; struct ip6_hdr *ip6; diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 94c4401..2ea6330 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -125,6 +125,7 @@ extern struct callout in6_tmpaddrtimer_ch; void nd6_init(void) { + INIT_VNET_INET6(curvnet); static int nd6_init_done = 0; int i; @@ -198,6 +199,7 @@ nd6_setmtu(struct ifnet *ifp) void nd6_setmtu0(struct ifnet *ifp, struct nd_ifinfo *ndi) { + INIT_VNET_INET6(ifp->if_vnet); u_int32_t omaxmtu; omaxmtu = ndi->maxmtu; @@ -307,6 +309,7 @@ nd6_option(union nd_opts *ndopts) int nd6_options(union nd_opts *ndopts) { + INIT_VNET_INET6(curvnet); struct nd_opt_hdr *nd_opt; int i = 0; @@ -432,6 +435,9 @@ nd6_llinfo_timer(void *arg) panic("ln->ln_rt->rt_ifp == NULL"); ndi = ND_IFINFO(ifp); + CURVNET_SET(ifp->if_vnet); + INIT_VNET_INET6(curvnet); + /* sanity check */ if (rt->rt_llinfo && (struct llinfo_nd6 *)rt->rt_llinfo != ln) panic("rt_llinfo(%p) is not equal to ln(%p)", @@ -522,6 +528,7 @@ nd6_llinfo_timer(void *arg) } break; } + CURVNET_RESTORE(); } @@ -529,8 +536,10 @@ nd6_llinfo_timer(void *arg) * ND6 timer routine to expire default route list and prefix list */ void -nd6_timer(void *ignored_arg) +nd6_timer(void *arg) { + CURVNET_SET_QUIET((struct vnet *) arg); + INIT_VNET_INET6((struct vnet *) arg); int s; struct nd_defrouter *dr; struct nd_prefix *pr; @@ -650,6 +659,7 @@ nd6_timer(void *ignored_arg) pr = pr->ndpr_next; } splx(s); + CURVNET_RESTORE(); } /* @@ -724,6 +734,7 @@ regen_tmpaddr(struct in6_ifaddr *ia6) void nd6_purge(struct ifnet *ifp) { + INIT_VNET_INET6(ifp->if_vnet); struct llinfo_nd6 *ln, *nln; struct nd_defrouter *dr, *ndr; struct nd_prefix *pr, *npr; @@ -811,6 +822,7 @@ nd6_purge(struct ifnet *ifp) struct rtentry * nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp) { + INIT_VNET_INET6(curvnet); struct rtentry *rt; struct sockaddr_in6 sin6; char ip6buf[INET6_ADDRSTRLEN]; @@ -916,6 +928,7 @@ nd6_lookup(struct in6_addr *addr6, int create, struct ifnet *ifp) static int nd6_is_new_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp) { + INIT_VNET_INET6(ifp->if_vnet); struct nd_prefix *pr; struct ifaddr *dstaddr; @@ -1013,6 +1026,7 @@ nd6_is_addr_neighbor(struct sockaddr_in6 *addr, struct ifnet *ifp) static struct llinfo_nd6 * nd6_free(struct rtentry *rt, int gc) { + INIT_VNET_INET6(curvnet); struct llinfo_nd6 *ln = (struct llinfo_nd6 *)rt->rt_llinfo, *next; struct in6_addr in6 = ((struct sockaddr_in6 *)rt_key(rt))->sin6_addr; struct nd_defrouter *dr; @@ -1122,6 +1136,7 @@ nd6_free(struct rtentry *rt, int gc) void nd6_nud_hint(struct rtentry *rt, struct in6_addr *dst6, int force) { + INIT_VNET_INET6(curvnet); struct llinfo_nd6 *ln; /* @@ -1175,6 +1190,8 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK}; struct ifnet *ifp = rt->rt_ifp; struct ifaddr *ifa; + INIT_VNET_NET(ifp->if_vnet); + INIT_VNET_INET6(ifp->if_vnet); RT_LOCK_ASSERT(rt); @@ -1415,6 +1432,7 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) int nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp) { + INIT_VNET_INET6(ifp->if_vnet); struct in6_drlist *drl = (struct in6_drlist *)data; struct in6_oprlist *oprl = (struct in6_oprlist *)data; struct in6_ndireq *ndi = (struct in6_ndireq *)data; @@ -1653,6 +1671,7 @@ struct rtentry * nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr, int lladdrlen, int type, int code) { + INIT_VNET_INET6(curvnet); struct rtentry *rt = NULL; struct llinfo_nd6 *ln = NULL; int is_newentry; @@ -1883,8 +1902,11 @@ fail: } static void -nd6_slowtimo(void *ignored_arg) +nd6_slowtimo(void *arg) { + CURVNET_SET((struct vnet *) arg); + INIT_VNET_NET((struct vnet *) arg); + INIT_VNET_INET6((struct vnet *) arg); struct nd_ifinfo *nd6if; struct ifnet *ifp; @@ -1907,6 +1929,7 @@ nd6_slowtimo(void *ignored_arg) } } IFNET_RUNLOCK(); + CURVNET_RESTORE(); } #define senderr(e) { error = (e); goto bad;} @@ -1914,6 +1937,7 @@ int nd6_output(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0, struct sockaddr_in6 *dst, struct rtentry *rt0) { + INIT_VNET_INET6(curvnet); struct mbuf *m = m0; struct rtentry *rt = rt0; struct sockaddr_in6 *gw6 = NULL; @@ -2264,12 +2288,13 @@ SYSCTL_NODE(_net_inet6_icmp6, ICMPV6CTL_ND6_DRLIST, nd6_drlist, CTLFLAG_RD, nd6_sysctl_drlist, ""); SYSCTL_NODE(_net_inet6_icmp6, ICMPV6CTL_ND6_PRLIST, nd6_prlist, CTLFLAG_RD, nd6_sysctl_prlist, ""); -SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXQLEN, nd6_maxqueuelen, - CTLFLAG_RW, &nd6_maxqueuelen, 1, ""); +SYSCTL_V_INT(V_NET, vnet_inet6, _net_inet6_icmp6, ICMPV6CTL_ND6_MAXQLEN, + nd6_maxqueuelen, CTLFLAG_RW, nd6_maxqueuelen, 1, ""); static int nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS) { + INIT_VNET_INET6(curvnet); int error; char buf[1024] __aligned(4); struct in6_defrouter *d, *de; @@ -2310,6 +2335,7 @@ nd6_sysctl_drlist(SYSCTL_HANDLER_ARGS) static int nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS) { + INIT_VNET_INET6(curvnet); int error; char buf[1024] __aligned(4); struct in6_prefix *p, *pe; diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index 770a40a..f87a7a82 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -98,6 +98,7 @@ static int dad_maxtry = 15; /* max # of *tries* to transmit DAD packet */ void nd6_ns_input(struct mbuf *m, int off, int icmp6len) { + INIT_VNET_INET6(curvnet); struct ifnet *ifp = m->m_pkthdr.rcvif; struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct nd_neighbor_solicit *nd_ns; @@ -377,6 +378,7 @@ void nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6, const struct in6_addr *taddr6, struct llinfo_nd6 *ln, int dad) { + INIT_VNET_INET6(ifp->if_vnet); struct mbuf *m; struct ip6_hdr *ip6; struct nd_neighbor_solicit *nd_ns; @@ -582,6 +584,7 @@ nd6_ns_output(struct ifnet *ifp, const struct in6_addr *daddr6, void nd6_na_input(struct mbuf *m, int off, int icmp6len) { + INIT_VNET_INET6(curvnet); struct ifnet *ifp = m->m_pkthdr.rcvif; struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct nd_neighbor_advert *nd_na; @@ -894,6 +897,7 @@ nd6_na_output(struct ifnet *ifp, const struct in6_addr *daddr6_0, const struct in6_addr *taddr6, u_long flags, int tlladdr, struct sockaddr *sdl0) { + INIT_VNET_INET6(ifp->if_vnet); struct mbuf *m; struct ip6_hdr *ip6; struct nd_neighbor_advert *nd_na; @@ -1098,6 +1102,7 @@ static int dad_init = 0; static struct dadq * nd6_dad_find(struct ifaddr *ifa) { + INIT_VNET_INET6(curvnet); struct dadq *dp; for (dp = V_dadq.tqh_first; dp; dp = dp->dad_list.tqe_next) { @@ -1128,6 +1133,7 @@ nd6_dad_stoptimer(struct dadq *dp) void nd6_dad_start(struct ifaddr *ifa, int delay) { + INIT_VNET_INET6(curvnet); struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa; struct dadq *dp; char ip6buf[INET6_ADDRSTRLEN]; @@ -1210,6 +1216,7 @@ nd6_dad_start(struct ifaddr *ifa, int delay) void nd6_dad_stop(struct ifaddr *ifa) { + INIT_VNET_INET6(curvnet); struct dadq *dp; if (!V_dad_init) @@ -1231,6 +1238,8 @@ nd6_dad_stop(struct ifaddr *ifa) static void nd6_dad_timer(struct ifaddr *ifa) { + CURVNET_SET(dp->dad_vnet); + INIT_VNET_INET6(curvnet); int s; struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa; struct dadq *dp; @@ -1330,11 +1339,13 @@ nd6_dad_timer(struct ifaddr *ifa) done: splx(s); + CURVNET_RESTORE(); } void nd6_dad_duplicated(struct ifaddr *ifa) { + INIT_VNET_INET6(curvnet); struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa; struct ifnet *ifp; struct dadq *dp; @@ -1424,6 +1435,7 @@ nd6_dad_ns_output(struct dadq *dp, struct ifaddr *ifa) static void nd6_dad_ns_input(struct ifaddr *ifa) { + INIT_VNET_INET6(curvnet); struct in6_ifaddr *ia; struct ifnet *ifp; const struct in6_addr *taddr6; diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 3eb49bd..a1f891b 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -119,6 +119,7 @@ int ip6_temp_regen_advance = TEMPADDR_REGEN_ADVANCE; void nd6_rs_input(struct mbuf *m, int off, int icmp6len) { + INIT_VNET_INET6(curvnet); struct ifnet *ifp = m->m_pkthdr.rcvif; struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct nd_router_solicit *nd_rs; @@ -203,6 +204,7 @@ nd6_rs_input(struct mbuf *m, int off, int icmp6len) void nd6_ra_input(struct mbuf *m, int off, int icmp6len) { + INIT_VNET_INET6(curvnet); struct ifnet *ifp = m->m_pkthdr.rcvif; struct nd_ifinfo *ndi = ND_IFINFO(ifp); struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); @@ -483,6 +485,7 @@ defrouter_addreq(struct nd_defrouter *new) struct nd_defrouter * defrouter_lookup(struct in6_addr *addr, struct ifnet *ifp) { + INIT_VNET_INET6(ifp->if_vnet); struct nd_defrouter *dr; for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; @@ -531,6 +534,7 @@ defrouter_delreq(struct nd_defrouter *dr) void defrouter_reset(void) { + INIT_VNET_INET6(curvnet); struct nd_defrouter *dr; for (dr = TAILQ_FIRST(&V_nd_defrouter); dr; @@ -546,6 +550,7 @@ defrouter_reset(void) void defrtrlist_del(struct nd_defrouter *dr) { + INIT_VNET_INET6(curvnet); struct nd_defrouter *deldr = NULL; struct nd_prefix *pr; @@ -607,6 +612,7 @@ defrtrlist_del(struct nd_defrouter *dr) void defrouter_select(void) { + INIT_VNET_INET6(curvnet); int s = splnet(); struct nd_defrouter *dr, *selected_dr = NULL, *installed_dr = NULL; struct rtentry *rt = NULL; @@ -723,6 +729,7 @@ rtpref(struct nd_defrouter *dr) static struct nd_defrouter * defrtrlist_update(struct nd_defrouter *new) { + INIT_VNET_INET6(curvnet); struct nd_defrouter *dr, *n; int s = splnet(); @@ -844,6 +851,7 @@ pfxrtr_del(struct nd_pfxrouter *pfr) struct nd_prefix * nd6_prefix_lookup(struct nd_prefixctl *key) { + INIT_VNET_INET6(curvnet); struct nd_prefix *search; for (search = V_nd_prefix.lh_first; @@ -863,6 +871,7 @@ int nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr, struct nd_prefix **newp) { + INIT_VNET_INET6(curvnet); struct nd_prefix *new = NULL; int error = 0; int i, s; @@ -921,6 +930,7 @@ nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr, void prelist_remove(struct nd_prefix *pr) { + INIT_VNET_INET6(curvnet); struct nd_pfxrouter *pfr, *next; int e, s; char ip6buf[INET6_ADDRSTRLEN]; @@ -973,6 +983,7 @@ static int prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr, struct mbuf *m, int mcast) { + INIT_VNET_INET6(curvnet); struct in6_ifaddr *ia6 = NULL, *ia6_match = NULL; struct ifaddr *ifa; struct ifnet *ifp = new->ndpr_ifp; @@ -1343,6 +1354,7 @@ find_pfxlist_reachable_router(struct nd_prefix *pr) void pfxlist_onlink_check() { + INIT_VNET_INET6(curvnet); struct nd_prefix *pr; struct in6_ifaddr *ifa; struct nd_defrouter *dr; @@ -1522,6 +1534,7 @@ pfxlist_onlink_check() int nd6_prefix_onlink(struct nd_prefix *pr) { + INIT_VNET_INET6(curvnet); struct ifaddr *ifa; struct ifnet *ifp = pr->ndpr_ifp; struct sockaddr_in6 mask6; @@ -1635,6 +1648,7 @@ nd6_prefix_onlink(struct nd_prefix *pr) int nd6_prefix_offlink(struct nd_prefix *pr) { + INIT_VNET_INET6(curvnet); int error = 0; struct ifnet *ifp = pr->ndpr_ifp; struct nd_prefix *opr; @@ -1726,6 +1740,7 @@ nd6_prefix_offlink(struct nd_prefix *pr) static struct in6_ifaddr * in6_ifadd(struct nd_prefixctl *pr, int mcast) { + INIT_VNET_INET6(curvnet); struct ifnet *ifp = pr->ndpr_ifp; struct ifaddr *ifa; struct in6_aliasreq ifra; @@ -1854,6 +1869,7 @@ in6_ifadd(struct nd_prefixctl *pr, int mcast) int in6_tmpifadd(const struct in6_ifaddr *ia0, int forcegen, int delay) { + INIT_VNET_INET6(curvnet); struct ifnet *ifp = ia0->ia_ifa.ifa_ifp; struct in6_ifaddr *newia, *ia; struct in6_aliasreq ifra; @@ -2021,7 +2037,7 @@ in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6) void rt6_flush(struct in6_addr *gateway, struct ifnet *ifp) { - + INIT_VNET_NET(curvnet); struct radix_node_head *rnh = V_rt_tables[0][AF_INET6]; int s = splnet(); @@ -2074,6 +2090,8 @@ rt6_deleteroute(struct radix_node *rn, void *arg) int nd6_setdefaultiface(int ifindex) { + INIT_VNET_NET(curvnet); + INIT_VNET_INET6(curvnet); int error = 0; if (ifindex < 0 || V_if_index < ifindex) diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index cbdca81..4fafdb1 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -136,6 +136,11 @@ int (*mrt6_ioctl)(int, caddr_t); int rip6_input(struct mbuf **mp, int *offp, int proto) { + INIT_VNET_INET(curvnet); + INIT_VNET_INET6(curvnet); +#ifdef IPSEC + INIT_VNET_IPSEC(curvnet); +#endif struct mbuf *m = *mp; register struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); register struct inpcb *in6p; @@ -258,6 +263,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto) void rip6_ctlinput(int cmd, struct sockaddr *sa, void *d) { + INIT_VNET_INET(curvnet); struct ip6_hdr *ip6; struct mbuf *m; int off = 0; @@ -313,6 +319,7 @@ rip6_output(m, va_alist) va_dcl #endif { + INIT_VNET_INET6(curvnet); struct mbuf *control; struct socket *so; struct sockaddr_in6 *dstsock; @@ -544,6 +551,7 @@ rip6_ctloutput(struct socket *so, struct sockopt *sopt) static int rip6_attach(struct socket *so, int proto, struct thread *td) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; struct icmp6_filter *filter; int error; @@ -583,6 +591,7 @@ rip6_attach(struct socket *so, int proto, struct thread *td) static void rip6_detach(struct socket *so) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; inp = sotoinpcb(so); @@ -640,6 +649,9 @@ rip6_disconnect(struct socket *so) static int rip6_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { + INIT_VNET_NET(so->so_vnet); + INIT_VNET_INET(so->so_vnet); + INIT_VNET_INET6(so->so_vnet); struct inpcb *inp; struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam; struct ifaddr *ia = NULL; @@ -675,6 +687,9 @@ rip6_bind(struct socket *so, struct sockaddr *nam, struct thread *td) static int rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { + INIT_VNET_NET(so->so_vnet); + INIT_VNET_INET(so->so_vnet); + INIT_VNET_INET6(so->so_vnet); struct inpcb *inp; struct sockaddr_in6 *addr = (struct sockaddr_in6 *)nam; struct in6_addr *in6a = NULL; @@ -749,6 +764,7 @@ static int rip6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, struct mbuf *control, struct thread *td) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; struct sockaddr_in6 tmp; struct sockaddr_in6 *dst; diff --git a/sys/netinet6/route6.c b/sys/netinet6/route6.c index c058f3b..dd1ec68 100644 --- a/sys/netinet6/route6.c +++ b/sys/netinet6/route6.c @@ -65,6 +65,7 @@ static int ip6_rthdr0 __P((struct mbuf *, struct ip6_hdr *, int route6_input(struct mbuf **mp, int *offp, int proto) { + INIT_VNET_INET6(curvnet); struct ip6_hdr *ip6; struct mbuf *m = *mp; struct ip6_rthdr *rh; @@ -150,6 +151,7 @@ route6_input(struct mbuf **mp, int *offp, int proto) static int ip6_rthdr0(struct mbuf *m, struct ip6_hdr *ip6, struct ip6_rthdr0 *rh0) { + INIT_VNET_INET6(curvnet); int addrs, index; struct in6_addr *nextaddr, tmpaddr; struct in6_ifaddr *ifa; diff --git a/sys/netinet6/scope6.c b/sys/netinet6/scope6.c index 5dce8ce..4c6b860 100644 --- a/sys/netinet6/scope6.c +++ b/sys/netinet6/scope6.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include <net/if.h> #include <netinet/in.h> +#include <netinet/ip6.h> #include <netinet6/in6_var.h> #include <netinet6/scope6_var.h> @@ -72,6 +73,7 @@ static struct scope6_id sid_default; void scope6_init(void) { + INIT_VNET_INET6(curvnet); SCOPE6_LOCK_INIT(); bzero(&V_sid_default, sizeof(V_sid_default)); @@ -110,6 +112,7 @@ scope6_ifdetach(struct scope6_id *sid) int scope6_set(struct ifnet *ifp, struct scope6_id *idlist) { + INIT_VNET_NET(ifp->if_vnet); int i; int error = 0; struct scope6_id *sid = NULL; @@ -264,6 +267,8 @@ in6_addrscope(struct in6_addr *addr) void scope6_setdefault(struct ifnet *ifp) { + INIT_VNET_INET6(ifp->if_vnet); + /* * Currently, this function just sets the default "interfaces" * and "links" according to the given interface. @@ -286,6 +291,7 @@ scope6_setdefault(struct ifnet *ifp) int scope6_get_default(struct scope6_id *idlist) { + INIT_VNET_INET6(curvnet); SCOPE6_LOCK(); *idlist = V_sid_default; @@ -297,6 +303,7 @@ scope6_get_default(struct scope6_id *idlist) u_int32_t scope6_addr2default(struct in6_addr *addr) { + INIT_VNET_INET6(curvnet); u_int32_t id; /* @@ -327,6 +334,7 @@ scope6_addr2default(struct in6_addr *addr) int sa6_embedscope(struct sockaddr_in6 *sin6, int defaultok) { + INIT_VNET_NET(curvnet); struct ifnet *ifp; u_int32_t zoneid; @@ -363,6 +371,7 @@ sa6_embedscope(struct sockaddr_in6 *sin6, int defaultok) int sa6_recoverscope(struct sockaddr_in6 *sin6) { + INIT_VNET_NET(curvnet); char ip6buf[INET6_ADDRSTRLEN]; u_int32_t zoneid; diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 7d50c1b..5056ef1 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -127,6 +127,7 @@ static void udp6_append(struct inpcb *inp, struct mbuf *n, int off, struct sockaddr_in6 *fromsa) { + INIT_VNET_INET(inp->inp_vnet); struct socket *so; struct mbuf *opts; @@ -135,6 +136,7 @@ udp6_append(struct inpcb *inp, struct mbuf *n, int off, #ifdef IPSEC /* Check AH/ESP integrity. */ if (ipsec6_in_reject(n, inp)) { + INIT_VNET_IPSEC(inp->inp_vnet); m_freem(n); V_ipsec6stat.in_polvio++; return; @@ -168,6 +170,8 @@ udp6_append(struct inpcb *inp, struct mbuf *n, int off, int udp6_input(struct mbuf **mp, int *offp, int proto) { + INIT_VNET_INET(curvnet); + INIT_VNET_INET6(curvnet); struct mbuf *m = *mp; struct ip6_hdr *ip6; struct udphdr *uh; @@ -361,6 +365,7 @@ badunlocked: void udp6_ctlinput(int cmd, struct sockaddr *sa, void *d) { + INIT_VNET_INET(curvnet); struct udphdr uh; struct ip6_hdr *ip6; struct mbuf *m; @@ -426,6 +431,8 @@ udp6_ctlinput(int cmd, struct sockaddr *sa, void *d) static int udp6_getcred(SYSCTL_HANDLER_ARGS) { + INIT_VNET_INET(curvnet); + INIT_VNET_INET6(curvnet); struct xucred xuc; struct sockaddr_in6 addrs[2]; struct inpcb *inp; @@ -477,6 +484,8 @@ static int udp6_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr6, struct mbuf *control, struct thread *td) { + INIT_VNET_INET(curvnet); + INIT_VNET_INET6(curvnet); u_int32_t ulen = m->m_pkthdr.len; u_int32_t plen = sizeof(struct udphdr) + ulen; struct ip6_hdr *ip6; @@ -692,6 +701,7 @@ releaseopt: static void udp6_abort(struct socket *so) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; inp = sotoinpcb(so); @@ -721,6 +731,7 @@ udp6_abort(struct socket *so) static int udp6_attach(struct socket *so, int proto, struct thread *td) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; int error; @@ -759,6 +770,7 @@ udp6_attach(struct socket *so, int proto, struct thread *td) static int udp6_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; int error; @@ -798,6 +810,7 @@ out: static void udp6_close(struct socket *so) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; inp = sotoinpcb(so); @@ -826,6 +839,7 @@ udp6_close(struct socket *so) static int udp6_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; int error; @@ -878,6 +892,7 @@ out: static void udp6_detach(struct socket *so) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; inp = sotoinpcb(so); @@ -893,6 +908,7 @@ udp6_detach(struct socket *so) static int udp6_disconnect(struct socket *so) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; int error; @@ -931,6 +947,7 @@ static int udp6_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td) { + INIT_VNET_INET(so->so_vnet); struct inpcb *inp; int error = 0; diff --git a/sys/netinet6/vinet6.h b/sys/netinet6/vinet6.h new file mode 100644 index 0000000..992e6e7 --- /dev/null +++ b/sys/netinet6/vinet6.h @@ -0,0 +1,259 @@ +/*- + * Copyright (c) 2006-2008 University of Zagreb + * Copyright (c) 2006-2008 FreeBSD Foundation + * + * This software was developed by the University of Zagreb and the + * FreeBSD Foundation under sponsorship by the Stichting NLnet and the + * FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _NETINET6_VINET6_H_ +#define _NETINET6_VINET6_H_ + +#ifdef VIMAGE +#include <sys/socket.h> +#include <netinet/ip6.h> +#include <net/if.h> +#include <netinet6/ip6_var.h> +#include <netinet6/raw_ip6.h> +#include <netinet/icmp6.h> +#include <netinet6/scope6_var.h> +#include <netinet6/in6_ifattach.h> +#include <netinet6/in6_var.h> +#include <netinet6/nd6.h> +#include <netinet/in_pcb.h> + +struct vnet_inet6 { + struct in6_ifaddr * _in6_ifaddr; + + u_int _frag6_nfragpackets; + u_int _frag6_nfrags; + struct ip6q _ip6q; + + struct route_in6 _ip6_forward_rt; + + struct in6_addrpolicy _defaultaddrpolicy; + TAILQ_HEAD(, addrsel_policyent) _addrsel_policytab; + u_int _in6_maxmtu; + int _ip6_auto_linklocal; + int _rtq_minreallyold6; + int _rtq_reallyold6; + int _rtq_toomany6; + + struct ip6stat _ip6stat; + struct rip6stat _rip6stat; + struct icmp6stat _icmp6stat; + + int _rtq_timeout6; + struct callout _rtq_timer6; + struct callout _rtq_mtutimer; + struct callout _nd6_slowtimo_ch; + struct callout _nd6_timer_ch; + struct callout _in6_tmpaddrtimer_ch; + + int _nd6_inuse; + int _nd6_allocated; + struct llinfo_nd6 _llinfo_nd6; + struct nd_drhead _nd_defrouter; + struct nd_prhead _nd_prefix; + struct ifnet * _nd6_defifp; + int _nd6_defifindex; + + struct scope6_id _sid_default; + + TAILQ_HEAD(, dadq) _dadq; + int _dad_init; + + int _icmp6errpps_count; + int _icmp6errppslim_last; + + int _ip6_forwarding; + int _ip6_sendredirects; + int _ip6_defhlim; + int _ip6_defmcasthlim; + int _ip6_accept_rtadv; + int _ip6_maxfragpackets; + int _ip6_maxfrags; + int _ip6_log_interval; + int _ip6_hdrnestlimit; + int _ip6_dad_count; + int _ip6_auto_flowlabel; + int _ip6_use_deprecated; + int _ip6_rr_prune; + int _ip6_mcast_pmtu; + int _ip6_v6only; + int _ip6_keepfaith; + int _ip6stealth; + time_t _ip6_log_time; + + int _pmtu_expire; + int _pmtu_probe; + u_long _rip6_sendspace; + u_long _rip6_recvspace; + int _icmp6_rediraccept; + int _icmp6_redirtimeout; + int _icmp6errppslim; + int _icmp6_nodeinfo; + int _udp6_sendspace; + int _udp6_recvspace; + int _ip6qmaxlen; + int _ip6_prefer_tempaddr; + int _ip6_forward_srcrt; + int _ip6_sourcecheck; + int _ip6_sourcecheck_interval; + int _ip6_ours_check_algorithm; + + int _nd6_prune; + int _nd6_delay; + int _nd6_umaxtries; + int _nd6_mmaxtries; + int _nd6_useloopback; + int _nd6_gctimer; + int _nd6_maxndopt; + int _nd6_maxnudhint; + int _nd6_maxqueuelen; + int _nd6_debug; + int _nd6_recalc_reachtm_interval; + int _dad_ignore_ns; + int _dad_maxtry; + int _ip6_use_tempaddr; + int _ip6_desync_factor; + u_int32_t _ip6_temp_preferred_lifetime; + u_int32_t _ip6_temp_valid_lifetime; + + int _ip6_mrouter_ver; + int _pim6; + u_int _mrt6debug; + + int _ip6_temp_regen_advance; + int _ip6_use_defzone; + + struct ip6_pktopts _ip6_opts; +}; +#endif + + +#define INIT_VNET_INET6(vnet) \ + INIT_FROM_VNET(vnet, VNET_MOD_INET6, struct vnet_inet6, vnet_inet6) + +#define VNET_INET6(sym) VSYM(vnet_inet6, sym) + + +/* + * Symbol translation macros + */ +#define V_addrsel_policytab VNET_INET6(addrsel_policytab) +#define V_dad_ignore_ns VNET_INET6(dad_ignore_ns) +#define V_dad_init VNET_INET6(dad_init) +#define V_dad_maxtry VNET_INET6(dad_maxtry) +#define V_dadq VNET_INET6(dadq) +#define V_defaultaddrpolicy VNET_INET6(defaultaddrpolicy) +#define V_frag6_nfragpackets VNET_INET6(frag6_nfragpackets) +#define V_frag6_nfrags VNET_INET6(frag6_nfrags) +#define V_icmp6_nodeinfo VNET_INET6(icmp6_nodeinfo) +#define V_icmp6_rediraccept VNET_INET6(icmp6_rediraccept) +#define V_icmp6_redirtimeout VNET_INET6(icmp6_redirtimeout) +#define V_icmp6errpps_count VNET_INET6(icmp6errpps_count) +#define V_icmp6errppslim VNET_INET6(icmp6errppslim) +#define V_icmp6errppslim_last VNET_INET6(icmp6errppslim_last) +#define V_icmp6stat VNET_INET6(icmp6stat) +#define V_in6_ifaddr VNET_INET6(in6_ifaddr) +#define V_in6_maxmtu VNET_INET6(in6_maxmtu) +#define V_in6_tmpaddrtimer_ch VNET_INET6(in6_tmpaddrtimer_ch) +#define V_ip6_accept_rtadv VNET_INET6(ip6_accept_rtadv) +#define V_ip6_auto_flowlabel VNET_INET6(ip6_auto_flowlabel) +#define V_ip6_auto_linklocal VNET_INET6(ip6_auto_linklocal) +#define V_ip6_dad_count VNET_INET6(ip6_dad_count) +#define V_ip6_defhlim VNET_INET6(ip6_defhlim) +#define V_ip6_defmcasthlim VNET_INET6(ip6_defmcasthlim) +#define V_ip6_desync_factor VNET_INET6(ip6_desync_factor) +#define V_ip6_forward_rt VNET_INET6(ip6_forward_rt) +#define V_ip6_forward_srcrt VNET_INET6(ip6_forward_srcrt) +#define V_ip6_forwarding VNET_INET6(ip6_forwarding) +#define V_ip6_hdrnestlimit VNET_INET6(ip6_hdrnestlimit) +#define V_ip6_keepfaith VNET_INET6(ip6_keepfaith) +#define V_ip6_log_interval VNET_INET6(ip6_log_interval) +#define V_ip6_log_time VNET_INET6(ip6_log_time) +#define V_ip6_maxfragpackets VNET_INET6(ip6_maxfragpackets) +#define V_ip6_maxfrags VNET_INET6(ip6_maxfrags) +#define V_ip6_mcast_pmtu VNET_INET6(ip6_mcast_pmtu) +#define V_ip6_mrouter_ver VNET_INET6(ip6_mrouter_ver) +#define V_ip6_opts VNET_INET6(ip6_opts) +#define V_ip6_ours_check_algorithm VNET_INET6(ip6_ours_check_algorithm) +#define V_ip6_prefer_tempaddr VNET_INET6(ip6_prefer_tempaddr) +#define V_ip6_rr_prune VNET_INET6(ip6_rr_prune) +#define V_ip6_sendredirects VNET_INET6(ip6_sendredirects) +#define V_ip6_sourcecheck VNET_INET6(ip6_sourcecheck) +#define V_ip6_sourcecheck_interval VNET_INET6(ip6_sourcecheck_interval) +#define V_ip6_temp_preferred_lifetime VNET_INET6(ip6_temp_preferred_lifetime) +#define V_ip6_temp_regen_advance VNET_INET6(ip6_temp_regen_advance) +#define V_ip6_temp_valid_lifetime VNET_INET6(ip6_temp_valid_lifetime) +#define V_ip6_use_defzone VNET_INET6(ip6_use_defzone) +#define V_ip6_use_deprecated VNET_INET6(ip6_use_deprecated) +#define V_ip6_use_tempaddr VNET_INET6(ip6_use_tempaddr) +#define V_ip6_v6only VNET_INET6(ip6_v6only) +#define V_ip6q VNET_INET6(ip6q) +#define V_ip6qmaxlen VNET_INET6(ip6qmaxlen) +#define V_ip6stat VNET_INET6(ip6stat) +#define V_ip6stealth VNET_INET6(ip6stealth) +#define V_llinfo_nd6 VNET_INET6(llinfo_nd6) +#define V_mrt6debug VNET_INET6(mrt6debug) +#define V_nd6_allocated VNET_INET6(nd6_allocated) +#define V_nd6_debug VNET_INET6(nd6_debug) +#define V_nd6_defifindex VNET_INET6(nd6_defifindex) +#define V_nd6_defifp VNET_INET6(nd6_defifp) +#define V_nd6_delay VNET_INET6(nd6_delay) +#define V_nd6_gctimer VNET_INET6(nd6_gctimer) +#define V_nd6_inuse VNET_INET6(nd6_inuse) +#define V_nd6_maxndopt VNET_INET6(nd6_maxndopt) +#define V_nd6_maxnudhint VNET_INET6(nd6_maxnudhint) +#define V_nd6_maxqueuelen VNET_INET6(nd6_maxqueuelen) +#define V_nd6_mmaxtries VNET_INET6(nd6_mmaxtries) +#define V_nd6_prune VNET_INET6(nd6_prune) +#define V_nd6_recalc_reachtm_interval VNET_INET6(nd6_recalc_reachtm_interval) +#define V_nd6_slowtimo_ch VNET_INET6(nd6_slowtimo_ch) +#define V_nd6_timer_ch VNET_INET6(nd6_timer_ch) +#define V_nd6_umaxtries VNET_INET6(nd6_umaxtries) +#define V_nd6_useloopback VNET_INET6(nd6_useloopback) +#define V_nd_defrouter VNET_INET6(nd_defrouter) +#define V_nd_prefix VNET_INET6(nd_prefix) +#define V_pim6 VNET_INET6(pim6) +#define V_pmtu_expire VNET_INET6(pmtu_expire) +#define V_pmtu_probe VNET_INET6(pmtu_probe) +#define V_rip6_recvspace VNET_INET6(rip6_recvspace) +#define V_rip6_sendspace VNET_INET6(rip6_sendspace) +#define V_rip6stat VNET_INET6(rip6stat) +#define V_rtq_minreallyold6 VNET_INET6(rtq_minreallyold6) +#define V_rtq_mtutimer VNET_INET6(rtq_mtutimer) +#define V_rtq_reallyold6 VNET_INET6(rtq_reallyold6) +#define V_rtq_timeout6 VNET_INET6(rtq_timeout6) +#define V_rtq_timer6 VNET_INET6(rtq_timer6) +#define V_rtq_toomany6 VNET_INET6(rtq_toomany6) +#define V_sid_default VNET_INET6(sid_default) +#define V_udp6_recvspace VNET_INET6(udp6_recvspace) +#define V_udp6_sendspace VNET_INET6(udp6_sendspace) + +#endif /* !_NETINET6_VINET6_H_ */ |