VirtualBox

Ignore:
Timestamp:
Jan 22, 2009 5:31:11 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
41933
Message:

#3419: Added fNoPromisc parameter to pfnCreateAndConnect to prevent going promisc on WiFi.

Location:
trunk/src/VBox/HostDrivers/VBoxNetFlt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c

    r15950 r16183  
    10191019 */
    10201020static DECLCALLBACK(int) vboxNetFltFactoryCreateAndConnect(PINTNETTRUNKFACTORY pIfFactory, const char *pszName,
    1021                                                            PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT *ppIfPort)
     1021                                                           PINTNETTRUNKSWPORT pSwitchPort, PINTNETTRUNKIFPORT *ppIfPort, bool fNoPromisc)
    10221022{
    10231023    PVBOXNETFLTGLOBALS pGlobals = (PVBOXNETFLTGLOBALS)((uint8_t *)pIfFactory - RT_OFFSETOF(VBOXNETFLTGLOBALS, TrunkFactory));
     
    10441044                /* instance can be destroyed when it is neither used by the IntNet nor by the ndis filter driver mechanism
    10451045                 * (i.e. the driver is not bound to the specified adapter)*/
     1046                /* Prevent setting promiscuous mode for WiFi adapters. */
     1047                pCur->fDisablePromiscuous = fNoPromisc;
    10461048                vboxNetFltRetain(pCur, false /* fBusy */); /** @todo who releases this on failure? */
    10471049                rc = vboxNetFltConnectIt(pCur, pSwitchPort, ppIfPort);
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h

    r15923 r16183  
    119119     * takes care of serializing rediscovery and disconnecting. */
    120120    bool volatile fRediscoveryPending;
     121    /** Whether we should not attempt to set promiscuous mode at all. */
     122    bool fDisablePromiscuous;
    121123#if (ARCH_BITS == 32) && defined(__GNUC__)
    122124    uint32_t u32Padding;    /**< Alignment padding, will assert in ASMAtomicUoWriteU64 otherwise. */
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

    r16098 r16183  
    939939    struct net_device * pDev;
    940940
    941     LogFlow(("vboxNetFltPortOsSetActive: pThis=%p (%s), fActive=%s\n",
    942              pThis, pThis->szName, fActive?"true":"false"));
     941    LogFlow(("vboxNetFltPortOsSetActive: pThis=%p (%s), fActive=%s, fDisablePromiscuous=%s\n",
     942             pThis, pThis->szName, fActive?"true":"false",
     943             pThis->fDisablePromiscuous?"true":"false"));
     944
     945    if (pThis->fDisablePromiscuous)
     946        return;
    943947
    944948    pDev = vboxNetFltLinuxRetainNetDev(pThis);
     
    951955         * host the interface promiscuity for vboxNetFltPortOsIsPromiscuous.
    952956         */
     957#ifdef LOG_ENABLED
    953958        u_int16_t fIf;
    954 #ifdef LOG_ENABLED
    955959        unsigned const cPromiscBefore = VBOX_GET_PCOUNT(pDev);
    956960#endif
     
    959963            Assert(!pThis->u.s.fPromiscuousSet);
    960964
    961 #if 0
    962             /*
    963              * Try bring the interface up and running if it's down.
    964              */
    965             fIf = dev_get_flags(pDev);
    966             if ((fIf & (IFF_UP | IFF_RUNNING)) != (IFF_UP | IFF_RUNNING))
    967             {
    968                 rtnl_lock();
    969                 int err = dev_change_flags(pDev, fIf | IFF_UP);
    970                 rtnl_unlock();
    971                 fIf = dev_get_flags(pDev);
    972             }
    973 
    974             /*
    975              * Is it already up?  If it isn't, leave it to the link event or
    976              * we'll upset if_pcount (as stated above, ifnet_set_promiscuous is weird).
    977              */
    978             if ((fIf & (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING)
    979                 && !ASMAtomicReadBool(&pThis->u.s.fPromiscuousSet))
    980             {
    981 #endif
    982                 rtnl_lock();
    983                 dev_set_promiscuity(pDev, 1);
    984                 rtnl_unlock();
    985                 pThis->u.s.fPromiscuousSet = true;
    986                 Log(("vboxNetFltPortOsSetActive: enabled promiscuous mode on %s (%d)\n", pThis->szName, VBOX_GET_PCOUNT(pDev)));
    987 #if 0
    988                 /* check if it actually worked, this stuff is not always behaving well. */
    989                 if (!(dev_get_flags(pDev) & IFF_PROMISC))
    990                 {
    991                     err = dev_change_flags(pDev, fIf | IFF_PROMISC);
    992                     if (!err)
    993                         Log(("vboxNetFlt: fixed IFF_PROMISC on %s (%d->%d)\n", pThis->szName, cPromiscBefore, VBOX_GET_PCOUNT(pDev)));
    994                     else
    995                         Log(("VBoxNetFlt: failed to fix IFF_PROMISC on %s, err=%d (%d->%d)\n",
    996                              pThis->szName, err, cPromiscBefore, VBOX_GET_PCOUNT(pDev)));
    997                 }
    998 #endif
    999 #if 0
    1000             }
    1001             else if (!err)
    1002                 Log(("VBoxNetFlt: Waiting for the link to come up... (%d->%d)\n", cPromiscBefore, VBOX_GET_PCOUNT(pDev)));
    1003             if (err)
    1004                 LogRel(("VBoxNetFlt: Failed to put '%s' into promiscuous mode, err=%d (%d->%d)\n", pThis->szName, err, cPromiscBefore, VBOX_GET_PCOUNT(pDev)));
    1005 #endif
     965            rtnl_lock();
     966            dev_set_promiscuity(pDev, 1);
     967            rtnl_unlock();
     968            pThis->u.s.fPromiscuousSet = true;
     969            Log(("vboxNetFltPortOsSetActive: enabled promiscuous mode on %s (%d)\n", pThis->szName, VBOX_GET_PCOUNT(pDev)));
    1006970        }
    1007971        else
     
    1016980            pThis->u.s.fPromiscuousSet = false;
    1017981
     982#ifdef LOG_ENABLED
    1018983            fIf = dev_get_flags(pDev);
    1019984            Log(("VBoxNetFlt: fIf=%#x; %d->%d\n", fIf, cPromiscBefore, VBOX_GET_PCOUNT(pDev)));
     985#endif
    1020986        }
    1021987
Note: See TracChangeset for help on using the changeset viewer.

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