VBoxNetFlt-solaris.c revision 5479e8692221a59f5ce441db9fe494c6c62601f2
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * VBoxNetFlt - Network Filter Driver (Host), Solaris Specific Code.
e99772f9bf09219c532812c859fbeea513c67e65vboxsync * Copyright (C) 2008 Sun Microsystems, Inc.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * available from http://www.virtualbox.org. This file is free software;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * General Public License (GPL) as published by the Free Software
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * additional information or have any questions.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync/*******************************************************************************
a299266cddc1ae14d76d725a660bb278816bc151vboxsync* Header Files *
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync*******************************************************************************/
a299266cddc1ae14d76d725a660bb278816bc151vboxsync#if defined(DEBUG_ramshankar) && !defined(LOG_ENABLED)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Experimental: Using netinfo interfaces and queuing out packets.
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync * This is for playing better with IPFilter.
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync// Workaround for very strange define in sys/user.h
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync// #define u (curproc->p_user) /* user is now part of proc structure */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync/*******************************************************************************
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync* Defined Constants And Macros *
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync*******************************************************************************/
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync/** The module name. */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync/** The module descriptions as seen in 'modinfo'. */
a299266cddc1ae14d76d725a660bb278816bc151vboxsync/** @todo Remove the below hackery once done! */
a299266cddc1ae14d76d725a660bb278816bc151vboxsync#if defined(DEBUG_ramshankar) && defined(LOG_ENABLED)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync/** Maximum loopback packet queue size per interface */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync/*******************************************************************************
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync* Global Functions *
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync*******************************************************************************/
b2c35a7024c4c308b429c81b203b3bcbd44ee60cvboxsync * Stream Driver hooks.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int VBoxNetFltSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pArg, void **ppResult);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int VBoxNetFltSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd);
b2c35a7024c4c308b429c81b203b3bcbd44ee60cvboxsyncstatic int VBoxNetFltSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd);
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync * Stream Module hooks.
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsyncstatic int VBoxNetFltSolarisModOpen(queue_t *pQueue, dev_t *pDev, int fFile, int fStream, cred_t *pCred);
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsyncstatic int VBoxNetFltSolarisModClose(queue_t *pQueue, int fFile, cred_t *pCred);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int VBoxNetFltSolarisModReadPut(queue_t *pQueue, mblk_t *pMsg);
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsyncstatic int VBoxNetFltSolarisModWritePut(queue_t *pQueue, mblk_t *pMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * OS specific hooks invoked from common VBoxNetFlt ring-0.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync/** @todo r=bird: What are these doing here? */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncbool vboxNetFltPortOsIsPromiscuous(PVBOXNETFLTINS pThis);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncvoid vboxNetFltPortOsGetMacAddress(PVBOXNETFLTINS pThis, PRTMAC pMac);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncbool vboxNetFltPortOsIsHostMac(PVBOXNETFLTINS pThis, PCRTMAC pMac);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncvoid vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, bool fActive);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncvoid vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncint vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, void *pvContext);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncint vboxNetFltOsPreInitInstance(PVBOXNETFLTINS pThis);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync/*******************************************************************************
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync* Structures and Typedefs *
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync*******************************************************************************/
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync * Streams: module info.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsyncstatic struct module_info g_VBoxNetFltSolarisModInfo =
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync 0, /* min. packet size */
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync 0, /* hi-water mark */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync 0 /* lo-water mark */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Streams: read queue hooks.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Streams: write queue hooks.
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync * Streams: IO stream tab.
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsyncstatic struct streamtab g_VBoxNetFltSolarisStreamTab =
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * cb_ops: driver char/block entry points
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * dev_ops: driver entry/exit and other ops.
a8fd9edea57842da84a8bcf265a92eb5e96c9c4bvboxsync 0, /* ref count */
a8fd9edea57842da84a8bcf265a92eb5e96c9c4bvboxsync (struct bus_ops *)0,
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync * modldrv: export driver specifics to kernel
a8fd9edea57842da84a8bcf265a92eb5e96c9c4bvboxsync DEVICE_DESC_DRV " " VBOX_VERSION_STRING "r" VBOXSOLQUOTE(VBOX_SVN_REV),
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * fmodsw: streams module ops
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * modlstrmod: streams module specifics to kernel
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic struct modlstrmod g_VBoxNetFltSolarisModule =
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync DEVICE_DESC_MOD " " VBOX_VERSION_STRING "r" VBOXSOLQUOTE(VBOX_SVN_REV),
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * modlinkage: export install/remove/info to the kernel
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsyncstatic struct modlinkage g_VBoxNetFltSolarisModLinkage =
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync &g_VBoxNetFltSolarisDriver, /* streams driver framework */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync &g_VBoxNetFltSolarisModule, /* streams module framework */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * vboxnetflt_dladdr_t: DL SAP address format
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync#define VBOXNETFLT_DLADDRL sizeof(vboxnetflt_dladdr_t)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * which stream is this?
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * loopback packet identifier
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsynctypedef struct VBOXNETFLTPACKETID *PVBOXNETFLTPACKETID;
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * vboxnetflt_stream_t: per-stream data (multiple streams per interface)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync struct vboxnetflt_stream_t *pNext; /* next stream in list */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync PVBOXNETFLTINS volatile pThis; /* the backend instance */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync VBOXNETFLTSTREAMTYPE Type; /* the type of the stream */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * vboxnetflt_promisc_stream_t: per-interface dedicated stream data
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync vboxnetflt_stream_t Stream; /* The generic stream */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync bool fRawMode; /* whether raw mode request was successful */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync uint32_t ModeReqId; /* track MIOCTLs for swallowing our fake request acknowledgements */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync PVBOXNETFLTPACKETID pHead; /* loopback packet identifier head */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync PVBOXNETFLTPACKETID pTail; /* loopback packet identifier tail */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync/*******************************************************************************
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync* Internal Functions *
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync*******************************************************************************/
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisSetRawMode(vboxnetflt_promisc_stream_t *pPromiscStream);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync/* static int vboxNetFltSolarisSetFastMode(queue_t *pQueue); */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisPhysAddrReq(queue_t *pQueue);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic void vboxNetFltSolarisCachePhysAddr(PVBOXNETFLTINS pThis, mblk_t *pPhysAddrAckMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisBindReq(queue_t *pQueue, int SAP);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisNotifyReq(queue_t *pQueue);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisUnitDataToRaw(PVBOXNETFLTINS pThis, mblk_t *pMsg, mblk_t **ppRawMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisRawToUnitData(mblk_t *pMsg, mblk_t **ppDlpiMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic inline void vboxNetFltSolarisInitPacketId(PVBOXNETFLTPACKETID pTag, mblk_t *pMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisQueueLoopback(PVBOXNETFLTINS pThis, vboxnetflt_promisc_stream_t *pPromiscStream, mblk_t *pMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic bool vboxNetFltSolarisIsOurMBlk(PVBOXNETFLTINS pThis, vboxnetflt_promisc_stream_t *pPromiscStream, mblk_t *pMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic mblk_t *vboxNetFltSolarisMBlkFromSG(PVBOXNETFLTINS pThis, PINTNETSG pSG, uint32_t fDst);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic unsigned vboxNetFltSolarisMBlkCalcSGSegs(PVBOXNETFLTINS pThis, mblk_t *pMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisMBlkToSG(PVBOXNETFLTINS pThis, mblk_t *pMsg, PINTNETSG pSG, unsigned cSegs, uint32_t fSrc);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisRecv(PVBOXNETFLTINS pThis, vboxnetflt_stream_t *pStream, queue_t *pQueue, mblk_t *pMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic mblk_t *vboxNetFltSolarisFixChecksums(mblk_t *pMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic void vboxNetFltSolarisAnalyzeMBlk(mblk_t *pMsg);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync/*******************************************************************************
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync* Global Variables *
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync*******************************************************************************/
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync/** Global device info handle. */
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync/** The (common) global data. */
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsyncstatic VBOXNETFLTGLOBALS g_VBoxNetFltSolarisGlobals;
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync/** The list of all opened streams. */
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync/** Global mutex protecting open/close. */
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsyncstatic RTSEMFASTMUTEX g_VBoxNetFltSolarisMtx = NIL_RTSEMFASTMUTEX;
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * g_VBoxNetFltInstance is the current PVBOXNETFLTINS to be associated with the stream being created
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * in ModOpen. This is just shared global data between the dynamic attach and the ModOpen procedure.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsyncPVBOXNETFLTINS volatile g_VBoxNetFltSolarisInstance;
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync/** Goes along with the instance to determine type of stream being opened/created. */
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsyncVBOXNETFLTSTREAMTYPE volatile g_VBoxNetFltSolarisStreamType;
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync * Kernel entry points
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync * Prevent module autounloading.
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync modctl_t *pModCtl = mod_getctl(&g_VBoxNetFltSolarisModLinkage);
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync LogRel((DEVICE_NAME ":failed to disable autounloading!\n"));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Initialize IPRT.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Initialize Solaris specific globals here.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync int rc = RTSemFastMutexCreate(&g_VBoxNetFltSolarisMtx);
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Initialize the globals and connect to the support driver.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * This will call back vboxNetFltOsOpenSupDrv (and maybe vboxNetFltOsCloseSupDrv)
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * for establishing the connect to the support driver.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync memset(&g_VBoxNetFltSolarisGlobals, 0, sizeof(g_VBoxNetFltSolarisGlobals));
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltSolarisGlobals);
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync LogRel((DEVICE_NAME ":mod_install failed. rc=%d\n", rc));
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltSolarisGlobals);
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync LogRel((DEVICE_NAME ":failed to initialize globals.\n"));
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync LogRel((DEVICE_NAME ":failed to initialize IPRT (rc=%d)\n", rc));
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync memset(&g_VBoxNetFltSolarisGlobals, 0, sizeof(g_VBoxNetFltSolarisGlobals));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Undo the work done during start (in reverse order).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync rc = vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltSolarisGlobals);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync int rc = mod_info(&g_VBoxNetFltSolarisModLinkage, pModInfo);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Attach entry point, to attach a device to the system or resume it.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pDip The module structure instance.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param enmCmd Operation type (attach/resume).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @returns corresponding solaris error code.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int VBoxNetFltSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisAttach pDip=%p enmCmd=%d\n", pDip, enmCmd));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync int rc = ddi_create_minor_node(pDip, DEVICE_NAME, S_IFCHR, instance, DDI_PSEUDO, CLONE_DEV);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisAttach failed to create minor node. rc%d\n", rc));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync /* Nothing to do here... */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Detach entry point, to detach a device to the system or suspend it.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pDip The module structure instance.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param enmCmd Operation type (detach/suspend).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @returns corresponding solaris error code.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int VBoxNetFltSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisDetach pDip=%p enmCmd=%d\n", pDip, enmCmd));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync /* Nothing to do here... */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Info entry point, called by solaris kernel for obtaining driver info.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pDip The module structure instance (do not use).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param enmCmd Information request type.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pvArg Type specific argument.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param ppvResult Where to store the requested info.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @returns corresponding solaris error code.
ad27e1d5e48ca41245120c331cc88b50464813cevboxsyncstatic int VBoxNetFltSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, void **ppResult)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisGetInfo pDip=%p enmCmd=%d pArg=%p instance=%d\n", pDip, enmCmd,
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Stream module open entry point, initializes the queue and allows streams processing.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pQueue Pointer to the read queue (cannot be NULL).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pDev Pointer to the dev_t associated with the driver at the end of the stream.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param fOpenMode Open mode (always 0 for streams driver, thus ignored).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param fStreamMode Stream open mode.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pCred Pointer to user credentials.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @returns corresponding solaris error code.
a2d2faa1528d1752b2bb4da5469495fe5436e0f0vboxsyncstatic int VBoxNetFltSolarisModOpen(queue_t *pQueue, dev_t *pDev, int fOpenMode, int fStreamMode, cred_t *pCred)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModOpen pQueue=%p pDev=%p fOpenMode=%d fStreamMode=%d\n", pQueue, pDev,
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync int rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Already open?
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen invalid open.\n"));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Check for the VirtualBox instance.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync PVBOXNETFLTINS pThis = g_VBoxNetFltSolarisInstance;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen failed to get VirtualBox instance.\n"));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Check VirtualBox stream type.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen failed due to undefined VirtualBox open mode.\n"));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Get minor number. For clone opens provide a new dev_t.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync vboxnetflt_stream_t **ppPrevStream = &g_VBoxNetFltSolarisStreams;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync for (; (pStream = *ppPrevStream) != NULL; ppPrevStream = &pStream->pNext)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync if (g_VBoxNetFltSolarisStreamType == kPromiscStream)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync vboxnetflt_promisc_stream_t *pPromiscStream = RTMemAlloc(sizeof(vboxnetflt_promisc_stream_t));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen failed to allocate promiscuous stream data.\n"));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Allocate & initialize per-stream data. Hook it into the (read and write) queue's module specific data.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisModOpen failed to allocate stream data.\n"));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Pick up the current global VBOXNETFLTINS instance as
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * the one that we will associate this stream with.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync ASMAtomicUoWritePtr((void * volatile *)&pStream->pThis, pThis);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync case kIp4Stream: ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pvIp4Stream, pStream); break;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync case kIp6Stream: ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pvIp6Stream, pStream); break;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync case kArpStream: ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pvArpStream, pStream); break;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync case kPromiscStream: ASMAtomicUoWritePtr((void * volatile *)&pThis->u.s.pvPromiscStream, pStream); break;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync default: /* Heh. */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Link it to the list of streams.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Release global lock, & do not hold locks across putnext calls.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Don't hold the spinlocks across putnext calls as it could
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * (and does mostly) re-enter the put procedure on the same thread.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync vboxnetflt_promisc_stream_t *pPromiscStream = (vboxnetflt_promisc_stream_t *)pStream;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Bind to SAP 0 (DL_ETHER).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Note: We don't support DL_TPR (token passing ring) SAP as that is unnecessary asynchronous
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * work to get DL_INFO_REQ acknowledgements and determine SAP based on the Mac Type etc.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Besides TPR doesn't really exist anymore practically as far as I know.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync int rc = vboxNetFltSolarisBindReq(pStream->pReadQueue, 0 /* SAP */);
f285bb149147cccd6109e5487e744df17c04da82vboxsync * Request the physical address (we cache the acknowledgement).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync rc = vboxNetFltSolarisPhysAddrReq(pStream->pReadQueue);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Ask for DLPI link notifications, don't bother check for errors here.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Enable raw mode.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisSetRawMode failed rc=%Rrc.\n", rc));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisSetRawMode failed rc=%Rrc.\n", rc));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisBindReq failed rc=%Rrc.\n", rc));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModOpen returns 0, DevMinor=%d pQueue=%p\n", DevMinor, pStream->pReadQueue));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Stream module close entry point, undoes the work done on open and closes the stream.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pQueue Pointer to the read queue (cannot be NULL).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param fOpenMode Open mode (always 0 for streams driver, thus ignored).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pCred Pointer to user credentials.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @returns corresponding solaris error code.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int VBoxNetFltSolarisModClose(queue_t *pQueue, int fOpenMode, cred_t *pCred)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModClose pQueue=%p fOpenMode=%d\n", pQueue, fOpenMode));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync int rc = RTSemFastMutexRequest(g_VBoxNetFltSolarisMtx);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Get instance data.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisModClose failed to get stream.\n"));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync vboxNetFltRelease(pStream->pThis, false /* fBusy */);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync vboxnetflt_promisc_stream_t *pPromiscStream = (vboxnetflt_promisc_stream_t *)pStream;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync int rc = RTSemFastMutexRequest(pStream->pThis->u.s.hFastMtx);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Free-up loopback buffers.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync RTSemFastMutexRelease(pStream->pThis->u.s.hFastMtx);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Unlink it from the list of streams.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync for (ppPrevStream = &g_VBoxNetFltSolarisStreams; (pStream = *ppPrevStream) != NULL; ppPrevStream = &pStream->pNext)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync if (pStream == (vboxnetflt_stream_t *)pQueue->q_ptr)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Delete the stream.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync case kIp4Stream: ASMAtomicUoWritePtr(pStream->pThis->u.s.pvIp4Stream, NULL); break;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync case kIp6Stream: ASMAtomicUoWritePtr(pStream->pThis->u.s.pvIp6Stream, NULL); break;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync case kArpStream: ASMAtomicUoWritePtr(pStream->pThis->u.s.pvArpStream, NULL); break;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync case kPromiscStream: ASMAtomicUoWritePtr(pStream->pThis->u.s.pvPromiscStream, NULL); break;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync default: /* Heh. */
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync vboxNetFltRelease(pStream->pThis, false /* fBusy */);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Read side put procedure for processing messages in the read queue.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * All streams, bound and unbound share this read procedure.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pQueue Pointer to the read queue.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pMsg Pointer to the message.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @returns corresponding solaris error code.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int VBoxNetFltSolarisModReadPut(queue_t *pQueue, mblk_t *pMsg)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut pQueue=%p pMsg=%p\n", pQueue, pMsg));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * In the unlikely case where VirtualBox crashed and this filter
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * is somehow still in the host stream we must try not to panic the host.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync pThis = ASMAtomicUoReadPtr((void * volatile *)&pStream->pThis);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Retain the instance if we're filtering regardless of we are active or not
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * The reason being even when we are inactive we reference the instance (e.g
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * the promiscuous OFF acknowledgement case).
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync const bool fActive = ASMAtomicUoReadBool(&pThis->fActive);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync vboxnetflt_promisc_stream_t *pPromiscStream = (vboxnetflt_promisc_stream_t *)pStream;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut M_DATA\n"));
b2c35a7024c4c308b429c81b203b3bcbd44ee60cvboxsync vboxNetFltSolarisRecv(pThis, pStream, pQueue, pMsg);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync union DL_primitives *pPrim = (union DL_primitives *)pMsg->b_rptr;
b2c35a7024c4c308b429c81b203b3bcbd44ee60cvboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: M_PCPROTO %d\n", Prim));
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: Invalid notification size; expected>=%d got=%d\n",
b2c35a7024c4c308b429c81b203b3bcbd44ee60cvboxsync dl_notify_ind_t *pNotifyInd = (dl_notify_ind_t *)pMsg->b_rptr;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: DL_NOTE_PHYS_ADDR. Invalid offset/addr.\n"));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync bcopy(pMsg->b_rptr + cOffset, &pThis->u.s.Mac, sizeof(pThis->u.s.Mac));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: DL_NOTE_PHYS_ADDR. New Mac=%.*Rhxs\n",
a299266cddc1ae14d76d725a660bb278816bc151vboxsync const bool fDisconnected = ASMAtomicUoReadBool(&pThis->fActive);
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, false);
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: DL_NOTE_LINK_UP.\n"));
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync const bool fDisconnected = ASMAtomicUoReadBool(&pThis->fActive);
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, true);
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: DL_NOTE_LINK_DOWN.\n"));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Swallow our bind request acknowledgement.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: DL_BIND_ACK. Bound to requested SAP!\n"));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Swallow our physical address request acknowledgement.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Swallow our fake promiscous request acknowledgement.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync if (pOkAck->dl_correct_primitive == DL_PROMISCON_REQ)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: M_PCPROTO: DL_OK_ACK: fPromisc is ON.\n"));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync else if (pOkAck->dl_correct_primitive == DL_PROMISCOFF_REQ)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: M_PCPROTO: DL_OK_ACK: fPromisc is OFF.\n"));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Swallow our fake raw/fast path mode request acknowledgement.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync struct iocblk *pIOC = (struct iocblk *)pMsg->b_rptr;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: Mode acknowledgement. RawMode is %s\n",
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * Swallow our fake raw/fast path mode request not acknowledged.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync struct iocblk *pIOC = (struct iocblk *)pMsg->b_rptr;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: WARNING! Mode not acknowledged. RawMode is %s\n",
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * We must support flushing queues.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: M_FLUSH\n"));
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync LogRel((DEVICE_NAME ":VBoxNetFltSolarisModReadPut: Could not find VirtualBox instance!!\n"));
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * Don't queue up things here, can cause bad things to happen when the system
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * is under heavy loads and we need to jam across high priority messages which
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * if it's not done properly will end up in an infinite loop.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * We need to free up the message if we don't pass it through.
54dc8e6c81a07ae54c66e27f210609f2ff529760vboxsync * Write side put procedure for processing messages in the write queue.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * All streams, bound and unbound share this write procedure.
b8795afd31d95dd5bf668aa9034df0c985080bc0vboxsync * @param pQueue Pointer to the write queue.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * @param pMsg Pointer to the message.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @returns corresponding solaris error code.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int VBoxNetFltSolarisModWritePut(queue_t *pQueue, mblk_t *pMsg)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":VBoxNetFltSolarisModWritePut pQueue=%p pMsg=%p\n", pQueue, pMsg));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Put the stream in raw mode.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @returns VBox status code.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * @param pQueue Pointer to the read queue.
a299266cddc1ae14d76d725a660bb278816bc151vboxsyncstatic int vboxNetFltSolarisSetRawMode(vboxnetflt_promisc_stream_t *pPromiscStream)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisSetRawMode pPromiscStream=%p\n", pPromiscStream));
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync queue_t *pQueue = pPromiscStream->Stream.pReadQueue;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync struct iocblk *pIOC = (struct iocblk *)pRawMsg->b_rptr;
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * Put the stream back in fast path mode.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * @returns VBox status code.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * @param pQueue Pointer to the read queue.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsyncstatic int vboxNetFltSolarisSetFastMode(queue_t *pQueue)
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisSetFastMode pQueue=%p\n", pQueue));
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync struct iocblk *pIOC = (struct iocblk *)pFastMsg->b_rptr;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync size_t cbReq = sizeof(dl_unitdata_req_t) + sizeof(vboxnetflt_dladdr_t);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync dl_unitdata_req_t *pDataReq = (dl_unitdata_req_t *)pDataReqMsg->b_rptr;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync pDataReq->dl_dest_addr_length = sizeof(vboxnetflt_dladdr_t);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync pDataReq->dl_dest_addr_offset = sizeof(dl_unitdata_req_t);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync bzero(pDataReqMsg->b_rptr + sizeof(dl_unitdata_req_t), sizeof(vboxnetflt_dladdr_t));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Link the data format request message into the header ioctl message.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Send fake promiscous mode requests downstream.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pQueue Pointer to the read queue.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param fPromisc Whether to enable promiscous mode or not.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param PromiscLevel Promiscous level; DL_PROMISC_PHYS/SAP/MULTI.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @returns VBox error code.
a299266cddc1ae14d76d725a660bb278816bc151vboxsyncstatic int vboxNetFltSolarisPromiscReq(queue_t *pQueue, bool fPromisc)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisPromiscReq pQueue=%p fPromisc=%d\n", pQueue, fPromisc));
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync mblk_t *pPromiscPhysMsg = mexchange(NULL, NULL, cbReq, M_PROTO, Cmd);
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync mblk_t *pPromiscSapMsg = mexchange(NULL, NULL, cbReq, M_PROTO, Cmd);
939e2ecb812c6402abcc63e7d615c5444acfd02evboxsync ((dl_promiscon_req_t *)pPromiscPhysMsg->b_rptr)->dl_level = DL_PROMISC_PHYS;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync ((dl_promiscon_req_t *)pPromiscSapMsg->b_rptr)->dl_level = DL_PROMISC_SAP;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync ((dl_promiscoff_req_t *)pPromiscPhysMsg->b_rptr)->dl_level = DL_PROMISC_PHYS;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync ((dl_promiscoff_req_t *)pPromiscSapMsg->b_rptr)->dl_level = DL_PROMISC_SAP;
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsync * Send a fake physical address request downstream.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @returns VBox status code.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pQueue Pointer to the read queue.
a299266cddc1ae14d76d725a660bb278816bc151vboxsyncstatic int vboxNetFltSolarisPhysAddrReq(queue_t *pQueue)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisPhysAddrReq pQueue=%p\n", pQueue));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync mblk_t *pPhysAddrMsg = mexchange(NULL, NULL, cbReq, M_PROTO, Cmd);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync dl_phys_addr_req_t *pPhysAddrReq = (dl_phys_addr_req_t *)pPhysAddrMsg->b_rptr;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Cache the MAC address into the VirtualBox instance given a physical
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * address acknowledgement message.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pThis The instance.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pMsg Pointer to the physical address acknowledgement message.
a299266cddc1ae14d76d725a660bb278816bc151vboxsyncstatic void vboxNetFltSolarisCachePhysAddr(PVBOXNETFLTINS pThis, mblk_t *pMsg)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisCachePhysAddr pThis=%p pMsg=%p\n", pThis, pMsg));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync dl_phys_addr_ack_t *pPhysAddrAck = (dl_phys_addr_ack_t *)pMsg->b_rptr;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync if (pPhysAddrAck->dl_addr_length == sizeof(pThis->u.s.Mac))
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync bcopy(pMsg->b_rptr + pPhysAddrAck->dl_addr_offset, &pThis->u.s.Mac, sizeof(pThis->u.s.Mac));
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisCachePhysAddr: DL_PHYS_ADDR_ACK: Mac=%.*Rhxs\n", sizeof(pThis->u.s.Mac),
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisCachePhysAddr: Invalid address size. expected=%d got=%d\n", ETHERADDRL,
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Prepare DLPI bind request to a SAP.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @returns VBox status code.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pQueue Pointer to the read queue.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param SAP The SAP to bind the stream to.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsyncstatic int vboxNetFltSolarisBindReq(queue_t *pQueue, int SAP)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisBindReq SAP=%d\n", SAP));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync mblk_t *pBindMsg = mexchange(NULL, NULL, DL_BIND_REQ_SIZE, M_PROTO, DL_BIND_REQ);
da0b2d0ebcbeb635e76686254cc10c70faa37ee6vboxsync dl_bind_req_t *pBindReq = (dl_bind_req_t *)pBindMsg->b_rptr;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Prepare DLPI notifications request.
da0b2d0ebcbeb635e76686254cc10c70faa37ee6vboxsync * @returns VBox status code.
da0b2d0ebcbeb635e76686254cc10c70faa37ee6vboxsync * @param pQueue Pointer to the read queue.
a299266cddc1ae14d76d725a660bb278816bc151vboxsyncstatic int vboxNetFltSolarisNotifyReq(queue_t *pQueue)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisNotifyReq\n"));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync mblk_t *pNotifyMsg = mexchange(NULL, NULL, DL_NOTIFY_REQ_SIZE, M_PROTO, DL_NOTIFY_REQ);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync dl_notify_req_t *pNotifyReq = (dl_notify_req_t *)pNotifyMsg->b_rptr;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync pNotifyReq->dl_notifications = DL_NOTE_LINK_UP | DL_NOTE_LINK_DOWN | DL_NOTE_PHYS_ADDR;
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Opens the required device and returns the vnode_t associated with it.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * We require this for the funny attach/detach routine.
da0b2d0ebcbeb635e76686254cc10c70faa37ee6vboxsync * @returns VBox status code.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pszDev The device path.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param ppVNode Where to store the vnode_t pointer associated with the opened device.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param ppVNodeHeld Where to store the vnode_t required during closing of the device.
da0b2d0ebcbeb635e76686254cc10c70faa37ee6vboxsync * @param ppUser Open handle required while closing the device.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisOpenDev(char *pszDev, vnode_t **ppVNode, vnode_t **ppVNodeHeld, TIUSER **ppUser)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync rc = lookupname(pszDev, UIO_SYSSPACE, FOLLOW, NULLVPP, &pVNodeHeld);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync rc = t_kopen((file_t *)NULL, pVNodeHeld->v_rdev, FREAD | FWRITE, &pUser, kcred);
da0b2d0ebcbeb635e76686254cc10c70faa37ee6vboxsync * Close the device opened using vboxNetFltSolarisOpenDev.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pVNodeHeld Pointer to the held vnode of the device.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pUser Pointer to the file handle.
230bd8589bba39933ac5ec21482d6186d675e604vboxsyncstatic void vboxNetFltSolarisCloseDev(vnode_t *pVNodeHeld, TIUSER *pUser)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * Set the DLPI style-2 PPA via an attach request.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @returns VBox status code.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param hDevice Layered device handle.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param PPA Physical Point of Attachment (PPA) number.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisAttachReq(ldi_handle_t hDevice, int PPA)
b2c35a7024c4c308b429c81b203b3bcbd44ee60cvboxsync mblk_t *pAttachMsg = mexchange(NULL, NULL, cbReq, M_PROTO, Cmd);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync dl_attach_req_t *pAttachReq = (dl_attach_req_t *)pAttachMsg->b_rptr;
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachReq ldi_getmsg failed. rc=%d\n", rc));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachReq ldi_putmsg failed. rc=%d\n", rc));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Get the logical interface flags from the stream.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @returns VBox status code.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param hDevice Layered device handle.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pInterface Pointer to the interface.
a299266cddc1ae14d76d725a660bb278816bc151vboxsyncstatic int vboxNetFltSolarisGetIfFlags(ldi_handle_t hDevice, struct lifreq *pInterface)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync rc = ldi_ioctl(hDevice, I_STR, (intptr_t)&IOCReq, FKIOCTL, kcred, &ret);
b2c35a7024c4c308b429c81b203b3bcbd44ee60cvboxsync * Sets the multiplexor ID from the interface.
b2c35a7024c4c308b429c81b203b3bcbd44ee60cvboxsync * @returns VBox status code.
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync * @param pVNode Pointer to the device vnode.
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync * @param pInterface Pointer to the interface.
cec3b04587a02f0dc7d0cc679e9a0de19b730e2cvboxsyncstatic int vboxNetFltSolarisSetMuxId(vnode_t *pVNode, struct lifreq *pInterface)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync rc = strioctl(pVNode, I_STR, (intptr_t)&IOCReq, 0, K_TO_K, kcred, &ret);
4bcaf5d320bf0d88910212509c37bdd634e0879evboxsync * Get the multiplexor file descriptor of the lower stream.
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync * @returns VBox status code.
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync * @param MuxId The multiplexor ID.
4a4d802b46dfabbfd36e88822ff7b17421120469vboxsync * @param pFd Where to store the lower stream file descriptor.
b2c35a7024c4c308b429c81b203b3bcbd44ee60cvboxsyncstatic int vboxNetFltSolarisMuxIdToFd(vnode_t *pVNode, int MuxId, int *pFd)
b2c35a7024c4c308b429c81b203b3bcbd44ee60cvboxsync int rc = strioctl(pVNode, _I_MUXID2FD, (intptr_t)MuxId, 0, K_TO_K, kcred, &ret);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Relinks the lower and the upper IPv4 stream.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @returns VBox status code.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pVNode Pointer to the device vnode.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param pInterface Pointer to the interface.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param IpMuxFd The IP multiplexor ID.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync * @param ArpMuxFd The ARP multiplexor ID.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisRelinkIp4(vnode_t *pVNode, struct lifreq *pInterface, int IpMuxFd, int ArpMuxFd)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisRelinkIp4: pVNode=%p pInterface=%p IpMuxFd=%d ArpMuxFd=%d\n", pVNode,
a299266cddc1ae14d76d725a660bb278816bc151vboxsync int rc = strioctl(pVNode, I_PLINK, (intptr_t)IpMuxFd, 0, K_TO_K, kcred, &NewIpMuxId);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync int rc2 = strioctl(pVNode, I_PLINK, (intptr_t)ArpMuxFd, 0, K_TO_K, kcred, &NewArpMuxId);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync rc = vboxNetFltSolarisSetMuxId(pVNode, pInterface);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisRelinkIp4: failed to set new Mux Id.\n"));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisRelinkIp4: failed to link.\n"));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Relinks the lower and the upper IPv6 stream.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @returns VBox status code.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pVNode Pointer to the device vnode.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pInterface Pointer to the interface.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param Ip6MuxFd The IPv6 multiplexor ID.
a299266cddc1ae14d76d725a660bb278816bc151vboxsyncstatic int vboxNetFltSolarisRelinkIp6(vnode_t *pVNode, struct lifreq *pInterface, int Ip6MuxFd)
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisRelinkIp6: pVNode=%p pInterface=%p Ip6MuxFd=%d\n", pVNode, pInterface, Ip6MuxFd));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync int rc = strioctl(pVNode, I_PLINK, (intptr_t)Ip6MuxFd, 0, K_TO_K, kcred, &NewIp6MuxId);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync rc = vboxNetFltSolarisSetMuxId(pVNode, pInterface);
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisRelinkIp6: failed to set new Mux Id.\n"));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisRelinkIp6: failed to link.\n"));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * Dynamically find the position on the host stack where to attach/detach ourselves.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @returns VBox status code.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pVNode Pointer to the lower stream vnode.
a299266cddc1ae14d76d725a660bb278816bc151vboxsync * @param pModPos Where to store the module position.
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsyncstatic int vboxNetFltSolarisDetermineModPos(bool fAttach, vnode_t *pVNode, int *pModPos)
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogFlow((DEVICE_NAME ":vboxNetFltSolarisDetermineModPos: fAttach=%d pVNode=%p pModPos=%p\n", fAttach, pVNode, pModPos));
a299266cddc1ae14d76d725a660bb278816bc151vboxsync int rc = strioctl(pVNode, I_LIST, (intptr_t)NULL, 0, K_TO_K, kcred, &cMod);
6578276195b5b6a53ef2fc44f96a3348c516d3f5vboxsync LogRel((DEVICE_NAME ":vboxNetFltSolarisDetermineModPos: too few modules on host interface. cMod=%d\n"));
if (fAttach)
return VINF_SUCCESS;
return VERR_NO_MEMORY;
int ret;
if (!rc)
LogFlow((DEVICE_NAME ":vboxNetFltSolarisDetermineModPos: Success! Found %s at %d.\n", DEVICE_NAME, i));
*pModPos = i;
return VINF_SUCCESS;
LogRel((DEVICE_NAME ":vboxNetFltSolarisDetermineModPos: failed to get module information. rc=%d\n"));
LogRel((DEVICE_NAME ":vboxNetFltSolarisDetermineModPos: failed to get list of modules on host interface. rc=%d\n", rc));
return VERR_GENERAL_FAILURE;
int PPALen = 0;
PPALen++;
pszEnd++;
int rc;
long PPA;
if ( pszEnd
if (!rc)
if (!rc)
return VINF_SUCCESS;
return VERR_INTNET_FLT_IF_FAILED;
int ret;
if ( rc
if (rc)
LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenStream vboxNetFltSolarisOpenStyle2 failed. rc=%d\n", rc));
if (rc)
LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenStream Failed to open '%s' rc=%d pszName='%s'\n", szDev, rc, pThis->szName));
return VERR_INTNET_FLT_IF_FAILED;
if (!rc)
if (!ret)
if (!rc)
return VINF_SUCCESS;
LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenStream Failed to push filter onto host interface '%s'\n", pThis->szName));
return VINF_SUCCESS;
LogRel((DEVICE_NAME ":vboxNetFltSolarisOpenStream Failed to search for filter in interface '%s'.\n", pThis->szName));
return VERR_INTNET_FLT_IF_FAILED;
int rc;
int rc2;
int ret;
if (rc)
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachIp4: failed to open the IP stream on '%s'.\n", pThis->szName));
return VERR_INTNET_FLT_IF_FAILED;
if (rc)
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachIp4: failed to open the ARP stream on '%s'.\n", pThis->szName));
return VERR_INTNET_FLT_IF_FAILED;
if (!rc)
int Ip4MuxFd;
int ArpMuxFd;
int ret;
rc2 = strioctl(pUdp4VNode, I_PUNLINK, (intptr_t)Ip4Interface.lifr_arp_muxid, 0, K_TO_K, kcred, &ret);
if ( !rc
&& !rc2)
if ( pIpFile
&& pArpFile
if (!fAttach)
if (!rc)
if (!fAttach)
if (!rc)
return VINF_SUCCESS;
if (fAttach)
if (fAttach)
if (!fAttach)
if (!fAttach)
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachIp4: failed to find position. rc=%d rc2=%d\n", rc, rc2));
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachIp4: failed to unlink upper stream rc=%d rc2=%d.\n", rc, rc2));
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachIp4: failed to get MuxFd from MuxId. rc=%d rc2=%d\n", rc, rc2));
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachIp4: Warning: seems '%s' is unplumbed.\n", pThis->szName));
return rc;
return VERR_INTNET_FLT_IF_FAILED;
int rc;
int rc2;
int ret;
if (rc)
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachIp6: failed to open the IPv6 stream on '%s'.\n", pThis->szName));
return VERR_INTNET_FLT_IF_FAILED;
if (!rc)
int Ip6MuxFd;
int ret;
if (!rc)
if ( pIpFile
if (!fAttach)
if (!rc)
return VINF_SUCCESS;
if (fAttach)
if (!fAttach)
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachIp6: failed to find position. rc=%d rc2=%d\n", rc, rc2));
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachIp6: failed to unlink upper stream rc=%d rc2=%d.\n", rc, rc2));
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachIp6: failed to get MuxFd from MuxId. rc=%d rc2=%d\n", rc, rc2));
return rc;
return VERR_INTNET_FLT_IF_FAILED;
LogRel((DEVICE_NAME ":vboxNetFltSolarisAttachToInterface vboxNetFltSolarisOpenStream failed rc=%Rrc\n", rc));
return rc;
return rc;
LogRel((DEVICE_NAME ":vboxNetFltSolarisMBlkFromSG failed to alloc %d bytes for mblk_t.\n", pSG->cbTotal));
return NULL;
* need/possibility for using a mblk_t chain rather.
return pMsg;
unsigned cSegs = 0;
cSegs++;
#ifdef PADD_RUNT_FRAMES_FROM_HOST
cSegs++;
static int vboxNetFltSolarisMBlkToSG(PVBOXNETFLTINS pThis, mblk_t *pMsg, PINTNETSG pSG, unsigned cSegs, uint32_t fSrc)
LogFlow((DEVICE_NAME ":vboxNetFltSolarisMBlkToSG pThis=%p pMsg=%p pSG=%p cSegs=%d\n", pThis, pMsg, pSG, cSegs));
unsigned iSeg = 0;
while (pCur)
if (cbSeg)
iSeg++;
#ifdef PADD_RUNT_FRAMES_FROM_HOST
LogFlow((DEVICE_NAME ":vboxNetFltSolarisMBlkToSG iSeg=%d pSG->cbTotal=%d msgdsize=%d\n", iSeg, pSG->cbTotal, msgdsize(pMsg)));
return VINF_SUCCESS;
return VERR_NO_MEMORY;
return VERR_NO_MEMORY;
vboxnetflt_dladdr_t *pDlAddr = (vboxnetflt_dladdr_t *)(pDlpiMsg->b_rptr + pDlpiData->dl_dest_addr_offset);
return VINF_SUCCESS;
return VERR_NET_PROTOCOL_ERROR;
case DL_UNITDATA_IND:
vboxnetflt_dladdr_t *pDLSapAddr = (vboxnetflt_dladdr_t *)(pMsg->b_rptr + pDlpiMsg->dl_dest_addr_offset);
case DL_UNITDATA_REQ:
vboxnetflt_dladdr_t *pDLSapAddr = (vboxnetflt_dladdr_t *)(pMsg->b_rptr + pDlpiMsg->dl_dest_addr_offset);
LogRel((DEVICE_NAME ":vboxNetFltSolarisUnitDataToRaw Unknown M_PROTO. This shouldn't be happening!!"));
return VERR_NET_PROTOCOL_ERROR;
return VERR_NO_MEMORY;
return VINF_SUCCESS;
static int vboxNetFltSolarisQueueLoopback(PVBOXNETFLTINS pThis, vboxnetflt_promisc_stream_t *pPromiscStream, mblk_t *pMsg)
LogFlow((DEVICE_NAME ":vboxNetFltSolarisQueueLoopback pThis=%p pPromiscStream=%p pMsg=%p\n", pThis, pPromiscStream, pMsg));
return VERR_NOT_SUPPORTED;
return VERR_NET_MSG_SIZE;
LogFlow((DEVICE_NAME ":vboxNetFltSolarisQueueLoopback added head checksum=%u cLoopback=%d.\n", pCur->Checksum,
LogFlow((DEVICE_NAME ":vboxNetFltSolarisQueueLoopback recycled tail!! checksum=%u cLoopback=%d\n", pCur->Checksum,
return rc;
static bool vboxNetFltSolarisIsOurMBlk(PVBOXNETFLTINS pThis, vboxnetflt_promisc_stream_t *pPromiscStream, mblk_t *pMsg)
bool fIsOurPacket = false;
while (pCur)
if (pPrev)
fIsOurPacket = true;
LogFlow((DEVICE_NAME ":vboxNetFltSolarisIsOurMBlk found packet %p Checksum=%u cLoopback=%d\n", pMsg, Checksum,
return fIsOurPacket;
static int vboxNetFltSolarisRecv(PVBOXNETFLTINS pThis, vboxnetflt_stream_t *pStream, queue_t *pQueue, mblk_t *pMsg)
vboxnetflt_promisc_stream_t *pPromiscStream = ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pvPromiscStream);
return VERR_INVALID_POINTER;
return VINF_SUCCESS;
if (pCorrectedMsg)
return VINF_SUCCESS;
return NULL;
* odd/non-pulled up sizes are welcome.
LogRel((DEVICE_NAME ":vboxNetFltSolarisFixChecksums failed to alloc new message of %d bytes.\n", cbFullMsg));
return NULL;
bool fChecksumAdjusted = false;
* Fix up TCP/UDP and IP checksums if they're incomplete/invalid.
fChecksumAdjusted = true;
fChecksumAdjusted = true;
if (fChecksumAdjusted)
if (pFullMsg)
return pFullMsg;
return pMsg;
if (pFullMsg)
return NULL;
return NULL;
LogFlow((DEVICE_NAME ":ICMP D=%.6Rhxs S=%.6Rhxs T=%04x\n", pb, pb + 6, RT_BE2H_U16(*(uint16_t *)(pb + 12))));
LogRel((DEVICE_NAME ":UDP bootp ack D=%.6Rhxs S=%.6Rhxs UDP_CheckSum=%04x Computex=%04x\n", pb, pb + 6,
typedef struct VLANHEADER
} VLANHEADER;
LogFlow((DEVICE_NAME ":VLAN Pcp=%d Cfi=%d Id=%d\n", pVlanHdr->Pcp, pVlanHdr->Cfi, pVlanHdr->Vid >> 4));
LogFlow((DEVICE_NAME ":Unknown EtherType=%x D=%.6Rhxs S=%.6Rhxs\n", RT_H2BE_U16(pEthHdr->EtherType), &pEthHdr->DstMac,
if (pStream)
return VINF_SUCCESS;
return VINF_SUCCESS;
return rc;
return rc;
return VINF_SUCCESS;
unsigned uProtocol;
if (pNetStack)
if (pNetData)
if (pInterface)
if (!rc)
vboxnetflt_promisc_stream_t *pPromiscStream = ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pvPromiscStream);
if (!pIp4Stream)
return rc;
if (pArpStream)
&& pIp6Stream)
return rc;