VirtualBox

Changeset 28208 in vbox for trunk/src/VBox/HostDrivers


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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