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.

File:
1 edited

Legend:

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

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