Index: head/emulators/virtualbox/Makefile =================================================================== --- head/emulators/virtualbox/Makefile (revision 245450) +++ head/emulators/virtualbox/Makefile (revision 245451) @@ -1,259 +1,259 @@ # New ports collection makefile for: virtualbox # Date created: 2009-05-02 # Whom: Bernhard Froehlich # # $FreeBSD$ # PORTNAME= virtualbox DISTVERSION= 3.0.51r22902 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= emulators kld MASTER_SITES= http://tmp.chruetertee.ch/ \ http://freebsd.unixfreunde.de/sources/ \ http://disasterarea.chruetertee.ch/ \ http://mirror.4bit.ws/ \ http://dlc.sun.com/virtualbox/${VBOX_GUEST_VER}/:guestadditions DISTFILES= ${DISTNAME}${EXTRACT_SUFX} ${GADISTFILES} EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} #for discussion please use emulation@FreeBSD.org MAINTAINER= vbox@FreeBSD.org COMMENT= A general-purpose full virtualizer for x86 hardware BUILD_DEPENDS= yasm:${PORTSDIR}/devel/yasm \ as86:${PORTSDIR}/devel/dev86 \ xsltproc:${PORTSDIR}/textproc/libxslt \ kmk:${PORTSDIR}/devel/kBuild LIB_DEPENDS= png.5:${PORTSDIR}/graphics/png \ xslt.2:${PORTSDIR}/textproc/libxslt \ curl.5:${PORTSDIR}/ftp/curl ONLY_FOR_ARCHS= i386 amd64 USE_GNOME= libidl USE_CDRTOOLS= yes USE_BZIP2= yes USE_PYTHON= yes USE_PYDISTUTILS= easy_install PYDISTUTILS_PKGNAME= vboxapi PYDISTUTILS_PKGVERSION= 1.0 PYDISTUTILS_NOEGGINFO= yes HAS_CONFIGURE= yes CONFIGURE_ARGS+=--with-gcc="${CC}" --with-g++="${CXX}" USE_LDCONFIG= ${PREFIX}/lib/virtualbox CONFLICTS= bcc-[0-9]* VBOXGROUP?= vboxusers VBOXGID?= 920 VBOX_FRONTENDS= VBoxHeadless VBOX_GUEST_VER= 3.0.6 SUB_FILES= pkg-install SUB_LIST= PREFIX=${PREFIX} \ VBOXGROUP=${VBOXGROUP} \ VBOXGID=${VBOXGID} OPTIONS= QT4 "Build with QT4 Frontend" on \ DEBUG "Build with debugging symbols" off \ GUESTADDITIONS "Build with Guest Additions" off \ DBUS "Build with D-Bus and HAL support" on \ PULSEAUDIO "Build with PulseAudio" off \ X11 "Build with X11 support" on \ NLS "Native language support" on .include PLIST_SUB+= KMODDIR=${KMODDIR:C,^/,,} \ PYTHON_VER=${PYTHON_VER} \ PYTHON_VERU=${PYTHON_VER:S/./_/} \ GUEST_VER=${VBOX_GUEST_VER} KMODDIR= /boot/modules KMK_BUILDTYPE= release KMK_CONFIG= VBOX_LIBPATH_X11=${LOCALBASE} VBOX_FREEBSD_SRC=${SRC_BASE}/sys KMK_FLAGS= .if defined(WITHOUT_QT4) && !defined(WITHOUT_NLS) BROKEN= NLS support requires QT4 frontend. Run 'make config' again! .endif .if defined(WITHOUT_X11) && !defined(WITHOUT_QT4) BROKEN= QT4 frontend requires X11 support. Run 'make config' again! .endif .if !defined(WITHOUT_X11) USE_SDL= sdl USE_XORG= xcursor xmu VBOX_FRONTENDS+=VBoxBFE VBoxSDL VBoxTestOGL PLIST_SUB+= X11="" .else CONFIGURE_ARGS+=--build-headless PLIST_SUB+= X11="@comment " .endif .if !defined(WITHOUT_QT4) USE_QT_VER= 4 QT_NONSTANDARD= yes QT_COMPONENTS= gui network moc_build uic_build rcc_build linguist INSTALLS_ICONS= yes VBOX_FRONTENDS+=VirtualBox PLIST_SUB+= QT4="" .else CONFIGURE_ARGS+=--disable-qt4 PLIST_SUB+= QT4="@comment " .endif .if defined(WITH_GUESTADDITIONS) GUESTADDITIONS= VBoxGuestAdditions_${VBOX_GUEST_VER}.iso GADISTFILES= ${GUESTADDITIONS}:guestadditions RESTRICTED= for personal use only RESTRICTED_FILES= ${GUESTADDITIONS} FETCH_ARGS= -pRr PLIST_SUB+= GUESTADDITIONS="" .else PLIST_SUB+= GUESTADDITIONS="@comment " .endif .if defined(WITH_DEBUG) KMK_FLAGS+= BUILD_TYPE=debug KMK_BUILDTYPE= debug .endif .if !defined(WITHOUT_DBUS) LIB_DEPENDS+= dbus-1.3:${PORTSDIR}/devel/dbus .else CONFIGURE_ARGS+=--disable-dbus .endif .if !defined(WITH_PULSEAUDIO) CONFIGURE_ARGS+=--disable-pulse .endif .if !defined(WITHOUT_NLS) PLIST_SUB+= NLS="" .else PLIST_SUB+= NLS="@comment " .endif .if !exists(${SRC_BASE}/sys/kern/bus_if.m) IGNORE= requires kernel sources for the kernel module .endif .if ${OSVERSION} < 700000 BROKEN= Does not compile on FreeBSD 6.X .endif .if ${ARCH} == i386 KMK_ARCH= freebsd.x86 PLIST_SUB+= I386="" .else KMK_ARCH= freebsd.${ARCH} PLIST_SUB+= I386="@comment " .endif .include pre-everything:: .if ${ARCH} == "amd64" .if !exists(/usr/lib32) @${ECHO} 'Requires 32-bit libraries installed under /usr/lib32.' @${ECHO} 'Do: cd /usr/src; make build32 install32; ldconfig -v -m -R /usr/lib32' @${FALSE} .endif .endif post-patch: @${ECHO} 'VBOX_PATH_APP_PRIVATE_ARCH = ${PREFIX}/lib/virtualbox' > ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_SHARED_LIBS = ${PREFIX}/lib/virtualbox' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_RUNPATH = ${PREFIX}/lib/virtualbox' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_APP_PRIVATE = ${DATADIR}' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_APP_DOCS = ${DOCSDIR}' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_INSTALLER = 1' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_TESTCASES=' >> ${WRKSRC}/LocalConfig.kmk .if defined(WITHOUT_X11) @${ECHO} 'VBOX_WITH_X11_ADDITIONS=' >> ${WRKSRC}/LocalConfig.kmk .endif @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \ ${WRKSRC}/Config.kmk ${WRKSRC}/configure \ ${WRKSRC}/kBuild/units/qt3.kmk ${WRKSRC}/kBuild/units/qt4.kmk \ ${WRKSRC}/kBuild/sdks/LIBSDL.kmk \ ${WRKSRC}/src/libs/xpcom18a4/python/gen_python_deps.py @${REINPLACE_CMD} -e 's|\$$KBUILDDIR_BIN/kmk_sed|${PREFIX}/bin/kmk_sed|g' ${WRKSRC}/configure pre-build: @${REINPLACE_CMD} -e 's|/bin/bash|/bin/sh|' \ ${WRKSRC}/env.sh do-build: cd ${WRKSRC} && ${SH} env.sh && ${KMK_CONFIG} ${LOCALBASE}/bin/kmk ${KMK_FLAGS} do-install: ${MKDIR} ${KMODDIR} .for f in vboxdrv.ko vboxnetadp.ko vboxnetflt.ko ${INSTALL_KLD} ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/${f} ${KMODDIR} .endfor ${MKDIR} ${DATADIR} (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom && ${COPYTREE_SHARE} "idl samples" ${DATADIR}) ${MKDIR} ${PREFIX}/include/virtualbox (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom/include && ${COPYTREE_SHARE} "*" ${PREFIX}/include/virtualbox) ${MKDIR} ${PREFIX}/lib/virtualbox (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin && ${COPYTREE_SHARE} "*.so *.gc *.r0 components" ${PREFIX}/lib/virtualbox) .if !defined(WITHOUT_NLS) ${MKDIR} ${DATADIR}/nls (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/obj/VirtualBox/qtnls && ${COPYTREE_SHARE} "*.qm" ${DATADIR}/nls) .endif ${MKDIR} ${PREFIX}/bin .for f in VBoxManage VBoxNetAdpCtl VBoxNetDHCP VBoxSVC VBoxXPCOMIPCD ${VBOX_FRONTENDS} ${INSTALL_PROGRAM} ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/${f} ${PREFIX}/lib/virtualbox/ ${LN} -sf ${PREFIX}/lib/virtualbox/${f} ${PREFIX}/bin/ .endfor .for f in VBoxNetAdpCtl VBoxNetDHCP ${VBOX_FRONTENDS} ${CHMOD} 4511 ${PREFIX}/lib/virtualbox/${f} .endfor .for f in VBoxManage VBoxSVC VBoxXPCOMIPCD ${CHMOD} 0711 ${PREFIX}/lib/virtualbox/${f} .endfor .if defined(WITH_GUESTADDITIONS) ${MKDIR} ${PREFIX}/lib/virtualbox/additions ${INSTALL_DATA} ${DISTDIR}/${GUESTADDITIONS} ${PREFIX}/lib/virtualbox/additions/ ${LN} -sf ${PREFIX}/lib/virtualbox/additions/${GUESTADDITIONS} ${PREFIX}/lib/virtualbox/additions/VBoxGuestAdditions.iso .endif cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/installer && \ VBOX_INSTALL_PATH="${PREFIX}/lib/virtualbox" ${PYTHON_CMD} vboxapisetup.py install @${MKDIR} ${PYTHON_SITELIBDIR} (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom/python && ${COPYTREE_SHARE} "*" ${PYTHON_SITELIBDIR}) ${PYTHON_CMD} -mcompileall ${PYTHON_SITELIBDIR}/xpcom/ post-install: @${SETENV} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .for f in VBoxManage VBoxNetDHCP VBoxSVC VBoxXPCOMIPCD ${VBOX_FRONTENDS} ${CHOWN} root:${VBOXGROUP} ${PREFIX}/lib/virtualbox/${f} .endfor @${FIND} ${DATADIR} -type d -print0 | ${XARGS} -0 ${CHMOD} 755 @${FIND} ${PREFIX}/include/virtualbox -type d -print0 | ${XARGS} -0 ${CHMOD} 755 @${FIND} ${PREFIX}/lib/virtualbox -type d -print0 | ${XARGS} -0 ${CHMOD} 755 .if !defined(WITHOUT_QT4) ${MKDIR} ${PREFIX}/share/icons/hicolor/48x48/apps/ ${INSTALL_DATA} ${WRKSRC}/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_48px.png ${PREFIX}/share/icons/hicolor/48x48/apps/VBox.png ${MKDIR} ${PREFIX}/share/applications/ ${INSTALL_DATA} ${WRKSRC}/src/VBox/Installer/solaris/virtualbox.desktop ${PREFIX}/share/applications/virtualbox.desktop .endif @${CAT} ${PKGMESSAGE} .include Property changes on: head/emulators/virtualbox/Makefile ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.12 \ No newline at end of property +1.13 \ No newline at end of property Index: head/emulators/virtualbox/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c =================================================================== --- head/emulators/virtualbox/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (nonexistent) +++ head/emulators/virtualbox/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (revision 245451) @@ -0,0 +1,11 @@ +--- src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c.orig 2009-12-07 12:20:44.000000000 +0100 ++++ src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c 2009-12-07 12:21:00.000000000 +0100 +@@ -92,7 +92,7 @@ + DECLARE_MODULE(vboxnetadp, g_VBoxNetAdpFreeBSDModule, SI_SUB_PSEUDO, SI_ORDER_ANY); + MODULE_VERSION(vboxnetadp, 1); + MODULE_DEPEND(vboxnetadp, vboxdrv, 1, 1, 1); +-MODULE_DEPEND(vboxnetadp, ng_vboxnetflt, 1, 1, 1); ++MODULE_DEPEND(vboxnetadp, vboxnetflt, 1, 1, 1); + + /** + * Module event handler Property changes on: head/emulators/virtualbox/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/emulators/virtualbox/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c =================================================================== --- head/emulators/virtualbox/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c (revision 245450) +++ head/emulators/virtualbox/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c (revision 245451) @@ -1,375 +1,384 @@ Index: src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c =================================================================== --- src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c (revision 23391) +++ src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c (working copy) @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -78,8 +80,6 @@ static ng_rcvdata_t ng_vboxnetflt_rcvdata; static ng_disconnect_t ng_vboxnetflt_disconnect; static int ng_vboxnetflt_mod_event(module_t mod, int event, void *data); -static int ng_vboxnetflt_rcv_in(hook_p node, item_p item); -static int ng_vboxnetflt_rcv_out(hook_p node, item_p item); /** Netgraph node type */ #define NG_VBOXNETFLT_NODE_TYPE "vboxnetflt" @@ -112,8 +112,8 @@ { .version = NG_ABI_VERSION, .name = NG_VBOXNETFLT_NODE_TYPE, - .mod_event = vboxnetflt_modevent, - .constructor = ng_vboxnetflt_constructor, + .mod_event = vboxnetflt_modevent, + .constructor = ng_vboxnetflt_constructor, .rcvmsg = ng_vboxnetflt_rcvmsg, .shutdown = ng_vboxnetflt_shutdown, .newhook = ng_vboxnetflt_newhook, +@@ -122,7 +122,7 @@ + .cmdlist = ng_vboxnetflt_cmdlist, + }; + NETGRAPH_INIT(vboxnetflt, &ng_vboxnetflt_typestruct); +-MODULE_VERSION(ng_vboxnetflt, 1); ++MODULE_VERSION(vboxnetflt, 1); + MODULE_DEPEND(ng_vboxnetflt, vboxdrv, 1, 1, 1); + + /** @@ -267,16 +267,12 @@ if (strcmp(name, NG_VBOXNETFLT_HOOK_IN) == 0) { #if __FreeBSD_version >= 800000 - NG_HOOK_SET_RCVDATA(hook, ng_vboxnetflt_rcv_in); NG_HOOK_SET_TO_INBOUND(hook); #endif pThis->u.s.input = hook; } else if (strcmp(name, NG_VBOXNETFLT_HOOK_OUT) == 0) { -#if __FreeBSD_version >= 800000 - NG_HOOK_SET_RCVDATA(hook, ng_vboxnetflt_rcv_out); -#endif pThis->u.s.output = hook; } else @@ -310,161 +306,171 @@ /** * Handle data on netgraph hooks. + * Frames processing is deferred to a taskqueue because this might + * be called with non-sleepable locks held and code paths inside + * the virtual switch might sleep. */ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p item) { const node_p node = NG_HOOK_NODE(hook); PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); + struct ifnet *ifp = pThis->u.s.ifp; struct mbuf *m; + struct m_tag *mtag; + bool fActive; + fActive = ASMAtomicUoReadBool(&pThis->fActive); + + NGI_GET_M(item, m); + NG_FREE_ITEM(item); + + /* Locate tag to see if processing should be skipped for this frame */ + mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); + if (mtag != NULL) + { + m_tag_unlink(m, mtag); + m_tag_free(mtag); + } + + /* + * Handle incoming hook. This is connected to the + * input path of the interface, thus handling incoming frames. + */ if (pThis->u.s.input == hook) - return ng_vboxnetflt_rcv_in(hook, item); + { + if (mtag != NULL || !fActive) + { + ether_demux(ifp, m); + return (0); + } + mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); + _IF_ENQUEUE(&pThis->u.s.inq, m); + mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); + taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskin); + } + /** + * Handle mbufs on the outgoing hook, frames going to the interface + */ else if (pThis->u.s.output == hook) - return ng_vboxnetflt_rcv_out(hook, item); + { + if (mtag != NULL || !fActive) + return ether_output_frame(ifp, m); + mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); + _IF_ENQUEUE(&pThis->u.s.outq, m); + mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); + taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskout); + } else { - NGI_GET_M(item, m); - NG_FREE_ITEM(item); + m_freem(m); } return (0); } +static int ng_vboxnetflt_shutdown(node_p node) +{ + PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); + bool fActive; + + /* Prevent node shutdown if we're active */ + fActive = ASMAtomicUoReadBool(&pThis->fActive); + if (fActive) + return (EBUSY); + NG_NODE_UNREF(node); + return (0); +} + +static int ng_vboxnetflt_disconnect(hook_p hook) +{ + return (0); +} + /** - * Handle incoming hook. This is connected to the - * input path of the interface, thus handling incoming frames. + * Input processing task, handles incoming frames */ -static int ng_vboxnetflt_rcv_in(hook_p hook, item_p item) +static void vboxNetFltFreeBSDinput(void *arg, int pending) { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; struct mbuf *m, *m0; - struct m_tag *mtag; - const node_p node = NG_HOOK_NODE(hook); - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); struct ifnet *ifp = pThis->u.s.ifp; - bool fActive, fDropIt = false; unsigned int cSegs = 0; + bool fDropIt = false, fActive; PINTNETSG pSG; - NGI_GET_M(item, m); - NG_FREE_ITEM(item); - - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (!fActive) - goto out; - - mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); - if (mtag != NULL) - { - m_tag_unlink(m, mtag); - m_tag_free(mtag); - goto out; - } vboxNetFltRetain(pThis, true /* fBusy */); - - for (m0 = m; m0 != NULL; m0 = m0->m_next) + for (;;) { - if (m0->m_len > 0) - cSegs++; - } + mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); + _IF_DEQUEUE(&pThis->u.s.inq, m); + mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); + if (m == NULL) + break; + for (m0 = m; m0 != NULL; m0 = m0->m_next) + if (m0->m_len > 0) + cSegs++; + #ifdef PADD_RUNT_FRAMES_FROM_HOST - if (m_length(m, NULL) < 60) - cSegs++; + if (m_length(m, NULL) < 60) + cSegs++; #endif - /* Create a copy of the mbuf and hand it to the virtual switch */ - pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); - vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); - fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_WIRE); - RTMemTmpFree(pSG); + /* Create a copy and deliver to the virtual switch */ + pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); + vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); + fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); + RTMemTmpFree(pSG); + if (fDropIt) + m_freem(m); + else + ether_demux(ifp, m); + } vboxNetFltRelease(pThis, true /* fBusy */); - -out: - /* Only deliver it to the host stack if the destination weren't a guest */ - if (fDropIt) - { - m_freem(m); - return (0); - } - ether_demux(ifp, m); - return (0); } /** - * Handle mbufs on the outgoing hook, frames going to the interface + * Output processing task, handles outgoing frames */ -static int ng_vboxnetflt_rcv_out(hook_p hook, item_p item) +static void vboxNetFltFreeBSDoutput(void *arg, int pending) { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; struct mbuf *m, *m0; - struct m_tag *mtag; - const node_p node = NG_HOOK_NODE(hook); - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); struct ifnet *ifp = pThis->u.s.ifp; unsigned int cSegs = 0; bool fDropIt = false, fActive; PINTNETSG pSG; - NGI_GET_M(item, m); - NG_FREE_ITEM(item); - - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (!fActive) - return ether_output_frame(ifp, m); - vboxNetFltRetain(pThis, true /* fBusy */); - /* Pass directly to interface if the packet originated from us */ - mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); - if (mtag != NULL) + for (;;) { - m_tag_unlink(m, mtag); - m_tag_free(mtag); - goto out; - } + mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); + _IF_DEQUEUE(&pThis->u.s.outq, m); + mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); + if (m == NULL) + break; - for (m0 = m; m0 != NULL; m0 = m0->m_next) - { - if (m0->m_len > 0) - cSegs++; - } + for (m0 = m; m0 != NULL; m0 = m0->m_next) + if (m0->m_len > 0) + cSegs++; #ifdef PADD_RUNT_FRAMES_FROM_HOST - if (m_length(m, NULL) < 60) - cSegs++; + if (m_length(m, NULL) < 60) + cSegs++; #endif - /* Create a copy and deliver to the virtual switch */ - pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); - vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); - fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); - RTMemTmpFree(pSG); + /* Create a copy and deliver to the virtual switch */ + pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); + vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); + fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); + RTMemTmpFree(pSG); -out: + if (fDropIt) + m_freem(m); + else + ether_output_frame(ifp, m); + } vboxNetFltRelease(pThis, true /* fBusy */); - if (fDropIt) - { - m_freem(m); - return (0); - } - - return ether_output_frame(ifp, m); } -static int ng_vboxnetflt_shutdown(node_p node) -{ - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); - bool fActive; - - /* Prevent node shutdown if we're active */ - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (fActive) - return (EBUSY); - NG_NODE_UNREF(node); - return (0); -} - -static int ng_vboxnetflt_disconnect(hook_p hook) -{ - return (0); -} - /** * Called to deliver a frame to either the host, the wire or both. */ @@ -536,13 +542,23 @@ /* Create a new netgraph node for this instance */ if (ng_make_node_common(&ng_vboxnetflt_typestruct, &node) != 0) - return VERR_INTERNAL_ERROR; + return VERR_INTERNAL_ERROR; RTSpinlockAcquire(pThis->hSpinlock, &Tmp); ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.ifp, ifp); pThis->u.s.node = node; bcopy(IF_LLADDR(ifp), &pThis->u.s.Mac, ETHER_ADDR_LEN); ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false); + /* Initialize deferred input queue */ + bzero(&pThis->u.s.inq, sizeof(struct ifqueue)); + mtx_init(&pThis->u.s.inq.ifq_mtx, "vboxnetflt inq", NULL, MTX_SPIN); + TASK_INIT(&pThis->u.s.tskin, 0, vboxNetFltFreeBSDinput, pThis); + + /* Initialize deferred output queue */ + bzero(&pThis->u.s.outq, sizeof(struct ifqueue)); + mtx_init(&pThis->u.s.outq.ifq_mtx, "vboxnetflt outq", NULL, MTX_SPIN); + TASK_INIT(&pThis->u.s.tskout, 0, vboxNetFltFreeBSDoutput, pThis); + RTSpinlockRelease(pThis->hSpinlock, &Tmp); NG_NODE_SET_PRIVATE(node, pThis); @@ -571,7 +587,10 @@ } if (ifp0 != NULL) + { + vboxNetFltOsDeleteInstance(pThis); vboxNetFltOsInitInstance(pThis, NULL); + } return !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost); } @@ -579,6 +598,12 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) { + taskqueue_drain(taskqueue_fast, &pThis->u.s.tskin); + taskqueue_drain(taskqueue_fast, &pThis->u.s.tskout); + + mtx_destroy(&pThis->u.s.inq.ifq_mtx); + mtx_destroy(&pThis->u.s.outq.ifq_mtx); + if (pThis->u.s.node != NULL) ng_rmnode_self(pThis->u.s.node); pThis->u.s.node = NULL; Property changes on: head/emulators/virtualbox/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.1 \ No newline at end of property +1.2 \ No newline at end of property Index: head/emulators/virtualbox-ose/Makefile =================================================================== --- head/emulators/virtualbox-ose/Makefile (revision 245450) +++ head/emulators/virtualbox-ose/Makefile (revision 245451) @@ -1,259 +1,259 @@ # New ports collection makefile for: virtualbox # Date created: 2009-05-02 # Whom: Bernhard Froehlich # # $FreeBSD$ # PORTNAME= virtualbox DISTVERSION= 3.0.51r22902 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= emulators kld MASTER_SITES= http://tmp.chruetertee.ch/ \ http://freebsd.unixfreunde.de/sources/ \ http://disasterarea.chruetertee.ch/ \ http://mirror.4bit.ws/ \ http://dlc.sun.com/virtualbox/${VBOX_GUEST_VER}/:guestadditions DISTFILES= ${DISTNAME}${EXTRACT_SUFX} ${GADISTFILES} EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} #for discussion please use emulation@FreeBSD.org MAINTAINER= vbox@FreeBSD.org COMMENT= A general-purpose full virtualizer for x86 hardware BUILD_DEPENDS= yasm:${PORTSDIR}/devel/yasm \ as86:${PORTSDIR}/devel/dev86 \ xsltproc:${PORTSDIR}/textproc/libxslt \ kmk:${PORTSDIR}/devel/kBuild LIB_DEPENDS= png.5:${PORTSDIR}/graphics/png \ xslt.2:${PORTSDIR}/textproc/libxslt \ curl.5:${PORTSDIR}/ftp/curl ONLY_FOR_ARCHS= i386 amd64 USE_GNOME= libidl USE_CDRTOOLS= yes USE_BZIP2= yes USE_PYTHON= yes USE_PYDISTUTILS= easy_install PYDISTUTILS_PKGNAME= vboxapi PYDISTUTILS_PKGVERSION= 1.0 PYDISTUTILS_NOEGGINFO= yes HAS_CONFIGURE= yes CONFIGURE_ARGS+=--with-gcc="${CC}" --with-g++="${CXX}" USE_LDCONFIG= ${PREFIX}/lib/virtualbox CONFLICTS= bcc-[0-9]* VBOXGROUP?= vboxusers VBOXGID?= 920 VBOX_FRONTENDS= VBoxHeadless VBOX_GUEST_VER= 3.0.6 SUB_FILES= pkg-install SUB_LIST= PREFIX=${PREFIX} \ VBOXGROUP=${VBOXGROUP} \ VBOXGID=${VBOXGID} OPTIONS= QT4 "Build with QT4 Frontend" on \ DEBUG "Build with debugging symbols" off \ GUESTADDITIONS "Build with Guest Additions" off \ DBUS "Build with D-Bus and HAL support" on \ PULSEAUDIO "Build with PulseAudio" off \ X11 "Build with X11 support" on \ NLS "Native language support" on .include PLIST_SUB+= KMODDIR=${KMODDIR:C,^/,,} \ PYTHON_VER=${PYTHON_VER} \ PYTHON_VERU=${PYTHON_VER:S/./_/} \ GUEST_VER=${VBOX_GUEST_VER} KMODDIR= /boot/modules KMK_BUILDTYPE= release KMK_CONFIG= VBOX_LIBPATH_X11=${LOCALBASE} VBOX_FREEBSD_SRC=${SRC_BASE}/sys KMK_FLAGS= .if defined(WITHOUT_QT4) && !defined(WITHOUT_NLS) BROKEN= NLS support requires QT4 frontend. Run 'make config' again! .endif .if defined(WITHOUT_X11) && !defined(WITHOUT_QT4) BROKEN= QT4 frontend requires X11 support. Run 'make config' again! .endif .if !defined(WITHOUT_X11) USE_SDL= sdl USE_XORG= xcursor xmu VBOX_FRONTENDS+=VBoxBFE VBoxSDL VBoxTestOGL PLIST_SUB+= X11="" .else CONFIGURE_ARGS+=--build-headless PLIST_SUB+= X11="@comment " .endif .if !defined(WITHOUT_QT4) USE_QT_VER= 4 QT_NONSTANDARD= yes QT_COMPONENTS= gui network moc_build uic_build rcc_build linguist INSTALLS_ICONS= yes VBOX_FRONTENDS+=VirtualBox PLIST_SUB+= QT4="" .else CONFIGURE_ARGS+=--disable-qt4 PLIST_SUB+= QT4="@comment " .endif .if defined(WITH_GUESTADDITIONS) GUESTADDITIONS= VBoxGuestAdditions_${VBOX_GUEST_VER}.iso GADISTFILES= ${GUESTADDITIONS}:guestadditions RESTRICTED= for personal use only RESTRICTED_FILES= ${GUESTADDITIONS} FETCH_ARGS= -pRr PLIST_SUB+= GUESTADDITIONS="" .else PLIST_SUB+= GUESTADDITIONS="@comment " .endif .if defined(WITH_DEBUG) KMK_FLAGS+= BUILD_TYPE=debug KMK_BUILDTYPE= debug .endif .if !defined(WITHOUT_DBUS) LIB_DEPENDS+= dbus-1.3:${PORTSDIR}/devel/dbus .else CONFIGURE_ARGS+=--disable-dbus .endif .if !defined(WITH_PULSEAUDIO) CONFIGURE_ARGS+=--disable-pulse .endif .if !defined(WITHOUT_NLS) PLIST_SUB+= NLS="" .else PLIST_SUB+= NLS="@comment " .endif .if !exists(${SRC_BASE}/sys/kern/bus_if.m) IGNORE= requires kernel sources for the kernel module .endif .if ${OSVERSION} < 700000 BROKEN= Does not compile on FreeBSD 6.X .endif .if ${ARCH} == i386 KMK_ARCH= freebsd.x86 PLIST_SUB+= I386="" .else KMK_ARCH= freebsd.${ARCH} PLIST_SUB+= I386="@comment " .endif .include pre-everything:: .if ${ARCH} == "amd64" .if !exists(/usr/lib32) @${ECHO} 'Requires 32-bit libraries installed under /usr/lib32.' @${ECHO} 'Do: cd /usr/src; make build32 install32; ldconfig -v -m -R /usr/lib32' @${FALSE} .endif .endif post-patch: @${ECHO} 'VBOX_PATH_APP_PRIVATE_ARCH = ${PREFIX}/lib/virtualbox' > ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_SHARED_LIBS = ${PREFIX}/lib/virtualbox' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_RUNPATH = ${PREFIX}/lib/virtualbox' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_APP_PRIVATE = ${DATADIR}' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_APP_DOCS = ${DOCSDIR}' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_INSTALLER = 1' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_TESTCASES=' >> ${WRKSRC}/LocalConfig.kmk .if defined(WITHOUT_X11) @${ECHO} 'VBOX_WITH_X11_ADDITIONS=' >> ${WRKSRC}/LocalConfig.kmk .endif @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \ ${WRKSRC}/Config.kmk ${WRKSRC}/configure \ ${WRKSRC}/kBuild/units/qt3.kmk ${WRKSRC}/kBuild/units/qt4.kmk \ ${WRKSRC}/kBuild/sdks/LIBSDL.kmk \ ${WRKSRC}/src/libs/xpcom18a4/python/gen_python_deps.py @${REINPLACE_CMD} -e 's|\$$KBUILDDIR_BIN/kmk_sed|${PREFIX}/bin/kmk_sed|g' ${WRKSRC}/configure pre-build: @${REINPLACE_CMD} -e 's|/bin/bash|/bin/sh|' \ ${WRKSRC}/env.sh do-build: cd ${WRKSRC} && ${SH} env.sh && ${KMK_CONFIG} ${LOCALBASE}/bin/kmk ${KMK_FLAGS} do-install: ${MKDIR} ${KMODDIR} .for f in vboxdrv.ko vboxnetadp.ko vboxnetflt.ko ${INSTALL_KLD} ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/${f} ${KMODDIR} .endfor ${MKDIR} ${DATADIR} (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom && ${COPYTREE_SHARE} "idl samples" ${DATADIR}) ${MKDIR} ${PREFIX}/include/virtualbox (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom/include && ${COPYTREE_SHARE} "*" ${PREFIX}/include/virtualbox) ${MKDIR} ${PREFIX}/lib/virtualbox (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin && ${COPYTREE_SHARE} "*.so *.gc *.r0 components" ${PREFIX}/lib/virtualbox) .if !defined(WITHOUT_NLS) ${MKDIR} ${DATADIR}/nls (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/obj/VirtualBox/qtnls && ${COPYTREE_SHARE} "*.qm" ${DATADIR}/nls) .endif ${MKDIR} ${PREFIX}/bin .for f in VBoxManage VBoxNetAdpCtl VBoxNetDHCP VBoxSVC VBoxXPCOMIPCD ${VBOX_FRONTENDS} ${INSTALL_PROGRAM} ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/${f} ${PREFIX}/lib/virtualbox/ ${LN} -sf ${PREFIX}/lib/virtualbox/${f} ${PREFIX}/bin/ .endfor .for f in VBoxNetAdpCtl VBoxNetDHCP ${VBOX_FRONTENDS} ${CHMOD} 4511 ${PREFIX}/lib/virtualbox/${f} .endfor .for f in VBoxManage VBoxSVC VBoxXPCOMIPCD ${CHMOD} 0711 ${PREFIX}/lib/virtualbox/${f} .endfor .if defined(WITH_GUESTADDITIONS) ${MKDIR} ${PREFIX}/lib/virtualbox/additions ${INSTALL_DATA} ${DISTDIR}/${GUESTADDITIONS} ${PREFIX}/lib/virtualbox/additions/ ${LN} -sf ${PREFIX}/lib/virtualbox/additions/${GUESTADDITIONS} ${PREFIX}/lib/virtualbox/additions/VBoxGuestAdditions.iso .endif cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/installer && \ VBOX_INSTALL_PATH="${PREFIX}/lib/virtualbox" ${PYTHON_CMD} vboxapisetup.py install @${MKDIR} ${PYTHON_SITELIBDIR} (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom/python && ${COPYTREE_SHARE} "*" ${PYTHON_SITELIBDIR}) ${PYTHON_CMD} -mcompileall ${PYTHON_SITELIBDIR}/xpcom/ post-install: @${SETENV} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .for f in VBoxManage VBoxNetDHCP VBoxSVC VBoxXPCOMIPCD ${VBOX_FRONTENDS} ${CHOWN} root:${VBOXGROUP} ${PREFIX}/lib/virtualbox/${f} .endfor @${FIND} ${DATADIR} -type d -print0 | ${XARGS} -0 ${CHMOD} 755 @${FIND} ${PREFIX}/include/virtualbox -type d -print0 | ${XARGS} -0 ${CHMOD} 755 @${FIND} ${PREFIX}/lib/virtualbox -type d -print0 | ${XARGS} -0 ${CHMOD} 755 .if !defined(WITHOUT_QT4) ${MKDIR} ${PREFIX}/share/icons/hicolor/48x48/apps/ ${INSTALL_DATA} ${WRKSRC}/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_48px.png ${PREFIX}/share/icons/hicolor/48x48/apps/VBox.png ${MKDIR} ${PREFIX}/share/applications/ ${INSTALL_DATA} ${WRKSRC}/src/VBox/Installer/solaris/virtualbox.desktop ${PREFIX}/share/applications/virtualbox.desktop .endif @${CAT} ${PKGMESSAGE} .include Property changes on: head/emulators/virtualbox-ose/Makefile ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.12 \ No newline at end of property +1.13 \ No newline at end of property Index: head/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c =================================================================== --- head/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (nonexistent) +++ head/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (revision 245451) @@ -0,0 +1,11 @@ +--- src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c.orig 2009-12-07 12:20:44.000000000 +0100 ++++ src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c 2009-12-07 12:21:00.000000000 +0100 +@@ -92,7 +92,7 @@ + DECLARE_MODULE(vboxnetadp, g_VBoxNetAdpFreeBSDModule, SI_SUB_PSEUDO, SI_ORDER_ANY); + MODULE_VERSION(vboxnetadp, 1); + MODULE_DEPEND(vboxnetadp, vboxdrv, 1, 1, 1); +-MODULE_DEPEND(vboxnetadp, ng_vboxnetflt, 1, 1, 1); ++MODULE_DEPEND(vboxnetadp, vboxnetflt, 1, 1, 1); + + /** + * Module event handler Property changes on: head/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c =================================================================== --- head/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c (revision 245450) +++ head/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c (revision 245451) @@ -1,375 +1,384 @@ Index: src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c =================================================================== --- src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c (revision 23391) +++ src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c (working copy) @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -78,8 +80,6 @@ static ng_rcvdata_t ng_vboxnetflt_rcvdata; static ng_disconnect_t ng_vboxnetflt_disconnect; static int ng_vboxnetflt_mod_event(module_t mod, int event, void *data); -static int ng_vboxnetflt_rcv_in(hook_p node, item_p item); -static int ng_vboxnetflt_rcv_out(hook_p node, item_p item); /** Netgraph node type */ #define NG_VBOXNETFLT_NODE_TYPE "vboxnetflt" @@ -112,8 +112,8 @@ { .version = NG_ABI_VERSION, .name = NG_VBOXNETFLT_NODE_TYPE, - .mod_event = vboxnetflt_modevent, - .constructor = ng_vboxnetflt_constructor, + .mod_event = vboxnetflt_modevent, + .constructor = ng_vboxnetflt_constructor, .rcvmsg = ng_vboxnetflt_rcvmsg, .shutdown = ng_vboxnetflt_shutdown, .newhook = ng_vboxnetflt_newhook, +@@ -122,7 +122,7 @@ + .cmdlist = ng_vboxnetflt_cmdlist, + }; + NETGRAPH_INIT(vboxnetflt, &ng_vboxnetflt_typestruct); +-MODULE_VERSION(ng_vboxnetflt, 1); ++MODULE_VERSION(vboxnetflt, 1); + MODULE_DEPEND(ng_vboxnetflt, vboxdrv, 1, 1, 1); + + /** @@ -267,16 +267,12 @@ if (strcmp(name, NG_VBOXNETFLT_HOOK_IN) == 0) { #if __FreeBSD_version >= 800000 - NG_HOOK_SET_RCVDATA(hook, ng_vboxnetflt_rcv_in); NG_HOOK_SET_TO_INBOUND(hook); #endif pThis->u.s.input = hook; } else if (strcmp(name, NG_VBOXNETFLT_HOOK_OUT) == 0) { -#if __FreeBSD_version >= 800000 - NG_HOOK_SET_RCVDATA(hook, ng_vboxnetflt_rcv_out); -#endif pThis->u.s.output = hook; } else @@ -310,161 +306,171 @@ /** * Handle data on netgraph hooks. + * Frames processing is deferred to a taskqueue because this might + * be called with non-sleepable locks held and code paths inside + * the virtual switch might sleep. */ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p item) { const node_p node = NG_HOOK_NODE(hook); PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); + struct ifnet *ifp = pThis->u.s.ifp; struct mbuf *m; + struct m_tag *mtag; + bool fActive; + fActive = ASMAtomicUoReadBool(&pThis->fActive); + + NGI_GET_M(item, m); + NG_FREE_ITEM(item); + + /* Locate tag to see if processing should be skipped for this frame */ + mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); + if (mtag != NULL) + { + m_tag_unlink(m, mtag); + m_tag_free(mtag); + } + + /* + * Handle incoming hook. This is connected to the + * input path of the interface, thus handling incoming frames. + */ if (pThis->u.s.input == hook) - return ng_vboxnetflt_rcv_in(hook, item); + { + if (mtag != NULL || !fActive) + { + ether_demux(ifp, m); + return (0); + } + mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); + _IF_ENQUEUE(&pThis->u.s.inq, m); + mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); + taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskin); + } + /** + * Handle mbufs on the outgoing hook, frames going to the interface + */ else if (pThis->u.s.output == hook) - return ng_vboxnetflt_rcv_out(hook, item); + { + if (mtag != NULL || !fActive) + return ether_output_frame(ifp, m); + mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); + _IF_ENQUEUE(&pThis->u.s.outq, m); + mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); + taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskout); + } else { - NGI_GET_M(item, m); - NG_FREE_ITEM(item); + m_freem(m); } return (0); } +static int ng_vboxnetflt_shutdown(node_p node) +{ + PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); + bool fActive; + + /* Prevent node shutdown if we're active */ + fActive = ASMAtomicUoReadBool(&pThis->fActive); + if (fActive) + return (EBUSY); + NG_NODE_UNREF(node); + return (0); +} + +static int ng_vboxnetflt_disconnect(hook_p hook) +{ + return (0); +} + /** - * Handle incoming hook. This is connected to the - * input path of the interface, thus handling incoming frames. + * Input processing task, handles incoming frames */ -static int ng_vboxnetflt_rcv_in(hook_p hook, item_p item) +static void vboxNetFltFreeBSDinput(void *arg, int pending) { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; struct mbuf *m, *m0; - struct m_tag *mtag; - const node_p node = NG_HOOK_NODE(hook); - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); struct ifnet *ifp = pThis->u.s.ifp; - bool fActive, fDropIt = false; unsigned int cSegs = 0; + bool fDropIt = false, fActive; PINTNETSG pSG; - NGI_GET_M(item, m); - NG_FREE_ITEM(item); - - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (!fActive) - goto out; - - mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); - if (mtag != NULL) - { - m_tag_unlink(m, mtag); - m_tag_free(mtag); - goto out; - } vboxNetFltRetain(pThis, true /* fBusy */); - - for (m0 = m; m0 != NULL; m0 = m0->m_next) + for (;;) { - if (m0->m_len > 0) - cSegs++; - } + mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); + _IF_DEQUEUE(&pThis->u.s.inq, m); + mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); + if (m == NULL) + break; + for (m0 = m; m0 != NULL; m0 = m0->m_next) + if (m0->m_len > 0) + cSegs++; + #ifdef PADD_RUNT_FRAMES_FROM_HOST - if (m_length(m, NULL) < 60) - cSegs++; + if (m_length(m, NULL) < 60) + cSegs++; #endif - /* Create a copy of the mbuf and hand it to the virtual switch */ - pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); - vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); - fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_WIRE); - RTMemTmpFree(pSG); + /* Create a copy and deliver to the virtual switch */ + pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); + vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); + fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); + RTMemTmpFree(pSG); + if (fDropIt) + m_freem(m); + else + ether_demux(ifp, m); + } vboxNetFltRelease(pThis, true /* fBusy */); - -out: - /* Only deliver it to the host stack if the destination weren't a guest */ - if (fDropIt) - { - m_freem(m); - return (0); - } - ether_demux(ifp, m); - return (0); } /** - * Handle mbufs on the outgoing hook, frames going to the interface + * Output processing task, handles outgoing frames */ -static int ng_vboxnetflt_rcv_out(hook_p hook, item_p item) +static void vboxNetFltFreeBSDoutput(void *arg, int pending) { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; struct mbuf *m, *m0; - struct m_tag *mtag; - const node_p node = NG_HOOK_NODE(hook); - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); struct ifnet *ifp = pThis->u.s.ifp; unsigned int cSegs = 0; bool fDropIt = false, fActive; PINTNETSG pSG; - NGI_GET_M(item, m); - NG_FREE_ITEM(item); - - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (!fActive) - return ether_output_frame(ifp, m); - vboxNetFltRetain(pThis, true /* fBusy */); - /* Pass directly to interface if the packet originated from us */ - mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); - if (mtag != NULL) + for (;;) { - m_tag_unlink(m, mtag); - m_tag_free(mtag); - goto out; - } + mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); + _IF_DEQUEUE(&pThis->u.s.outq, m); + mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); + if (m == NULL) + break; - for (m0 = m; m0 != NULL; m0 = m0->m_next) - { - if (m0->m_len > 0) - cSegs++; - } + for (m0 = m; m0 != NULL; m0 = m0->m_next) + if (m0->m_len > 0) + cSegs++; #ifdef PADD_RUNT_FRAMES_FROM_HOST - if (m_length(m, NULL) < 60) - cSegs++; + if (m_length(m, NULL) < 60) + cSegs++; #endif - /* Create a copy and deliver to the virtual switch */ - pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); - vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); - fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); - RTMemTmpFree(pSG); + /* Create a copy and deliver to the virtual switch */ + pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); + vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); + fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); + RTMemTmpFree(pSG); -out: + if (fDropIt) + m_freem(m); + else + ether_output_frame(ifp, m); + } vboxNetFltRelease(pThis, true /* fBusy */); - if (fDropIt) - { - m_freem(m); - return (0); - } - - return ether_output_frame(ifp, m); } -static int ng_vboxnetflt_shutdown(node_p node) -{ - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); - bool fActive; - - /* Prevent node shutdown if we're active */ - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (fActive) - return (EBUSY); - NG_NODE_UNREF(node); - return (0); -} - -static int ng_vboxnetflt_disconnect(hook_p hook) -{ - return (0); -} - /** * Called to deliver a frame to either the host, the wire or both. */ @@ -536,13 +542,23 @@ /* Create a new netgraph node for this instance */ if (ng_make_node_common(&ng_vboxnetflt_typestruct, &node) != 0) - return VERR_INTERNAL_ERROR; + return VERR_INTERNAL_ERROR; RTSpinlockAcquire(pThis->hSpinlock, &Tmp); ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.ifp, ifp); pThis->u.s.node = node; bcopy(IF_LLADDR(ifp), &pThis->u.s.Mac, ETHER_ADDR_LEN); ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false); + /* Initialize deferred input queue */ + bzero(&pThis->u.s.inq, sizeof(struct ifqueue)); + mtx_init(&pThis->u.s.inq.ifq_mtx, "vboxnetflt inq", NULL, MTX_SPIN); + TASK_INIT(&pThis->u.s.tskin, 0, vboxNetFltFreeBSDinput, pThis); + + /* Initialize deferred output queue */ + bzero(&pThis->u.s.outq, sizeof(struct ifqueue)); + mtx_init(&pThis->u.s.outq.ifq_mtx, "vboxnetflt outq", NULL, MTX_SPIN); + TASK_INIT(&pThis->u.s.tskout, 0, vboxNetFltFreeBSDoutput, pThis); + RTSpinlockRelease(pThis->hSpinlock, &Tmp); NG_NODE_SET_PRIVATE(node, pThis); @@ -571,7 +587,10 @@ } if (ifp0 != NULL) + { + vboxNetFltOsDeleteInstance(pThis); vboxNetFltOsInitInstance(pThis, NULL); + } return !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost); } @@ -579,6 +598,12 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) { + taskqueue_drain(taskqueue_fast, &pThis->u.s.tskin); + taskqueue_drain(taskqueue_fast, &pThis->u.s.tskout); + + mtx_destroy(&pThis->u.s.inq.ifq_mtx); + mtx_destroy(&pThis->u.s.outq.ifq_mtx); + if (pThis->u.s.node != NULL) ng_rmnode_self(pThis->u.s.node); pThis->u.s.node = NULL; Property changes on: head/emulators/virtualbox-ose/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.1 \ No newline at end of property +1.2 \ No newline at end of property Index: head/emulators/virtualbox-ose-kmod/Makefile =================================================================== --- head/emulators/virtualbox-ose-kmod/Makefile (revision 245450) +++ head/emulators/virtualbox-ose-kmod/Makefile (revision 245451) @@ -1,259 +1,259 @@ # New ports collection makefile for: virtualbox # Date created: 2009-05-02 # Whom: Bernhard Froehlich # # $FreeBSD$ # PORTNAME= virtualbox DISTVERSION= 3.0.51r22902 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= emulators kld MASTER_SITES= http://tmp.chruetertee.ch/ \ http://freebsd.unixfreunde.de/sources/ \ http://disasterarea.chruetertee.ch/ \ http://mirror.4bit.ws/ \ http://dlc.sun.com/virtualbox/${VBOX_GUEST_VER}/:guestadditions DISTFILES= ${DISTNAME}${EXTRACT_SUFX} ${GADISTFILES} EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} #for discussion please use emulation@FreeBSD.org MAINTAINER= vbox@FreeBSD.org COMMENT= A general-purpose full virtualizer for x86 hardware BUILD_DEPENDS= yasm:${PORTSDIR}/devel/yasm \ as86:${PORTSDIR}/devel/dev86 \ xsltproc:${PORTSDIR}/textproc/libxslt \ kmk:${PORTSDIR}/devel/kBuild LIB_DEPENDS= png.5:${PORTSDIR}/graphics/png \ xslt.2:${PORTSDIR}/textproc/libxslt \ curl.5:${PORTSDIR}/ftp/curl ONLY_FOR_ARCHS= i386 amd64 USE_GNOME= libidl USE_CDRTOOLS= yes USE_BZIP2= yes USE_PYTHON= yes USE_PYDISTUTILS= easy_install PYDISTUTILS_PKGNAME= vboxapi PYDISTUTILS_PKGVERSION= 1.0 PYDISTUTILS_NOEGGINFO= yes HAS_CONFIGURE= yes CONFIGURE_ARGS+=--with-gcc="${CC}" --with-g++="${CXX}" USE_LDCONFIG= ${PREFIX}/lib/virtualbox CONFLICTS= bcc-[0-9]* VBOXGROUP?= vboxusers VBOXGID?= 920 VBOX_FRONTENDS= VBoxHeadless VBOX_GUEST_VER= 3.0.6 SUB_FILES= pkg-install SUB_LIST= PREFIX=${PREFIX} \ VBOXGROUP=${VBOXGROUP} \ VBOXGID=${VBOXGID} OPTIONS= QT4 "Build with QT4 Frontend" on \ DEBUG "Build with debugging symbols" off \ GUESTADDITIONS "Build with Guest Additions" off \ DBUS "Build with D-Bus and HAL support" on \ PULSEAUDIO "Build with PulseAudio" off \ X11 "Build with X11 support" on \ NLS "Native language support" on .include PLIST_SUB+= KMODDIR=${KMODDIR:C,^/,,} \ PYTHON_VER=${PYTHON_VER} \ PYTHON_VERU=${PYTHON_VER:S/./_/} \ GUEST_VER=${VBOX_GUEST_VER} KMODDIR= /boot/modules KMK_BUILDTYPE= release KMK_CONFIG= VBOX_LIBPATH_X11=${LOCALBASE} VBOX_FREEBSD_SRC=${SRC_BASE}/sys KMK_FLAGS= .if defined(WITHOUT_QT4) && !defined(WITHOUT_NLS) BROKEN= NLS support requires QT4 frontend. Run 'make config' again! .endif .if defined(WITHOUT_X11) && !defined(WITHOUT_QT4) BROKEN= QT4 frontend requires X11 support. Run 'make config' again! .endif .if !defined(WITHOUT_X11) USE_SDL= sdl USE_XORG= xcursor xmu VBOX_FRONTENDS+=VBoxBFE VBoxSDL VBoxTestOGL PLIST_SUB+= X11="" .else CONFIGURE_ARGS+=--build-headless PLIST_SUB+= X11="@comment " .endif .if !defined(WITHOUT_QT4) USE_QT_VER= 4 QT_NONSTANDARD= yes QT_COMPONENTS= gui network moc_build uic_build rcc_build linguist INSTALLS_ICONS= yes VBOX_FRONTENDS+=VirtualBox PLIST_SUB+= QT4="" .else CONFIGURE_ARGS+=--disable-qt4 PLIST_SUB+= QT4="@comment " .endif .if defined(WITH_GUESTADDITIONS) GUESTADDITIONS= VBoxGuestAdditions_${VBOX_GUEST_VER}.iso GADISTFILES= ${GUESTADDITIONS}:guestadditions RESTRICTED= for personal use only RESTRICTED_FILES= ${GUESTADDITIONS} FETCH_ARGS= -pRr PLIST_SUB+= GUESTADDITIONS="" .else PLIST_SUB+= GUESTADDITIONS="@comment " .endif .if defined(WITH_DEBUG) KMK_FLAGS+= BUILD_TYPE=debug KMK_BUILDTYPE= debug .endif .if !defined(WITHOUT_DBUS) LIB_DEPENDS+= dbus-1.3:${PORTSDIR}/devel/dbus .else CONFIGURE_ARGS+=--disable-dbus .endif .if !defined(WITH_PULSEAUDIO) CONFIGURE_ARGS+=--disable-pulse .endif .if !defined(WITHOUT_NLS) PLIST_SUB+= NLS="" .else PLIST_SUB+= NLS="@comment " .endif .if !exists(${SRC_BASE}/sys/kern/bus_if.m) IGNORE= requires kernel sources for the kernel module .endif .if ${OSVERSION} < 700000 BROKEN= Does not compile on FreeBSD 6.X .endif .if ${ARCH} == i386 KMK_ARCH= freebsd.x86 PLIST_SUB+= I386="" .else KMK_ARCH= freebsd.${ARCH} PLIST_SUB+= I386="@comment " .endif .include pre-everything:: .if ${ARCH} == "amd64" .if !exists(/usr/lib32) @${ECHO} 'Requires 32-bit libraries installed under /usr/lib32.' @${ECHO} 'Do: cd /usr/src; make build32 install32; ldconfig -v -m -R /usr/lib32' @${FALSE} .endif .endif post-patch: @${ECHO} 'VBOX_PATH_APP_PRIVATE_ARCH = ${PREFIX}/lib/virtualbox' > ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_SHARED_LIBS = ${PREFIX}/lib/virtualbox' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_RUNPATH = ${PREFIX}/lib/virtualbox' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_APP_PRIVATE = ${DATADIR}' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_APP_DOCS = ${DOCSDIR}' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_INSTALLER = 1' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_TESTCASES=' >> ${WRKSRC}/LocalConfig.kmk .if defined(WITHOUT_X11) @${ECHO} 'VBOX_WITH_X11_ADDITIONS=' >> ${WRKSRC}/LocalConfig.kmk .endif @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \ ${WRKSRC}/Config.kmk ${WRKSRC}/configure \ ${WRKSRC}/kBuild/units/qt3.kmk ${WRKSRC}/kBuild/units/qt4.kmk \ ${WRKSRC}/kBuild/sdks/LIBSDL.kmk \ ${WRKSRC}/src/libs/xpcom18a4/python/gen_python_deps.py @${REINPLACE_CMD} -e 's|\$$KBUILDDIR_BIN/kmk_sed|${PREFIX}/bin/kmk_sed|g' ${WRKSRC}/configure pre-build: @${REINPLACE_CMD} -e 's|/bin/bash|/bin/sh|' \ ${WRKSRC}/env.sh do-build: cd ${WRKSRC} && ${SH} env.sh && ${KMK_CONFIG} ${LOCALBASE}/bin/kmk ${KMK_FLAGS} do-install: ${MKDIR} ${KMODDIR} .for f in vboxdrv.ko vboxnetadp.ko vboxnetflt.ko ${INSTALL_KLD} ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/${f} ${KMODDIR} .endfor ${MKDIR} ${DATADIR} (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom && ${COPYTREE_SHARE} "idl samples" ${DATADIR}) ${MKDIR} ${PREFIX}/include/virtualbox (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom/include && ${COPYTREE_SHARE} "*" ${PREFIX}/include/virtualbox) ${MKDIR} ${PREFIX}/lib/virtualbox (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin && ${COPYTREE_SHARE} "*.so *.gc *.r0 components" ${PREFIX}/lib/virtualbox) .if !defined(WITHOUT_NLS) ${MKDIR} ${DATADIR}/nls (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/obj/VirtualBox/qtnls && ${COPYTREE_SHARE} "*.qm" ${DATADIR}/nls) .endif ${MKDIR} ${PREFIX}/bin .for f in VBoxManage VBoxNetAdpCtl VBoxNetDHCP VBoxSVC VBoxXPCOMIPCD ${VBOX_FRONTENDS} ${INSTALL_PROGRAM} ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/${f} ${PREFIX}/lib/virtualbox/ ${LN} -sf ${PREFIX}/lib/virtualbox/${f} ${PREFIX}/bin/ .endfor .for f in VBoxNetAdpCtl VBoxNetDHCP ${VBOX_FRONTENDS} ${CHMOD} 4511 ${PREFIX}/lib/virtualbox/${f} .endfor .for f in VBoxManage VBoxSVC VBoxXPCOMIPCD ${CHMOD} 0711 ${PREFIX}/lib/virtualbox/${f} .endfor .if defined(WITH_GUESTADDITIONS) ${MKDIR} ${PREFIX}/lib/virtualbox/additions ${INSTALL_DATA} ${DISTDIR}/${GUESTADDITIONS} ${PREFIX}/lib/virtualbox/additions/ ${LN} -sf ${PREFIX}/lib/virtualbox/additions/${GUESTADDITIONS} ${PREFIX}/lib/virtualbox/additions/VBoxGuestAdditions.iso .endif cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/installer && \ VBOX_INSTALL_PATH="${PREFIX}/lib/virtualbox" ${PYTHON_CMD} vboxapisetup.py install @${MKDIR} ${PYTHON_SITELIBDIR} (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom/python && ${COPYTREE_SHARE} "*" ${PYTHON_SITELIBDIR}) ${PYTHON_CMD} -mcompileall ${PYTHON_SITELIBDIR}/xpcom/ post-install: @${SETENV} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .for f in VBoxManage VBoxNetDHCP VBoxSVC VBoxXPCOMIPCD ${VBOX_FRONTENDS} ${CHOWN} root:${VBOXGROUP} ${PREFIX}/lib/virtualbox/${f} .endfor @${FIND} ${DATADIR} -type d -print0 | ${XARGS} -0 ${CHMOD} 755 @${FIND} ${PREFIX}/include/virtualbox -type d -print0 | ${XARGS} -0 ${CHMOD} 755 @${FIND} ${PREFIX}/lib/virtualbox -type d -print0 | ${XARGS} -0 ${CHMOD} 755 .if !defined(WITHOUT_QT4) ${MKDIR} ${PREFIX}/share/icons/hicolor/48x48/apps/ ${INSTALL_DATA} ${WRKSRC}/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_48px.png ${PREFIX}/share/icons/hicolor/48x48/apps/VBox.png ${MKDIR} ${PREFIX}/share/applications/ ${INSTALL_DATA} ${WRKSRC}/src/VBox/Installer/solaris/virtualbox.desktop ${PREFIX}/share/applications/virtualbox.desktop .endif @${CAT} ${PKGMESSAGE} .include Property changes on: head/emulators/virtualbox-ose-kmod/Makefile ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.12 \ No newline at end of property +1.13 \ No newline at end of property Index: head/emulators/virtualbox-ose-kmod/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c =================================================================== --- head/emulators/virtualbox-ose-kmod/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (nonexistent) +++ head/emulators/virtualbox-ose-kmod/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (revision 245451) @@ -0,0 +1,11 @@ +--- src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c.orig 2009-12-07 12:20:44.000000000 +0100 ++++ src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c 2009-12-07 12:21:00.000000000 +0100 +@@ -92,7 +92,7 @@ + DECLARE_MODULE(vboxnetadp, g_VBoxNetAdpFreeBSDModule, SI_SUB_PSEUDO, SI_ORDER_ANY); + MODULE_VERSION(vboxnetadp, 1); + MODULE_DEPEND(vboxnetadp, vboxdrv, 1, 1, 1); +-MODULE_DEPEND(vboxnetadp, ng_vboxnetflt, 1, 1, 1); ++MODULE_DEPEND(vboxnetadp, vboxnetflt, 1, 1, 1); + + /** + * Module event handler Property changes on: head/emulators/virtualbox-ose-kmod/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/emulators/virtualbox-ose-kmod/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c =================================================================== --- head/emulators/virtualbox-ose-kmod/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c (revision 245450) +++ head/emulators/virtualbox-ose-kmod/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c (revision 245451) @@ -1,375 +1,384 @@ Index: src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c =================================================================== --- src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c (revision 23391) +++ src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c (working copy) @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -78,8 +80,6 @@ static ng_rcvdata_t ng_vboxnetflt_rcvdata; static ng_disconnect_t ng_vboxnetflt_disconnect; static int ng_vboxnetflt_mod_event(module_t mod, int event, void *data); -static int ng_vboxnetflt_rcv_in(hook_p node, item_p item); -static int ng_vboxnetflt_rcv_out(hook_p node, item_p item); /** Netgraph node type */ #define NG_VBOXNETFLT_NODE_TYPE "vboxnetflt" @@ -112,8 +112,8 @@ { .version = NG_ABI_VERSION, .name = NG_VBOXNETFLT_NODE_TYPE, - .mod_event = vboxnetflt_modevent, - .constructor = ng_vboxnetflt_constructor, + .mod_event = vboxnetflt_modevent, + .constructor = ng_vboxnetflt_constructor, .rcvmsg = ng_vboxnetflt_rcvmsg, .shutdown = ng_vboxnetflt_shutdown, .newhook = ng_vboxnetflt_newhook, +@@ -122,7 +122,7 @@ + .cmdlist = ng_vboxnetflt_cmdlist, + }; + NETGRAPH_INIT(vboxnetflt, &ng_vboxnetflt_typestruct); +-MODULE_VERSION(ng_vboxnetflt, 1); ++MODULE_VERSION(vboxnetflt, 1); + MODULE_DEPEND(ng_vboxnetflt, vboxdrv, 1, 1, 1); + + /** @@ -267,16 +267,12 @@ if (strcmp(name, NG_VBOXNETFLT_HOOK_IN) == 0) { #if __FreeBSD_version >= 800000 - NG_HOOK_SET_RCVDATA(hook, ng_vboxnetflt_rcv_in); NG_HOOK_SET_TO_INBOUND(hook); #endif pThis->u.s.input = hook; } else if (strcmp(name, NG_VBOXNETFLT_HOOK_OUT) == 0) { -#if __FreeBSD_version >= 800000 - NG_HOOK_SET_RCVDATA(hook, ng_vboxnetflt_rcv_out); -#endif pThis->u.s.output = hook; } else @@ -310,161 +306,171 @@ /** * Handle data on netgraph hooks. + * Frames processing is deferred to a taskqueue because this might + * be called with non-sleepable locks held and code paths inside + * the virtual switch might sleep. */ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p item) { const node_p node = NG_HOOK_NODE(hook); PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); + struct ifnet *ifp = pThis->u.s.ifp; struct mbuf *m; + struct m_tag *mtag; + bool fActive; + fActive = ASMAtomicUoReadBool(&pThis->fActive); + + NGI_GET_M(item, m); + NG_FREE_ITEM(item); + + /* Locate tag to see if processing should be skipped for this frame */ + mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); + if (mtag != NULL) + { + m_tag_unlink(m, mtag); + m_tag_free(mtag); + } + + /* + * Handle incoming hook. This is connected to the + * input path of the interface, thus handling incoming frames. + */ if (pThis->u.s.input == hook) - return ng_vboxnetflt_rcv_in(hook, item); + { + if (mtag != NULL || !fActive) + { + ether_demux(ifp, m); + return (0); + } + mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); + _IF_ENQUEUE(&pThis->u.s.inq, m); + mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); + taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskin); + } + /** + * Handle mbufs on the outgoing hook, frames going to the interface + */ else if (pThis->u.s.output == hook) - return ng_vboxnetflt_rcv_out(hook, item); + { + if (mtag != NULL || !fActive) + return ether_output_frame(ifp, m); + mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); + _IF_ENQUEUE(&pThis->u.s.outq, m); + mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); + taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskout); + } else { - NGI_GET_M(item, m); - NG_FREE_ITEM(item); + m_freem(m); } return (0); } +static int ng_vboxnetflt_shutdown(node_p node) +{ + PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); + bool fActive; + + /* Prevent node shutdown if we're active */ + fActive = ASMAtomicUoReadBool(&pThis->fActive); + if (fActive) + return (EBUSY); + NG_NODE_UNREF(node); + return (0); +} + +static int ng_vboxnetflt_disconnect(hook_p hook) +{ + return (0); +} + /** - * Handle incoming hook. This is connected to the - * input path of the interface, thus handling incoming frames. + * Input processing task, handles incoming frames */ -static int ng_vboxnetflt_rcv_in(hook_p hook, item_p item) +static void vboxNetFltFreeBSDinput(void *arg, int pending) { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; struct mbuf *m, *m0; - struct m_tag *mtag; - const node_p node = NG_HOOK_NODE(hook); - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); struct ifnet *ifp = pThis->u.s.ifp; - bool fActive, fDropIt = false; unsigned int cSegs = 0; + bool fDropIt = false, fActive; PINTNETSG pSG; - NGI_GET_M(item, m); - NG_FREE_ITEM(item); - - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (!fActive) - goto out; - - mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); - if (mtag != NULL) - { - m_tag_unlink(m, mtag); - m_tag_free(mtag); - goto out; - } vboxNetFltRetain(pThis, true /* fBusy */); - - for (m0 = m; m0 != NULL; m0 = m0->m_next) + for (;;) { - if (m0->m_len > 0) - cSegs++; - } + mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); + _IF_DEQUEUE(&pThis->u.s.inq, m); + mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); + if (m == NULL) + break; + for (m0 = m; m0 != NULL; m0 = m0->m_next) + if (m0->m_len > 0) + cSegs++; + #ifdef PADD_RUNT_FRAMES_FROM_HOST - if (m_length(m, NULL) < 60) - cSegs++; + if (m_length(m, NULL) < 60) + cSegs++; #endif - /* Create a copy of the mbuf and hand it to the virtual switch */ - pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); - vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); - fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_WIRE); - RTMemTmpFree(pSG); + /* Create a copy and deliver to the virtual switch */ + pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); + vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); + fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); + RTMemTmpFree(pSG); + if (fDropIt) + m_freem(m); + else + ether_demux(ifp, m); + } vboxNetFltRelease(pThis, true /* fBusy */); - -out: - /* Only deliver it to the host stack if the destination weren't a guest */ - if (fDropIt) - { - m_freem(m); - return (0); - } - ether_demux(ifp, m); - return (0); } /** - * Handle mbufs on the outgoing hook, frames going to the interface + * Output processing task, handles outgoing frames */ -static int ng_vboxnetflt_rcv_out(hook_p hook, item_p item) +static void vboxNetFltFreeBSDoutput(void *arg, int pending) { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; struct mbuf *m, *m0; - struct m_tag *mtag; - const node_p node = NG_HOOK_NODE(hook); - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); struct ifnet *ifp = pThis->u.s.ifp; unsigned int cSegs = 0; bool fDropIt = false, fActive; PINTNETSG pSG; - NGI_GET_M(item, m); - NG_FREE_ITEM(item); - - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (!fActive) - return ether_output_frame(ifp, m); - vboxNetFltRetain(pThis, true /* fBusy */); - /* Pass directly to interface if the packet originated from us */ - mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); - if (mtag != NULL) + for (;;) { - m_tag_unlink(m, mtag); - m_tag_free(mtag); - goto out; - } + mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); + _IF_DEQUEUE(&pThis->u.s.outq, m); + mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); + if (m == NULL) + break; - for (m0 = m; m0 != NULL; m0 = m0->m_next) - { - if (m0->m_len > 0) - cSegs++; - } + for (m0 = m; m0 != NULL; m0 = m0->m_next) + if (m0->m_len > 0) + cSegs++; #ifdef PADD_RUNT_FRAMES_FROM_HOST - if (m_length(m, NULL) < 60) - cSegs++; + if (m_length(m, NULL) < 60) + cSegs++; #endif - /* Create a copy and deliver to the virtual switch */ - pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); - vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); - fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); - RTMemTmpFree(pSG); + /* Create a copy and deliver to the virtual switch */ + pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); + vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); + fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); + RTMemTmpFree(pSG); -out: + if (fDropIt) + m_freem(m); + else + ether_output_frame(ifp, m); + } vboxNetFltRelease(pThis, true /* fBusy */); - if (fDropIt) - { - m_freem(m); - return (0); - } - - return ether_output_frame(ifp, m); } -static int ng_vboxnetflt_shutdown(node_p node) -{ - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); - bool fActive; - - /* Prevent node shutdown if we're active */ - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (fActive) - return (EBUSY); - NG_NODE_UNREF(node); - return (0); -} - -static int ng_vboxnetflt_disconnect(hook_p hook) -{ - return (0); -} - /** * Called to deliver a frame to either the host, the wire or both. */ @@ -536,13 +542,23 @@ /* Create a new netgraph node for this instance */ if (ng_make_node_common(&ng_vboxnetflt_typestruct, &node) != 0) - return VERR_INTERNAL_ERROR; + return VERR_INTERNAL_ERROR; RTSpinlockAcquire(pThis->hSpinlock, &Tmp); ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.ifp, ifp); pThis->u.s.node = node; bcopy(IF_LLADDR(ifp), &pThis->u.s.Mac, ETHER_ADDR_LEN); ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false); + /* Initialize deferred input queue */ + bzero(&pThis->u.s.inq, sizeof(struct ifqueue)); + mtx_init(&pThis->u.s.inq.ifq_mtx, "vboxnetflt inq", NULL, MTX_SPIN); + TASK_INIT(&pThis->u.s.tskin, 0, vboxNetFltFreeBSDinput, pThis); + + /* Initialize deferred output queue */ + bzero(&pThis->u.s.outq, sizeof(struct ifqueue)); + mtx_init(&pThis->u.s.outq.ifq_mtx, "vboxnetflt outq", NULL, MTX_SPIN); + TASK_INIT(&pThis->u.s.tskout, 0, vboxNetFltFreeBSDoutput, pThis); + RTSpinlockRelease(pThis->hSpinlock, &Tmp); NG_NODE_SET_PRIVATE(node, pThis); @@ -571,7 +587,10 @@ } if (ifp0 != NULL) + { + vboxNetFltOsDeleteInstance(pThis); vboxNetFltOsInitInstance(pThis, NULL); + } return !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost); } @@ -579,6 +598,12 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) { + taskqueue_drain(taskqueue_fast, &pThis->u.s.tskin); + taskqueue_drain(taskqueue_fast, &pThis->u.s.tskout); + + mtx_destroy(&pThis->u.s.inq.ifq_mtx); + mtx_destroy(&pThis->u.s.outq.ifq_mtx); + if (pThis->u.s.node != NULL) ng_rmnode_self(pThis->u.s.node); pThis->u.s.node = NULL; Property changes on: head/emulators/virtualbox-ose-kmod/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.1 \ No newline at end of property +1.2 \ No newline at end of property Index: head/emulators/virtualbox-ose-kmod-legacy/Makefile =================================================================== --- head/emulators/virtualbox-ose-kmod-legacy/Makefile (revision 245450) +++ head/emulators/virtualbox-ose-kmod-legacy/Makefile (revision 245451) @@ -1,259 +1,259 @@ # New ports collection makefile for: virtualbox # Date created: 2009-05-02 # Whom: Bernhard Froehlich # # $FreeBSD$ # PORTNAME= virtualbox DISTVERSION= 3.0.51r22902 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= emulators kld MASTER_SITES= http://tmp.chruetertee.ch/ \ http://freebsd.unixfreunde.de/sources/ \ http://disasterarea.chruetertee.ch/ \ http://mirror.4bit.ws/ \ http://dlc.sun.com/virtualbox/${VBOX_GUEST_VER}/:guestadditions DISTFILES= ${DISTNAME}${EXTRACT_SUFX} ${GADISTFILES} EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} #for discussion please use emulation@FreeBSD.org MAINTAINER= vbox@FreeBSD.org COMMENT= A general-purpose full virtualizer for x86 hardware BUILD_DEPENDS= yasm:${PORTSDIR}/devel/yasm \ as86:${PORTSDIR}/devel/dev86 \ xsltproc:${PORTSDIR}/textproc/libxslt \ kmk:${PORTSDIR}/devel/kBuild LIB_DEPENDS= png.5:${PORTSDIR}/graphics/png \ xslt.2:${PORTSDIR}/textproc/libxslt \ curl.5:${PORTSDIR}/ftp/curl ONLY_FOR_ARCHS= i386 amd64 USE_GNOME= libidl USE_CDRTOOLS= yes USE_BZIP2= yes USE_PYTHON= yes USE_PYDISTUTILS= easy_install PYDISTUTILS_PKGNAME= vboxapi PYDISTUTILS_PKGVERSION= 1.0 PYDISTUTILS_NOEGGINFO= yes HAS_CONFIGURE= yes CONFIGURE_ARGS+=--with-gcc="${CC}" --with-g++="${CXX}" USE_LDCONFIG= ${PREFIX}/lib/virtualbox CONFLICTS= bcc-[0-9]* VBOXGROUP?= vboxusers VBOXGID?= 920 VBOX_FRONTENDS= VBoxHeadless VBOX_GUEST_VER= 3.0.6 SUB_FILES= pkg-install SUB_LIST= PREFIX=${PREFIX} \ VBOXGROUP=${VBOXGROUP} \ VBOXGID=${VBOXGID} OPTIONS= QT4 "Build with QT4 Frontend" on \ DEBUG "Build with debugging symbols" off \ GUESTADDITIONS "Build with Guest Additions" off \ DBUS "Build with D-Bus and HAL support" on \ PULSEAUDIO "Build with PulseAudio" off \ X11 "Build with X11 support" on \ NLS "Native language support" on .include PLIST_SUB+= KMODDIR=${KMODDIR:C,^/,,} \ PYTHON_VER=${PYTHON_VER} \ PYTHON_VERU=${PYTHON_VER:S/./_/} \ GUEST_VER=${VBOX_GUEST_VER} KMODDIR= /boot/modules KMK_BUILDTYPE= release KMK_CONFIG= VBOX_LIBPATH_X11=${LOCALBASE} VBOX_FREEBSD_SRC=${SRC_BASE}/sys KMK_FLAGS= .if defined(WITHOUT_QT4) && !defined(WITHOUT_NLS) BROKEN= NLS support requires QT4 frontend. Run 'make config' again! .endif .if defined(WITHOUT_X11) && !defined(WITHOUT_QT4) BROKEN= QT4 frontend requires X11 support. Run 'make config' again! .endif .if !defined(WITHOUT_X11) USE_SDL= sdl USE_XORG= xcursor xmu VBOX_FRONTENDS+=VBoxBFE VBoxSDL VBoxTestOGL PLIST_SUB+= X11="" .else CONFIGURE_ARGS+=--build-headless PLIST_SUB+= X11="@comment " .endif .if !defined(WITHOUT_QT4) USE_QT_VER= 4 QT_NONSTANDARD= yes QT_COMPONENTS= gui network moc_build uic_build rcc_build linguist INSTALLS_ICONS= yes VBOX_FRONTENDS+=VirtualBox PLIST_SUB+= QT4="" .else CONFIGURE_ARGS+=--disable-qt4 PLIST_SUB+= QT4="@comment " .endif .if defined(WITH_GUESTADDITIONS) GUESTADDITIONS= VBoxGuestAdditions_${VBOX_GUEST_VER}.iso GADISTFILES= ${GUESTADDITIONS}:guestadditions RESTRICTED= for personal use only RESTRICTED_FILES= ${GUESTADDITIONS} FETCH_ARGS= -pRr PLIST_SUB+= GUESTADDITIONS="" .else PLIST_SUB+= GUESTADDITIONS="@comment " .endif .if defined(WITH_DEBUG) KMK_FLAGS+= BUILD_TYPE=debug KMK_BUILDTYPE= debug .endif .if !defined(WITHOUT_DBUS) LIB_DEPENDS+= dbus-1.3:${PORTSDIR}/devel/dbus .else CONFIGURE_ARGS+=--disable-dbus .endif .if !defined(WITH_PULSEAUDIO) CONFIGURE_ARGS+=--disable-pulse .endif .if !defined(WITHOUT_NLS) PLIST_SUB+= NLS="" .else PLIST_SUB+= NLS="@comment " .endif .if !exists(${SRC_BASE}/sys/kern/bus_if.m) IGNORE= requires kernel sources for the kernel module .endif .if ${OSVERSION} < 700000 BROKEN= Does not compile on FreeBSD 6.X .endif .if ${ARCH} == i386 KMK_ARCH= freebsd.x86 PLIST_SUB+= I386="" .else KMK_ARCH= freebsd.${ARCH} PLIST_SUB+= I386="@comment " .endif .include pre-everything:: .if ${ARCH} == "amd64" .if !exists(/usr/lib32) @${ECHO} 'Requires 32-bit libraries installed under /usr/lib32.' @${ECHO} 'Do: cd /usr/src; make build32 install32; ldconfig -v -m -R /usr/lib32' @${FALSE} .endif .endif post-patch: @${ECHO} 'VBOX_PATH_APP_PRIVATE_ARCH = ${PREFIX}/lib/virtualbox' > ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_SHARED_LIBS = ${PREFIX}/lib/virtualbox' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_RUNPATH = ${PREFIX}/lib/virtualbox' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_APP_PRIVATE = ${DATADIR}' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_APP_DOCS = ${DOCSDIR}' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_INSTALLER = 1' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_TESTCASES=' >> ${WRKSRC}/LocalConfig.kmk .if defined(WITHOUT_X11) @${ECHO} 'VBOX_WITH_X11_ADDITIONS=' >> ${WRKSRC}/LocalConfig.kmk .endif @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \ ${WRKSRC}/Config.kmk ${WRKSRC}/configure \ ${WRKSRC}/kBuild/units/qt3.kmk ${WRKSRC}/kBuild/units/qt4.kmk \ ${WRKSRC}/kBuild/sdks/LIBSDL.kmk \ ${WRKSRC}/src/libs/xpcom18a4/python/gen_python_deps.py @${REINPLACE_CMD} -e 's|\$$KBUILDDIR_BIN/kmk_sed|${PREFIX}/bin/kmk_sed|g' ${WRKSRC}/configure pre-build: @${REINPLACE_CMD} -e 's|/bin/bash|/bin/sh|' \ ${WRKSRC}/env.sh do-build: cd ${WRKSRC} && ${SH} env.sh && ${KMK_CONFIG} ${LOCALBASE}/bin/kmk ${KMK_FLAGS} do-install: ${MKDIR} ${KMODDIR} .for f in vboxdrv.ko vboxnetadp.ko vboxnetflt.ko ${INSTALL_KLD} ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/${f} ${KMODDIR} .endfor ${MKDIR} ${DATADIR} (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom && ${COPYTREE_SHARE} "idl samples" ${DATADIR}) ${MKDIR} ${PREFIX}/include/virtualbox (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom/include && ${COPYTREE_SHARE} "*" ${PREFIX}/include/virtualbox) ${MKDIR} ${PREFIX}/lib/virtualbox (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin && ${COPYTREE_SHARE} "*.so *.gc *.r0 components" ${PREFIX}/lib/virtualbox) .if !defined(WITHOUT_NLS) ${MKDIR} ${DATADIR}/nls (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/obj/VirtualBox/qtnls && ${COPYTREE_SHARE} "*.qm" ${DATADIR}/nls) .endif ${MKDIR} ${PREFIX}/bin .for f in VBoxManage VBoxNetAdpCtl VBoxNetDHCP VBoxSVC VBoxXPCOMIPCD ${VBOX_FRONTENDS} ${INSTALL_PROGRAM} ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/${f} ${PREFIX}/lib/virtualbox/ ${LN} -sf ${PREFIX}/lib/virtualbox/${f} ${PREFIX}/bin/ .endfor .for f in VBoxNetAdpCtl VBoxNetDHCP ${VBOX_FRONTENDS} ${CHMOD} 4511 ${PREFIX}/lib/virtualbox/${f} .endfor .for f in VBoxManage VBoxSVC VBoxXPCOMIPCD ${CHMOD} 0711 ${PREFIX}/lib/virtualbox/${f} .endfor .if defined(WITH_GUESTADDITIONS) ${MKDIR} ${PREFIX}/lib/virtualbox/additions ${INSTALL_DATA} ${DISTDIR}/${GUESTADDITIONS} ${PREFIX}/lib/virtualbox/additions/ ${LN} -sf ${PREFIX}/lib/virtualbox/additions/${GUESTADDITIONS} ${PREFIX}/lib/virtualbox/additions/VBoxGuestAdditions.iso .endif cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/installer && \ VBOX_INSTALL_PATH="${PREFIX}/lib/virtualbox" ${PYTHON_CMD} vboxapisetup.py install @${MKDIR} ${PYTHON_SITELIBDIR} (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom/python && ${COPYTREE_SHARE} "*" ${PYTHON_SITELIBDIR}) ${PYTHON_CMD} -mcompileall ${PYTHON_SITELIBDIR}/xpcom/ post-install: @${SETENV} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .for f in VBoxManage VBoxNetDHCP VBoxSVC VBoxXPCOMIPCD ${VBOX_FRONTENDS} ${CHOWN} root:${VBOXGROUP} ${PREFIX}/lib/virtualbox/${f} .endfor @${FIND} ${DATADIR} -type d -print0 | ${XARGS} -0 ${CHMOD} 755 @${FIND} ${PREFIX}/include/virtualbox -type d -print0 | ${XARGS} -0 ${CHMOD} 755 @${FIND} ${PREFIX}/lib/virtualbox -type d -print0 | ${XARGS} -0 ${CHMOD} 755 .if !defined(WITHOUT_QT4) ${MKDIR} ${PREFIX}/share/icons/hicolor/48x48/apps/ ${INSTALL_DATA} ${WRKSRC}/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_48px.png ${PREFIX}/share/icons/hicolor/48x48/apps/VBox.png ${MKDIR} ${PREFIX}/share/applications/ ${INSTALL_DATA} ${WRKSRC}/src/VBox/Installer/solaris/virtualbox.desktop ${PREFIX}/share/applications/virtualbox.desktop .endif @${CAT} ${PKGMESSAGE} .include Property changes on: head/emulators/virtualbox-ose-kmod-legacy/Makefile ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.12 \ No newline at end of property +1.13 \ No newline at end of property Index: head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c =================================================================== --- head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (nonexistent) +++ head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (revision 245451) @@ -0,0 +1,11 @@ +--- src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c.orig 2009-12-07 12:20:44.000000000 +0100 ++++ src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c 2009-12-07 12:21:00.000000000 +0100 +@@ -92,7 +92,7 @@ + DECLARE_MODULE(vboxnetadp, g_VBoxNetAdpFreeBSDModule, SI_SUB_PSEUDO, SI_ORDER_ANY); + MODULE_VERSION(vboxnetadp, 1); + MODULE_DEPEND(vboxnetadp, vboxdrv, 1, 1, 1); +-MODULE_DEPEND(vboxnetadp, ng_vboxnetflt, 1, 1, 1); ++MODULE_DEPEND(vboxnetadp, vboxnetflt, 1, 1, 1); + + /** + * Module event handler Property changes on: head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c =================================================================== --- head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c (revision 245450) +++ head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c (revision 245451) @@ -1,375 +1,384 @@ Index: src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c =================================================================== --- src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c (revision 23391) +++ src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c (working copy) @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -78,8 +80,6 @@ static ng_rcvdata_t ng_vboxnetflt_rcvdata; static ng_disconnect_t ng_vboxnetflt_disconnect; static int ng_vboxnetflt_mod_event(module_t mod, int event, void *data); -static int ng_vboxnetflt_rcv_in(hook_p node, item_p item); -static int ng_vboxnetflt_rcv_out(hook_p node, item_p item); /** Netgraph node type */ #define NG_VBOXNETFLT_NODE_TYPE "vboxnetflt" @@ -112,8 +112,8 @@ { .version = NG_ABI_VERSION, .name = NG_VBOXNETFLT_NODE_TYPE, - .mod_event = vboxnetflt_modevent, - .constructor = ng_vboxnetflt_constructor, + .mod_event = vboxnetflt_modevent, + .constructor = ng_vboxnetflt_constructor, .rcvmsg = ng_vboxnetflt_rcvmsg, .shutdown = ng_vboxnetflt_shutdown, .newhook = ng_vboxnetflt_newhook, +@@ -122,7 +122,7 @@ + .cmdlist = ng_vboxnetflt_cmdlist, + }; + NETGRAPH_INIT(vboxnetflt, &ng_vboxnetflt_typestruct); +-MODULE_VERSION(ng_vboxnetflt, 1); ++MODULE_VERSION(vboxnetflt, 1); + MODULE_DEPEND(ng_vboxnetflt, vboxdrv, 1, 1, 1); + + /** @@ -267,16 +267,12 @@ if (strcmp(name, NG_VBOXNETFLT_HOOK_IN) == 0) { #if __FreeBSD_version >= 800000 - NG_HOOK_SET_RCVDATA(hook, ng_vboxnetflt_rcv_in); NG_HOOK_SET_TO_INBOUND(hook); #endif pThis->u.s.input = hook; } else if (strcmp(name, NG_VBOXNETFLT_HOOK_OUT) == 0) { -#if __FreeBSD_version >= 800000 - NG_HOOK_SET_RCVDATA(hook, ng_vboxnetflt_rcv_out); -#endif pThis->u.s.output = hook; } else @@ -310,161 +306,171 @@ /** * Handle data on netgraph hooks. + * Frames processing is deferred to a taskqueue because this might + * be called with non-sleepable locks held and code paths inside + * the virtual switch might sleep. */ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p item) { const node_p node = NG_HOOK_NODE(hook); PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); + struct ifnet *ifp = pThis->u.s.ifp; struct mbuf *m; + struct m_tag *mtag; + bool fActive; + fActive = ASMAtomicUoReadBool(&pThis->fActive); + + NGI_GET_M(item, m); + NG_FREE_ITEM(item); + + /* Locate tag to see if processing should be skipped for this frame */ + mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); + if (mtag != NULL) + { + m_tag_unlink(m, mtag); + m_tag_free(mtag); + } + + /* + * Handle incoming hook. This is connected to the + * input path of the interface, thus handling incoming frames. + */ if (pThis->u.s.input == hook) - return ng_vboxnetflt_rcv_in(hook, item); + { + if (mtag != NULL || !fActive) + { + ether_demux(ifp, m); + return (0); + } + mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); + _IF_ENQUEUE(&pThis->u.s.inq, m); + mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); + taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskin); + } + /** + * Handle mbufs on the outgoing hook, frames going to the interface + */ else if (pThis->u.s.output == hook) - return ng_vboxnetflt_rcv_out(hook, item); + { + if (mtag != NULL || !fActive) + return ether_output_frame(ifp, m); + mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); + _IF_ENQUEUE(&pThis->u.s.outq, m); + mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); + taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskout); + } else { - NGI_GET_M(item, m); - NG_FREE_ITEM(item); + m_freem(m); } return (0); } +static int ng_vboxnetflt_shutdown(node_p node) +{ + PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); + bool fActive; + + /* Prevent node shutdown if we're active */ + fActive = ASMAtomicUoReadBool(&pThis->fActive); + if (fActive) + return (EBUSY); + NG_NODE_UNREF(node); + return (0); +} + +static int ng_vboxnetflt_disconnect(hook_p hook) +{ + return (0); +} + /** - * Handle incoming hook. This is connected to the - * input path of the interface, thus handling incoming frames. + * Input processing task, handles incoming frames */ -static int ng_vboxnetflt_rcv_in(hook_p hook, item_p item) +static void vboxNetFltFreeBSDinput(void *arg, int pending) { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; struct mbuf *m, *m0; - struct m_tag *mtag; - const node_p node = NG_HOOK_NODE(hook); - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); struct ifnet *ifp = pThis->u.s.ifp; - bool fActive, fDropIt = false; unsigned int cSegs = 0; + bool fDropIt = false, fActive; PINTNETSG pSG; - NGI_GET_M(item, m); - NG_FREE_ITEM(item); - - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (!fActive) - goto out; - - mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); - if (mtag != NULL) - { - m_tag_unlink(m, mtag); - m_tag_free(mtag); - goto out; - } vboxNetFltRetain(pThis, true /* fBusy */); - - for (m0 = m; m0 != NULL; m0 = m0->m_next) + for (;;) { - if (m0->m_len > 0) - cSegs++; - } + mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); + _IF_DEQUEUE(&pThis->u.s.inq, m); + mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); + if (m == NULL) + break; + for (m0 = m; m0 != NULL; m0 = m0->m_next) + if (m0->m_len > 0) + cSegs++; + #ifdef PADD_RUNT_FRAMES_FROM_HOST - if (m_length(m, NULL) < 60) - cSegs++; + if (m_length(m, NULL) < 60) + cSegs++; #endif - /* Create a copy of the mbuf and hand it to the virtual switch */ - pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); - vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); - fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_WIRE); - RTMemTmpFree(pSG); + /* Create a copy and deliver to the virtual switch */ + pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); + vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); + fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); + RTMemTmpFree(pSG); + if (fDropIt) + m_freem(m); + else + ether_demux(ifp, m); + } vboxNetFltRelease(pThis, true /* fBusy */); - -out: - /* Only deliver it to the host stack if the destination weren't a guest */ - if (fDropIt) - { - m_freem(m); - return (0); - } - ether_demux(ifp, m); - return (0); } /** - * Handle mbufs on the outgoing hook, frames going to the interface + * Output processing task, handles outgoing frames */ -static int ng_vboxnetflt_rcv_out(hook_p hook, item_p item) +static void vboxNetFltFreeBSDoutput(void *arg, int pending) { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; struct mbuf *m, *m0; - struct m_tag *mtag; - const node_p node = NG_HOOK_NODE(hook); - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); struct ifnet *ifp = pThis->u.s.ifp; unsigned int cSegs = 0; bool fDropIt = false, fActive; PINTNETSG pSG; - NGI_GET_M(item, m); - NG_FREE_ITEM(item); - - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (!fActive) - return ether_output_frame(ifp, m); - vboxNetFltRetain(pThis, true /* fBusy */); - /* Pass directly to interface if the packet originated from us */ - mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); - if (mtag != NULL) + for (;;) { - m_tag_unlink(m, mtag); - m_tag_free(mtag); - goto out; - } + mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); + _IF_DEQUEUE(&pThis->u.s.outq, m); + mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); + if (m == NULL) + break; - for (m0 = m; m0 != NULL; m0 = m0->m_next) - { - if (m0->m_len > 0) - cSegs++; - } + for (m0 = m; m0 != NULL; m0 = m0->m_next) + if (m0->m_len > 0) + cSegs++; #ifdef PADD_RUNT_FRAMES_FROM_HOST - if (m_length(m, NULL) < 60) - cSegs++; + if (m_length(m, NULL) < 60) + cSegs++; #endif - /* Create a copy and deliver to the virtual switch */ - pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); - vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); - fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); - RTMemTmpFree(pSG); + /* Create a copy and deliver to the virtual switch */ + pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); + vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); + fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); + RTMemTmpFree(pSG); -out: + if (fDropIt) + m_freem(m); + else + ether_output_frame(ifp, m); + } vboxNetFltRelease(pThis, true /* fBusy */); - if (fDropIt) - { - m_freem(m); - return (0); - } - - return ether_output_frame(ifp, m); } -static int ng_vboxnetflt_shutdown(node_p node) -{ - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); - bool fActive; - - /* Prevent node shutdown if we're active */ - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (fActive) - return (EBUSY); - NG_NODE_UNREF(node); - return (0); -} - -static int ng_vboxnetflt_disconnect(hook_p hook) -{ - return (0); -} - /** * Called to deliver a frame to either the host, the wire or both. */ @@ -536,13 +542,23 @@ /* Create a new netgraph node for this instance */ if (ng_make_node_common(&ng_vboxnetflt_typestruct, &node) != 0) - return VERR_INTERNAL_ERROR; + return VERR_INTERNAL_ERROR; RTSpinlockAcquire(pThis->hSpinlock, &Tmp); ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.ifp, ifp); pThis->u.s.node = node; bcopy(IF_LLADDR(ifp), &pThis->u.s.Mac, ETHER_ADDR_LEN); ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false); + /* Initialize deferred input queue */ + bzero(&pThis->u.s.inq, sizeof(struct ifqueue)); + mtx_init(&pThis->u.s.inq.ifq_mtx, "vboxnetflt inq", NULL, MTX_SPIN); + TASK_INIT(&pThis->u.s.tskin, 0, vboxNetFltFreeBSDinput, pThis); + + /* Initialize deferred output queue */ + bzero(&pThis->u.s.outq, sizeof(struct ifqueue)); + mtx_init(&pThis->u.s.outq.ifq_mtx, "vboxnetflt outq", NULL, MTX_SPIN); + TASK_INIT(&pThis->u.s.tskout, 0, vboxNetFltFreeBSDoutput, pThis); + RTSpinlockRelease(pThis->hSpinlock, &Tmp); NG_NODE_SET_PRIVATE(node, pThis); @@ -571,7 +587,10 @@ } if (ifp0 != NULL) + { + vboxNetFltOsDeleteInstance(pThis); vboxNetFltOsInitInstance(pThis, NULL); + } return !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost); } @@ -579,6 +598,12 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) { + taskqueue_drain(taskqueue_fast, &pThis->u.s.tskin); + taskqueue_drain(taskqueue_fast, &pThis->u.s.tskout); + + mtx_destroy(&pThis->u.s.inq.ifq_mtx); + mtx_destroy(&pThis->u.s.outq.ifq_mtx); + if (pThis->u.s.node != NULL) ng_rmnode_self(pThis->u.s.node); pThis->u.s.node = NULL; Property changes on: head/emulators/virtualbox-ose-kmod-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.1 \ No newline at end of property +1.2 \ No newline at end of property Index: head/emulators/virtualbox-ose-legacy/Makefile =================================================================== --- head/emulators/virtualbox-ose-legacy/Makefile (revision 245450) +++ head/emulators/virtualbox-ose-legacy/Makefile (revision 245451) @@ -1,259 +1,259 @@ # New ports collection makefile for: virtualbox # Date created: 2009-05-02 # Whom: Bernhard Froehlich # # $FreeBSD$ # PORTNAME= virtualbox DISTVERSION= 3.0.51r22902 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= emulators kld MASTER_SITES= http://tmp.chruetertee.ch/ \ http://freebsd.unixfreunde.de/sources/ \ http://disasterarea.chruetertee.ch/ \ http://mirror.4bit.ws/ \ http://dlc.sun.com/virtualbox/${VBOX_GUEST_VER}/:guestadditions DISTFILES= ${DISTNAME}${EXTRACT_SUFX} ${GADISTFILES} EXTRACT_ONLY= ${DISTNAME}${EXTRACT_SUFX} #for discussion please use emulation@FreeBSD.org MAINTAINER= vbox@FreeBSD.org COMMENT= A general-purpose full virtualizer for x86 hardware BUILD_DEPENDS= yasm:${PORTSDIR}/devel/yasm \ as86:${PORTSDIR}/devel/dev86 \ xsltproc:${PORTSDIR}/textproc/libxslt \ kmk:${PORTSDIR}/devel/kBuild LIB_DEPENDS= png.5:${PORTSDIR}/graphics/png \ xslt.2:${PORTSDIR}/textproc/libxslt \ curl.5:${PORTSDIR}/ftp/curl ONLY_FOR_ARCHS= i386 amd64 USE_GNOME= libidl USE_CDRTOOLS= yes USE_BZIP2= yes USE_PYTHON= yes USE_PYDISTUTILS= easy_install PYDISTUTILS_PKGNAME= vboxapi PYDISTUTILS_PKGVERSION= 1.0 PYDISTUTILS_NOEGGINFO= yes HAS_CONFIGURE= yes CONFIGURE_ARGS+=--with-gcc="${CC}" --with-g++="${CXX}" USE_LDCONFIG= ${PREFIX}/lib/virtualbox CONFLICTS= bcc-[0-9]* VBOXGROUP?= vboxusers VBOXGID?= 920 VBOX_FRONTENDS= VBoxHeadless VBOX_GUEST_VER= 3.0.6 SUB_FILES= pkg-install SUB_LIST= PREFIX=${PREFIX} \ VBOXGROUP=${VBOXGROUP} \ VBOXGID=${VBOXGID} OPTIONS= QT4 "Build with QT4 Frontend" on \ DEBUG "Build with debugging symbols" off \ GUESTADDITIONS "Build with Guest Additions" off \ DBUS "Build with D-Bus and HAL support" on \ PULSEAUDIO "Build with PulseAudio" off \ X11 "Build with X11 support" on \ NLS "Native language support" on .include PLIST_SUB+= KMODDIR=${KMODDIR:C,^/,,} \ PYTHON_VER=${PYTHON_VER} \ PYTHON_VERU=${PYTHON_VER:S/./_/} \ GUEST_VER=${VBOX_GUEST_VER} KMODDIR= /boot/modules KMK_BUILDTYPE= release KMK_CONFIG= VBOX_LIBPATH_X11=${LOCALBASE} VBOX_FREEBSD_SRC=${SRC_BASE}/sys KMK_FLAGS= .if defined(WITHOUT_QT4) && !defined(WITHOUT_NLS) BROKEN= NLS support requires QT4 frontend. Run 'make config' again! .endif .if defined(WITHOUT_X11) && !defined(WITHOUT_QT4) BROKEN= QT4 frontend requires X11 support. Run 'make config' again! .endif .if !defined(WITHOUT_X11) USE_SDL= sdl USE_XORG= xcursor xmu VBOX_FRONTENDS+=VBoxBFE VBoxSDL VBoxTestOGL PLIST_SUB+= X11="" .else CONFIGURE_ARGS+=--build-headless PLIST_SUB+= X11="@comment " .endif .if !defined(WITHOUT_QT4) USE_QT_VER= 4 QT_NONSTANDARD= yes QT_COMPONENTS= gui network moc_build uic_build rcc_build linguist INSTALLS_ICONS= yes VBOX_FRONTENDS+=VirtualBox PLIST_SUB+= QT4="" .else CONFIGURE_ARGS+=--disable-qt4 PLIST_SUB+= QT4="@comment " .endif .if defined(WITH_GUESTADDITIONS) GUESTADDITIONS= VBoxGuestAdditions_${VBOX_GUEST_VER}.iso GADISTFILES= ${GUESTADDITIONS}:guestadditions RESTRICTED= for personal use only RESTRICTED_FILES= ${GUESTADDITIONS} FETCH_ARGS= -pRr PLIST_SUB+= GUESTADDITIONS="" .else PLIST_SUB+= GUESTADDITIONS="@comment " .endif .if defined(WITH_DEBUG) KMK_FLAGS+= BUILD_TYPE=debug KMK_BUILDTYPE= debug .endif .if !defined(WITHOUT_DBUS) LIB_DEPENDS+= dbus-1.3:${PORTSDIR}/devel/dbus .else CONFIGURE_ARGS+=--disable-dbus .endif .if !defined(WITH_PULSEAUDIO) CONFIGURE_ARGS+=--disable-pulse .endif .if !defined(WITHOUT_NLS) PLIST_SUB+= NLS="" .else PLIST_SUB+= NLS="@comment " .endif .if !exists(${SRC_BASE}/sys/kern/bus_if.m) IGNORE= requires kernel sources for the kernel module .endif .if ${OSVERSION} < 700000 BROKEN= Does not compile on FreeBSD 6.X .endif .if ${ARCH} == i386 KMK_ARCH= freebsd.x86 PLIST_SUB+= I386="" .else KMK_ARCH= freebsd.${ARCH} PLIST_SUB+= I386="@comment " .endif .include pre-everything:: .if ${ARCH} == "amd64" .if !exists(/usr/lib32) @${ECHO} 'Requires 32-bit libraries installed under /usr/lib32.' @${ECHO} 'Do: cd /usr/src; make build32 install32; ldconfig -v -m -R /usr/lib32' @${FALSE} .endif .endif post-patch: @${ECHO} 'VBOX_PATH_APP_PRIVATE_ARCH = ${PREFIX}/lib/virtualbox' > ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_SHARED_LIBS = ${PREFIX}/lib/virtualbox' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_RUNPATH = ${PREFIX}/lib/virtualbox' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_APP_PRIVATE = ${DATADIR}' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_PATH_APP_DOCS = ${DOCSDIR}' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_INSTALLER = 1' >> ${WRKSRC}/LocalConfig.kmk @${ECHO} 'VBOX_WITH_TESTCASES=' >> ${WRKSRC}/LocalConfig.kmk .if defined(WITHOUT_X11) @${ECHO} 'VBOX_WITH_X11_ADDITIONS=' >> ${WRKSRC}/LocalConfig.kmk .endif @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \ ${WRKSRC}/Config.kmk ${WRKSRC}/configure \ ${WRKSRC}/kBuild/units/qt3.kmk ${WRKSRC}/kBuild/units/qt4.kmk \ ${WRKSRC}/kBuild/sdks/LIBSDL.kmk \ ${WRKSRC}/src/libs/xpcom18a4/python/gen_python_deps.py @${REINPLACE_CMD} -e 's|\$$KBUILDDIR_BIN/kmk_sed|${PREFIX}/bin/kmk_sed|g' ${WRKSRC}/configure pre-build: @${REINPLACE_CMD} -e 's|/bin/bash|/bin/sh|' \ ${WRKSRC}/env.sh do-build: cd ${WRKSRC} && ${SH} env.sh && ${KMK_CONFIG} ${LOCALBASE}/bin/kmk ${KMK_FLAGS} do-install: ${MKDIR} ${KMODDIR} .for f in vboxdrv.ko vboxnetadp.ko vboxnetflt.ko ${INSTALL_KLD} ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/${f} ${KMODDIR} .endfor ${MKDIR} ${DATADIR} (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom && ${COPYTREE_SHARE} "idl samples" ${DATADIR}) ${MKDIR} ${PREFIX}/include/virtualbox (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom/include && ${COPYTREE_SHARE} "*" ${PREFIX}/include/virtualbox) ${MKDIR} ${PREFIX}/lib/virtualbox (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin && ${COPYTREE_SHARE} "*.so *.gc *.r0 components" ${PREFIX}/lib/virtualbox) .if !defined(WITHOUT_NLS) ${MKDIR} ${DATADIR}/nls (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/obj/VirtualBox/qtnls && ${COPYTREE_SHARE} "*.qm" ${DATADIR}/nls) .endif ${MKDIR} ${PREFIX}/bin .for f in VBoxManage VBoxNetAdpCtl VBoxNetDHCP VBoxSVC VBoxXPCOMIPCD ${VBOX_FRONTENDS} ${INSTALL_PROGRAM} ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/${f} ${PREFIX}/lib/virtualbox/ ${LN} -sf ${PREFIX}/lib/virtualbox/${f} ${PREFIX}/bin/ .endfor .for f in VBoxNetAdpCtl VBoxNetDHCP ${VBOX_FRONTENDS} ${CHMOD} 4511 ${PREFIX}/lib/virtualbox/${f} .endfor .for f in VBoxManage VBoxSVC VBoxXPCOMIPCD ${CHMOD} 0711 ${PREFIX}/lib/virtualbox/${f} .endfor .if defined(WITH_GUESTADDITIONS) ${MKDIR} ${PREFIX}/lib/virtualbox/additions ${INSTALL_DATA} ${DISTDIR}/${GUESTADDITIONS} ${PREFIX}/lib/virtualbox/additions/ ${LN} -sf ${PREFIX}/lib/virtualbox/additions/${GUESTADDITIONS} ${PREFIX}/lib/virtualbox/additions/VBoxGuestAdditions.iso .endif cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/installer && \ VBOX_INSTALL_PATH="${PREFIX}/lib/virtualbox" ${PYTHON_CMD} vboxapisetup.py install @${MKDIR} ${PYTHON_SITELIBDIR} (cd ${WRKSRC}/out/${KMK_ARCH}/${KMK_BUILDTYPE}/bin/sdk/bindings/xpcom/python && ${COPYTREE_SHARE} "*" ${PYTHON_SITELIBDIR}) ${PYTHON_CMD} -mcompileall ${PYTHON_SITELIBDIR}/xpcom/ post-install: @${SETENV} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .for f in VBoxManage VBoxNetDHCP VBoxSVC VBoxXPCOMIPCD ${VBOX_FRONTENDS} ${CHOWN} root:${VBOXGROUP} ${PREFIX}/lib/virtualbox/${f} .endfor @${FIND} ${DATADIR} -type d -print0 | ${XARGS} -0 ${CHMOD} 755 @${FIND} ${PREFIX}/include/virtualbox -type d -print0 | ${XARGS} -0 ${CHMOD} 755 @${FIND} ${PREFIX}/lib/virtualbox -type d -print0 | ${XARGS} -0 ${CHMOD} 755 .if !defined(WITHOUT_QT4) ${MKDIR} ${PREFIX}/share/icons/hicolor/48x48/apps/ ${INSTALL_DATA} ${WRKSRC}/src/VBox/Frontends/VirtualBox/images/OSE/VirtualBox_48px.png ${PREFIX}/share/icons/hicolor/48x48/apps/VBox.png ${MKDIR} ${PREFIX}/share/applications/ ${INSTALL_DATA} ${WRKSRC}/src/VBox/Installer/solaris/virtualbox.desktop ${PREFIX}/share/applications/virtualbox.desktop .endif @${CAT} ${PKGMESSAGE} .include Property changes on: head/emulators/virtualbox-ose-legacy/Makefile ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.12 \ No newline at end of property +1.13 \ No newline at end of property Index: head/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c =================================================================== --- head/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (nonexistent) +++ head/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c (revision 245451) @@ -0,0 +1,11 @@ +--- src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c.orig 2009-12-07 12:20:44.000000000 +0100 ++++ src/VBox/HostDrivers/VBoxNetAdp/freebsd/VBoxNetAdp-freebsd.c 2009-12-07 12:21:00.000000000 +0100 +@@ -92,7 +92,7 @@ + DECLARE_MODULE(vboxnetadp, g_VBoxNetAdpFreeBSDModule, SI_SUB_PSEUDO, SI_ORDER_ANY); + MODULE_VERSION(vboxnetadp, 1); + MODULE_DEPEND(vboxnetadp, vboxdrv, 1, 1, 1); +-MODULE_DEPEND(vboxnetadp, ng_vboxnetflt, 1, 1, 1); ++MODULE_DEPEND(vboxnetadp, vboxnetflt, 1, 1, 1); + + /** + * Module event handler Property changes on: head/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetAdp-freebsd-VBoxNetAdp-freebsd.c ___________________________________________________________________ Added: cvs2svn:cvs-rev ## -0,0 +1 ## +1.1 \ No newline at end of property Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Index: head/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c =================================================================== --- head/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c (revision 245450) +++ head/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c (revision 245451) @@ -1,375 +1,384 @@ Index: src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c =================================================================== --- src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c (revision 23391) +++ src/VBox/HostDrivers/VBoxNetFlt/freebsd/VBoxNetFlt-freebsd.c (working copy) @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -78,8 +80,6 @@ static ng_rcvdata_t ng_vboxnetflt_rcvdata; static ng_disconnect_t ng_vboxnetflt_disconnect; static int ng_vboxnetflt_mod_event(module_t mod, int event, void *data); -static int ng_vboxnetflt_rcv_in(hook_p node, item_p item); -static int ng_vboxnetflt_rcv_out(hook_p node, item_p item); /** Netgraph node type */ #define NG_VBOXNETFLT_NODE_TYPE "vboxnetflt" @@ -112,8 +112,8 @@ { .version = NG_ABI_VERSION, .name = NG_VBOXNETFLT_NODE_TYPE, - .mod_event = vboxnetflt_modevent, - .constructor = ng_vboxnetflt_constructor, + .mod_event = vboxnetflt_modevent, + .constructor = ng_vboxnetflt_constructor, .rcvmsg = ng_vboxnetflt_rcvmsg, .shutdown = ng_vboxnetflt_shutdown, .newhook = ng_vboxnetflt_newhook, +@@ -122,7 +122,7 @@ + .cmdlist = ng_vboxnetflt_cmdlist, + }; + NETGRAPH_INIT(vboxnetflt, &ng_vboxnetflt_typestruct); +-MODULE_VERSION(ng_vboxnetflt, 1); ++MODULE_VERSION(vboxnetflt, 1); + MODULE_DEPEND(ng_vboxnetflt, vboxdrv, 1, 1, 1); + + /** @@ -267,16 +267,12 @@ if (strcmp(name, NG_VBOXNETFLT_HOOK_IN) == 0) { #if __FreeBSD_version >= 800000 - NG_HOOK_SET_RCVDATA(hook, ng_vboxnetflt_rcv_in); NG_HOOK_SET_TO_INBOUND(hook); #endif pThis->u.s.input = hook; } else if (strcmp(name, NG_VBOXNETFLT_HOOK_OUT) == 0) { -#if __FreeBSD_version >= 800000 - NG_HOOK_SET_RCVDATA(hook, ng_vboxnetflt_rcv_out); -#endif pThis->u.s.output = hook; } else @@ -310,161 +306,171 @@ /** * Handle data on netgraph hooks. + * Frames processing is deferred to a taskqueue because this might + * be called with non-sleepable locks held and code paths inside + * the virtual switch might sleep. */ static int ng_vboxnetflt_rcvdata(hook_p hook, item_p item) { const node_p node = NG_HOOK_NODE(hook); PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); + struct ifnet *ifp = pThis->u.s.ifp; struct mbuf *m; + struct m_tag *mtag; + bool fActive; + fActive = ASMAtomicUoReadBool(&pThis->fActive); + + NGI_GET_M(item, m); + NG_FREE_ITEM(item); + + /* Locate tag to see if processing should be skipped for this frame */ + mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); + if (mtag != NULL) + { + m_tag_unlink(m, mtag); + m_tag_free(mtag); + } + + /* + * Handle incoming hook. This is connected to the + * input path of the interface, thus handling incoming frames. + */ if (pThis->u.s.input == hook) - return ng_vboxnetflt_rcv_in(hook, item); + { + if (mtag != NULL || !fActive) + { + ether_demux(ifp, m); + return (0); + } + mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); + _IF_ENQUEUE(&pThis->u.s.inq, m); + mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); + taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskin); + } + /** + * Handle mbufs on the outgoing hook, frames going to the interface + */ else if (pThis->u.s.output == hook) - return ng_vboxnetflt_rcv_out(hook, item); + { + if (mtag != NULL || !fActive) + return ether_output_frame(ifp, m); + mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); + _IF_ENQUEUE(&pThis->u.s.outq, m); + mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); + taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskout); + } else { - NGI_GET_M(item, m); - NG_FREE_ITEM(item); + m_freem(m); } return (0); } +static int ng_vboxnetflt_shutdown(node_p node) +{ + PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); + bool fActive; + + /* Prevent node shutdown if we're active */ + fActive = ASMAtomicUoReadBool(&pThis->fActive); + if (fActive) + return (EBUSY); + NG_NODE_UNREF(node); + return (0); +} + +static int ng_vboxnetflt_disconnect(hook_p hook) +{ + return (0); +} + /** - * Handle incoming hook. This is connected to the - * input path of the interface, thus handling incoming frames. + * Input processing task, handles incoming frames */ -static int ng_vboxnetflt_rcv_in(hook_p hook, item_p item) +static void vboxNetFltFreeBSDinput(void *arg, int pending) { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; struct mbuf *m, *m0; - struct m_tag *mtag; - const node_p node = NG_HOOK_NODE(hook); - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); struct ifnet *ifp = pThis->u.s.ifp; - bool fActive, fDropIt = false; unsigned int cSegs = 0; + bool fDropIt = false, fActive; PINTNETSG pSG; - NGI_GET_M(item, m); - NG_FREE_ITEM(item); - - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (!fActive) - goto out; - - mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); - if (mtag != NULL) - { - m_tag_unlink(m, mtag); - m_tag_free(mtag); - goto out; - } vboxNetFltRetain(pThis, true /* fBusy */); - - for (m0 = m; m0 != NULL; m0 = m0->m_next) + for (;;) { - if (m0->m_len > 0) - cSegs++; - } + mtx_lock_spin(&pThis->u.s.inq.ifq_mtx); + _IF_DEQUEUE(&pThis->u.s.inq, m); + mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx); + if (m == NULL) + break; + for (m0 = m; m0 != NULL; m0 = m0->m_next) + if (m0->m_len > 0) + cSegs++; + #ifdef PADD_RUNT_FRAMES_FROM_HOST - if (m_length(m, NULL) < 60) - cSegs++; + if (m_length(m, NULL) < 60) + cSegs++; #endif - /* Create a copy of the mbuf and hand it to the virtual switch */ - pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); - vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); - fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_WIRE); - RTMemTmpFree(pSG); + /* Create a copy and deliver to the virtual switch */ + pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); + vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); + fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); + RTMemTmpFree(pSG); + if (fDropIt) + m_freem(m); + else + ether_demux(ifp, m); + } vboxNetFltRelease(pThis, true /* fBusy */); - -out: - /* Only deliver it to the host stack if the destination weren't a guest */ - if (fDropIt) - { - m_freem(m); - return (0); - } - ether_demux(ifp, m); - return (0); } /** - * Handle mbufs on the outgoing hook, frames going to the interface + * Output processing task, handles outgoing frames */ -static int ng_vboxnetflt_rcv_out(hook_p hook, item_p item) +static void vboxNetFltFreeBSDoutput(void *arg, int pending) { + PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg; struct mbuf *m, *m0; - struct m_tag *mtag; - const node_p node = NG_HOOK_NODE(hook); - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); struct ifnet *ifp = pThis->u.s.ifp; unsigned int cSegs = 0; bool fDropIt = false, fActive; PINTNETSG pSG; - NGI_GET_M(item, m); - NG_FREE_ITEM(item); - - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (!fActive) - return ether_output_frame(ifp, m); - vboxNetFltRetain(pThis, true /* fBusy */); - /* Pass directly to interface if the packet originated from us */ - mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL); - if (mtag != NULL) + for (;;) { - m_tag_unlink(m, mtag); - m_tag_free(mtag); - goto out; - } + mtx_lock_spin(&pThis->u.s.outq.ifq_mtx); + _IF_DEQUEUE(&pThis->u.s.outq, m); + mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx); + if (m == NULL) + break; - for (m0 = m; m0 != NULL; m0 = m0->m_next) - { - if (m0->m_len > 0) - cSegs++; - } + for (m0 = m; m0 != NULL; m0 = m0->m_next) + if (m0->m_len > 0) + cSegs++; #ifdef PADD_RUNT_FRAMES_FROM_HOST - if (m_length(m, NULL) < 60) - cSegs++; + if (m_length(m, NULL) < 60) + cSegs++; #endif - /* Create a copy and deliver to the virtual switch */ - pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); - vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); - fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); - RTMemTmpFree(pSG); + /* Create a copy and deliver to the virtual switch */ + pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs])); + vboxNetFltFreeBSDMBufToSG(pThis, m, pSG, cSegs, 0); + fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, pSG, INTNETTRUNKDIR_HOST); + RTMemTmpFree(pSG); -out: + if (fDropIt) + m_freem(m); + else + ether_output_frame(ifp, m); + } vboxNetFltRelease(pThis, true /* fBusy */); - if (fDropIt) - { - m_freem(m); - return (0); - } - - return ether_output_frame(ifp, m); } -static int ng_vboxnetflt_shutdown(node_p node) -{ - PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node); - bool fActive; - - /* Prevent node shutdown if we're active */ - fActive = ASMAtomicUoReadBool(&pThis->fActive); - if (fActive) - return (EBUSY); - NG_NODE_UNREF(node); - return (0); -} - -static int ng_vboxnetflt_disconnect(hook_p hook) -{ - return (0); -} - /** * Called to deliver a frame to either the host, the wire or both. */ @@ -536,13 +542,23 @@ /* Create a new netgraph node for this instance */ if (ng_make_node_common(&ng_vboxnetflt_typestruct, &node) != 0) - return VERR_INTERNAL_ERROR; + return VERR_INTERNAL_ERROR; RTSpinlockAcquire(pThis->hSpinlock, &Tmp); ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.ifp, ifp); pThis->u.s.node = node; bcopy(IF_LLADDR(ifp), &pThis->u.s.Mac, ETHER_ADDR_LEN); ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false); + /* Initialize deferred input queue */ + bzero(&pThis->u.s.inq, sizeof(struct ifqueue)); + mtx_init(&pThis->u.s.inq.ifq_mtx, "vboxnetflt inq", NULL, MTX_SPIN); + TASK_INIT(&pThis->u.s.tskin, 0, vboxNetFltFreeBSDinput, pThis); + + /* Initialize deferred output queue */ + bzero(&pThis->u.s.outq, sizeof(struct ifqueue)); + mtx_init(&pThis->u.s.outq.ifq_mtx, "vboxnetflt outq", NULL, MTX_SPIN); + TASK_INIT(&pThis->u.s.tskout, 0, vboxNetFltFreeBSDoutput, pThis); + RTSpinlockRelease(pThis->hSpinlock, &Tmp); NG_NODE_SET_PRIVATE(node, pThis); @@ -571,7 +587,10 @@ } if (ifp0 != NULL) + { + vboxNetFltOsDeleteInstance(pThis); vboxNetFltOsInitInstance(pThis, NULL); + } return !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost); } @@ -579,6 +598,12 @@ void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis) { + taskqueue_drain(taskqueue_fast, &pThis->u.s.tskin); + taskqueue_drain(taskqueue_fast, &pThis->u.s.tskout); + + mtx_destroy(&pThis->u.s.inq.ifq_mtx); + mtx_destroy(&pThis->u.s.outq.ifq_mtx); + if (pThis->u.s.node != NULL) ng_rmnode_self(pThis->u.s.node); pThis->u.s.node = NULL; Property changes on: head/emulators/virtualbox-ose-legacy/files/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c ___________________________________________________________________ Modified: cvs2svn:cvs-rev ## -1 +1 ## -1.1 \ No newline at end of property +1.2 \ No newline at end of property