PERFORCE change 128288 for review
Marko Zec
zec at FreeBSD.org
Mon Oct 29 08:54:35 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=128288
Change 128288 by zec at zec_tpx32 on 2007/10/29 15:54:27
Set / reset vnet context when entering networking code
from cdevsw-hooked open/close etc. handles in tun(4).
Reported by: Nikos Vassiliadis <nvass at teledomenet.gr>
Affected files ...
.. //depot/projects/vimage/src/sys/net/if_tun.c#3 edit
Differences ...
==== //depot/projects/vimage/src/sys/net/if_tun.c#3 (text+ko) ====
@@ -21,6 +21,7 @@
#include "opt_inet6.h"
#include "opt_ipx.h"
#include "opt_mac.h"
+#include "opt_vimage.h"
#include <sys/param.h>
#include <sys/priv.h>
@@ -43,6 +44,7 @@
#include <sys/uio.h>
#include <sys/malloc.h>
#include <sys/random.h>
+#include <sys/vimage.h>
#include <net/if.h>
#include <net/if_clone.h>
@@ -224,6 +226,7 @@
else
append_unit = 0;
+ CURVNET_SET(TD_TO_VNET(curthread));
/* find any existing device, or allocate new unit number */
i = clone_create(&tunclones, &tun_cdevsw, &u, dev, 0);
if (i) {
@@ -242,6 +245,7 @@
}
if_clone_create(name, namelen, NULL);
+ CURVNET_RESTORE();
}
static void
@@ -253,6 +257,7 @@
KASSERT((tp->tun_flags & TUN_OPEN) == 0,
("tununits is out of sync - unit %d", TUN2IFP(tp)->if_dunit));
+ CURVNET_SET(TUN2IFP(tp)->if_vnet);
dev = tp->tun_dev;
bpfdetach(TUN2IFP(tp));
if_detach(TUN2IFP(tp));
@@ -261,6 +266,7 @@
knlist_destroy(&tp->tun_rsel.si_note);
mtx_destroy(&tp->tun_mtx);
free(tp, M_TUN);
+ CURVNET_RESTORE();
}
static void
@@ -447,6 +453,7 @@
/*
* junk all pending output
*/
+ CURVNET_SET(ifp->if_vnet);
s = splimp();
IFQ_PURGE(&ifp->if_snd);
splx(s);
@@ -476,6 +483,7 @@
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
splx(s);
}
+ CURVNET_RESTORE();
funsetown(&tp->tun_sigio);
selwakeuppri(&tp->tun_rsel, PZERO + 1);
@@ -924,7 +932,9 @@
random_harvest(m, 16, 3, 0, RANDOM_NET);
ifp->if_ibytes += m->m_pkthdr.len;
ifp->if_ipackets++;
+ CURVNET_SET(ifp->if_vnet);
netisr_dispatch(isr, m);
+ CURVNET_RESTORE();
return (0);
}
More information about the p4-projects
mailing list