VirtualBox

Ignore:
Timestamp:
Jun 8, 2015 8:28:26 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
100861
Message:

VBoxNetFlt/linux: Ignore IPv4 (RFC3927) and IPv6 link-local addresses
on other devices.

File:
1 edited

Legend:

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

    r56144 r56280  
    8888#else
    8989# define VBOX_NETDEV_NAME(dev)              ((dev)->reg_state != NETREG_REGISTERED ? "(unregistered net_device)" : (dev)->name)
     90#endif
     91
     92#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     93# define VBOX_IPV4_IS_LOOPBACK(addr)        ipv4_is_loopback(addr)
     94# define VBOX_IPV4_IS_LINKLOCAL_169(addr)   ipv4_is_linklocal_169(addr)
     95#else
     96# define VBOX_IPV4_IS_LOOPBACK(addr)        ((addr & htonl(IN_CLASSA_NET)) == htonl(0x7f000000))
     97# define VBOX_IPV4_IS_LINKLOCAL_169(addr)   ((addr & htonl(IN_CLASSB_NET)) == htonl(0xa9fe0000))
    9098#endif
    9199
     
    18971905    {
    18981906        for_ifa(in_dev) {
    1899             if (IN_LOOPBACK(ntohl(ifa->ifa_address)))
     1907            if (VBOX_IPV4_IS_LOOPBACK(ifa->ifa_address))
    19001908                return NOTIFY_OK;
     1909
     1910            if (   dev != pThis->u.s.pDev
     1911                && VBOX_IPV4_IS_LINKLOCAL_169(ifa->ifa_address))
     1912                continue;
    19011913
    19021914            Log(("%s: %s: IPv4 addr %RTnaipv4 mask %RTnaipv4\n",
     
    19451957{
    19461958    PVBOXNETFLTINS     pThis = RT_FROM_MEMBER(self, VBOXNETFLTINS, u.s.NotifierIPv4);
    1947     struct net_device *pDev;
     1959    struct net_device *pDev, *pEventDev;
    19481960    struct in_ifaddr  *ifa   = (struct in_ifaddr *)ptr;
     1961    bool               fMyDev;
    19491962    int                rc    = NOTIFY_OK;
    19501963
    19511964    pDev = vboxNetFltLinuxRetainNetDev(pThis);
    1952     Log(("VBoxNetFlt: %s: IPv4 event %s(0x%lx): addr %RTnaipv4 mask %RTnaipv4\n",
     1965    pEventDev = ifa->ifa_dev->dev;
     1966    fMyDev = (pDev == pEventDev);
     1967    Log(("VBoxNetFlt: %s: IPv4 event %s(0x%lx) %s: addr %RTnaipv4 mask %RTnaipv4\n",
    19531968         pDev ? VBOX_NETDEV_NAME(pDev) : "<???>",
    19541969         vboxNetFltLinuxGetNetDevEventName(ulEventType), ulEventType,
     1970         pEventDev ? VBOX_NETDEV_NAME(pEventDev) : "<???>",
    19551971         ifa->ifa_address, ifa->ifa_mask));
    19561972
    19571973    if (pDev != NULL)
    19581974        vboxNetFltLinuxReleaseNetDev(pThis, pDev);
     1975
     1976    if (VBOX_IPV4_IS_LOOPBACK(ifa->ifa_address))
     1977        return NOTIFY_OK;
     1978
     1979    if (   !fMyDev
     1980        && VBOX_IPV4_IS_LINKLOCAL_169(ifa->ifa_address))
     1981        return NOTIFY_OK;
    19591982
    19601983    if (pThis->pSwitchPort->pfnNotifyHostAddress)
     
    19792002{
    19802003    PVBOXNETFLTINS       pThis = RT_FROM_MEMBER(self, VBOXNETFLTINS, u.s.NotifierIPv6);
    1981     struct net_device   *pDev;
     2004    struct net_device   *pDev, *pEventDev;
    19822005    struct inet6_ifaddr *ifa   = (struct inet6_ifaddr *)ptr;
     2006    bool                 fMyDev;
    19832007    int                  rc    = NOTIFY_OK;
    19842008
    19852009    pDev = vboxNetFltLinuxRetainNetDev(pThis);
    1986     Log(("VBoxNetFlt: %s: IPv6 event %s(0x%lx): %RTnaipv6\n",
     2010    pEventDev = ifa->idev->dev;
     2011    fMyDev = (pDev == pEventDev);
     2012    Log(("VBoxNetFlt: %s: IPv6 event %s(0x%lx) %s: %RTnaipv6\n",
    19872013         pDev ? VBOX_NETDEV_NAME(pDev) : "<???>",
    19882014         vboxNetFltLinuxGetNetDevEventName(ulEventType), ulEventType,
     2015         pEventDev ? VBOX_NETDEV_NAME(pEventDev) : "<???>",
    19892016         &ifa->addr));
    19902017
    19912018    if (pDev != NULL)
    19922019        vboxNetFltLinuxReleaseNetDev(pThis, pDev);
     2020
     2021    if (   !fMyDev
     2022        && ipv6_addr_src_scope(&ifa->addr) <= IPV6_ADDR_SCOPE_LINKLOCAL)
     2023        return NOTIFY_OK;
    19932024
    19942025    if (pThis->pSwitchPort->pfnNotifyHostAddress)
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