summaryrefslogtreecommitdiffstats
path: root/sys/netinet/igmp.c
diff options
context:
space:
mode:
authorzec <zec@FreeBSD.org>2009-05-05 10:56:12 +0000
committerzec <zec@FreeBSD.org>2009-05-05 10:56:12 +0000
commitd78a1b1a824c4f5eb8cb3583bb5265f73dcc24dd (patch)
tree79a0bccccf2c92504cdf23ad15f7c1813bb3f926 /sys/netinet/igmp.c
parent8e4ffe653f6c9ff6da3eed58566ef35e77d530d0 (diff)
downloadFreeBSD-src-d78a1b1a824c4f5eb8cb3583bb5265f73dcc24dd.zip
FreeBSD-src-d78a1b1a824c4f5eb8cb3583bb5265f73dcc24dd.tar.gz
Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a dynamically changing thread-local one. The currvnet context should be set on entry to networking code via CURVNET_SET() macros, and reverted to previous state via CURVNET_RESTORE(). Recursions on curvnet are permitted, though strongly discuouraged. This change should have no functional impact on nooptions VIMAGE kernel builds, where CURVNET_* macros expand to whitespace. The curthread->td_vnet (aka curvnet) variable's purpose is to be an indicator of the vnet context in which the current network-related operation takes place, in case we cannot deduce the current vnet context from any other source, such as by looking at mbuf's m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so far curvnet has turned out to be an invaluable consistency checking aid: it helps to catch cases when sockets, ifnets or any other vnet-aware structures may have leaked from one vnet to another. The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros was a result of an empirical iterative process, whith an aim to reduce recursions on CURVNET_SET() to a minimum, while still reducing the scope of CURVNET_SET() to networking only operations - the alternative would be calling CURVNET_SET() on each system call entry. In general, curvnet has to be set in three typicall cases: when processing socket-related requests from userspace or from within the kernel; when processing inbound traffic flowing from device drivers to upper layers of the networking stack, and when executing timer-driven networking functions. This change also introduces a DDB subcommand to show the list of all vnet instances. Approved by: julian (mentor)
Diffstat (limited to 'sys/netinet/igmp.c')
-rw-r--r--sys/netinet/igmp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 2bbd10d..3fb3711 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -1117,6 +1117,9 @@ igmp_input_v3_group_query(struct in_multi *inm, struct igmp_ifinfo *igi,
nsrc = ntohs(igmpv3->igmp_numsrc);
+ if (!IS_DEFAULT_VNET(curvnet))
+ return (retval);
+
/*
* Deal with group-specific queries upfront.
* If any group query is already pending, purge any recorded
@@ -3372,7 +3375,7 @@ igmp_intr(struct mbuf *m)
* indexes to guard against interface detach, they are
* unique to each VIMAGE and must be retrieved.
*/
- CURVNET_SET(m->m_pkthdr.header);
+ CURVNET_SET((struct vnet *)(m->m_pkthdr.header));
INIT_VNET_NET(curvnet);
INIT_VNET_INET(curvnet);
ifindex = igmp_restore_context(m);
@@ -3654,9 +3657,7 @@ igmp_modevent(module_t mod, int type, void *unused __unused)
break;
case MOD_UNLOAD:
#ifndef VIMAGE_GLOBALS
-#ifdef NOTYET
vnet_mod_deregister(&vnet_igmp_modinfo);
-#endif
#else
vnet_igmp_idetach(NULL);
#endif
OpenPOWER on IntegriCloud