~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2010-12-05 11:27:36 UTC
  • mfrom: (0.3.11 upstream) (0.4.21 sid)
  • Revision ID: james.westby@ubuntu.com-20101205112736-os9dcg0r9dxbfpa0
Tags: 3.2.12-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
  - Add ubuntu-01-fix-build-gcc45.patch to fix FTBFS due to uninitalized
    variables.
  - Add ubuntu-02-as-needed.patch to fix FTBFS with --as-needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1337
1337
    return fRc;
1338
1338
}
1339
1339
 
 
1340
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
 
1341
/**
 
1342
 * Helper for detecting TAP devices.
 
1343
 */
 
1344
static bool vboxNetFltIsTapDevice(PVBOXNETFLTINS pThis, struct net_device *pDev)
 
1345
{
 
1346
    if (pDev->ethtool_ops && pDev->ethtool_ops->get_drvinfo)
 
1347
    {
 
1348
        struct ethtool_drvinfo Info;
 
1349
 
 
1350
        memset(&Info, 0, sizeof(Info));
 
1351
        Info.cmd = ETHTOOL_GDRVINFO;
 
1352
        pDev->ethtool_ops->get_drvinfo(pDev, &Info);
 
1353
        Log3(("vboxNetFltIsTapDevice: driver=%s version=%s bus_info=%s\n",
 
1354
              Info.driver, Info.version, Info.bus_info));
 
1355
 
 
1356
        return !strncmp(Info.driver,   "tun", 4)
 
1357
            && !strncmp(Info.bus_info, "tap", 4);
 
1358
    }
 
1359
 
 
1360
    return false;
 
1361
}
 
1362
 
 
1363
/**
 
1364
 * Helper for updating the link state of TAP devices.
 
1365
 * Only TAP devices are affected.
 
1366
 */
 
1367
static void vboxNetFltSetTapLinkState(PVBOXNETFLTINS pThis, struct net_device *pDev, bool fLinkUp)
 
1368
{
 
1369
    if (vboxNetFltIsTapDevice(pThis, pDev))
 
1370
    {
 
1371
        Log3(("vboxNetFltSetTapLinkState: bringing %s tap device link state\n",
 
1372
              fLinkUp ? "up" : "down"));
 
1373
        netif_tx_lock_bh(pDev);
 
1374
        if (fLinkUp)
 
1375
            netif_carrier_on(pDev);
 
1376
        else
 
1377
            netif_carrier_off(pDev);
 
1378
        netif_tx_unlock_bh(pDev);
 
1379
    }
 
1380
}
 
1381
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) */
 
1382
DECLINLINE(void) vboxNetFltSetTapLinkState(PVBOXNETFLTINS pThis, struct net_device *pDev, bool fLinkUp)
 
1383
{
 
1384
    /* Nothing to do for pre-2.6.36 kernels. */
 
1385
}
 
1386
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) */
 
1387
 
1340
1388
/**
1341
1389
 * Internal worker for vboxNetFltLinuxNotifierCallback.
1342
1390
 *
1378
1426
#endif
1379
1427
 
1380
1428
    /*
 
1429
     * If attaching to TAP interface we need to bring the link state up
 
1430
     * starting from 2.6.36 kernel.
 
1431
     */
 
1432
    vboxNetFltSetTapLinkState(pThis, pDev, true);
 
1433
 
 
1434
    /*
1381
1435
     * Set indicators that require the spinlock. Be abit paranoid about racing
1382
1436
     * the device notification handle.
1383
1437
     */
1741
1795
 
1742
1796
    if (fRegistered)
1743
1797
    {
 
1798
        vboxNetFltSetTapLinkState(pThis, pDev, false);
 
1799
 
1744
1800
#ifndef VBOXNETFLT_LINUX_NO_XMIT_QUEUE
1745
1801
        skb_queue_purge(&pThis->u.s.XmitQueue);
1746
1802
#endif