VirtualBox

Changeset 28208 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 12, 2010 2:07:33 PM (15 years ago)
Author:
vboxsync
Message:

intnet,VBoxNetFlt-linux: Added INTNETTRUNKSWPORT::pfnPreRecv for doing filtering and switching in difficult contexts. It currently returns broadcast all the time, but that will be addressed before long.

Location:
trunk/src/VBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvIntNet.cpp

    r28134 r28208  
    135135#ifdef IN_RING3
    136136
    137 /* -=-=-=-=- PDMINETWORKUP -=-=-=-=- */
    138 
    139137
    140138/**
     
    192190}
    193191
     192/* -=-=-=-=- PDMINETWORKUP -=-=-=-=- */
    194193
    195194/**
  • trunk/src/VBox/Devices/Network/SrvIntNetR0.cpp

    r28156 r28208  
    33293329
    33303330
     3331/** @copydoc INTNETTRUNKSWPORT::pfnPreRecv */
     3332static DECLCALLBACK(INTNETSWDECISION) intnetR0TrunkIfPortPreRecv(PINTNETTRUNKSWPORT pSwitchPort,
     3333                                                                 void const *pvSrc, size_t cbSrc, uint32_t fSrc)
     3334{
     3335    PINTNETTRUNKIF pThis = INTNET_SWITCHPORT_2_TRUNKIF(pSwitchPort);
     3336    PINTNETNETWORK pNetwork = pThis->pNetwork;
     3337
     3338    /* assert some sanity */
     3339    AssertPtrReturn(pNetwork, INTNETSWDECISION_TRUNK);
     3340    AssertReturn(pNetwork->FastMutex != NIL_RTSEMFASTMUTEX, INTNETSWDECISION_TRUNK);
     3341    AssertPtr(pvSrc);
     3342    AssertPtr(cbSrc >= 6);
     3343    Assert(fSrc);
     3344
     3345    /** @todo implement the switch table. */
     3346
     3347    return INTNETSWDECISION_BROADCAST;
     3348}
     3349
     3350
    33313351/** @copydoc INTNETTRUNKSWPORT::pfnRecv */
    33323352static DECLCALLBACK(bool) intnetR0TrunkIfPortRecv(PINTNETTRUNKSWPORT pSwitchPort, PINTNETSG pSG, uint32_t fSrc)
     
    36123632        return VERR_NO_MEMORY;
    36133633    pTrunkIF->SwitchPort.u32Version                 = INTNETTRUNKSWPORT_VERSION;
     3634    pTrunkIF->SwitchPort.pfnPreRecv                 = intnetR0TrunkIfPortPreRecv;
    36143635    pTrunkIF->SwitchPort.pfnRecv                    = intnetR0TrunkIfPortRecv;
    36153636    pTrunkIF->SwitchPort.pfnSGRetain                = intnetR0TrunkIfPortSGRetain;
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r28202 r28208  
    250250    /** Our overridden ops. */
    251251    struct net_device_ops           Ops;
     252    /** Magic word. */
     253    uint32_t                        u32Magic;
    252254    /** Pointer to the original ops. */
    253255    struct net_device_ops const    *pOrgOps;
    254     /** Magic word. */
    255     uint32_t                        u32Magic;
     256    /** Pointer to the net filter instance. */
     257    PVBOXNETFLTINS                  pVBoxNetFlt;
    256258    /** The number of filtered packages. */
    257259    uint64_t                        cFiltered;
     
    273275{
    274276    PVBOXNETDEVICEOPSOVERRIDE   pOverride = (PVBOXNETDEVICEOPSOVERRIDE)pDev->netdev_ops;
    275     RTNETETHERHDR               EtherHdrBuf;
     277    uint8_t                     abHdrBuf[sizeof(RTNETETHERHDR) + sizeof(uint32_t) + RTNETIPV4_MIN_LEN];
    276278    PCRTNETETHERHDR             pEtherHdr;
     279    PINTNETTRUNKSWPORT          pSwitchPort;
     280
    277281
    278282    /*
     
    300304     *       drop it.
    301305     */
    302     pEtherHdr = (PCRTNETETHERHDR)skb_header_pointer(pSkb, 0, sizeof(EtherHdrBuf), &EtherHdrBuf);
    303     if (    pEtherHdr
    304         &&  pEtherHdr->DstMac.au8[0] == 0x08
    305         &&  pEtherHdr->DstMac.au8[1] == 0x00
    306         &&  pEtherHdr->DstMac.au8[2] == 0x27
     306    pEtherHdr = (PCRTNETETHERHDR)skb_header_pointer(pSkb, 0, sizeof(abHdrBuf), &abHdrBuf[0]);
     307    if (   pEtherHdr
     308        && VALID_PTR(pOverride->pVBoxNetFlt)
     309        && (pSwitchPort = pOverride->pVBoxNetFlt->pSwitchPort) != NULL
     310        && VALID_PTR(pSwitchPort)
    307311       )
    308312    {
    309         dev_kfree_skb(pSkb);
    310         pOverride->cFiltered++;
    311         return NETDEV_TX_OK;
     313        INTNETSWDECISION    enmDecision;
     314        uint32_t            cbHdrs = skb_headlen(pSkb);
     315        cbHdrs = RT_MAX(cbHdrs, sizeof(abHdrBuf));
     316
     317        /** @todo consider reference counting, etc. */
     318        enmDecision = pSwitchPort->pfnPreRecv(pSwitchPort, pEtherHdr, cbHdrs, INTNETTRUNKDIR_HOST);
     319        if (enmDecision == INTNETSWDECISION_INTNET)
     320        {
     321            dev_kfree_skb(pSkb);
     322            pOverride->cFiltered++;
     323            return NETDEV_TX_OK;
     324        }
    312325    }
    313326
     
    333346    pOverride->Ops.ndo_start_xmit   = vboxNetFltLinuxStartXmitFilter;
    334347    pOverride->u32Magic             = VBOXNETDEVICEOPSOVERRIDE_MAGIC;
     348    pOverride->cTotal               = 0;
     349    pOverride->cFiltered            = 0;
     350    pOverride->pVBoxNetFlt          = pThis;
    335351
    336352    RTSpinlockAcquire(pThis->hSpinlock, &Tmp); /* (this isn't necessary, but so what) */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette