VirtualBox

Ignore:
Timestamp:
Nov 30, 2011 5:07:23 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75134
Message:

NetFlt: Restore VLAN tags stripped by hardware (#4806)

File:
1 edited

Legend:

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

    r39019 r39479  
    2929#include <linux/miscdevice.h>
    3030#include <linux/ip.h>
     31#include <linux/if_vlan.h>
    3132
    3233#include <VBox/log.h>
     
    803804         * Get rid of fragmented packets, they cause too much trouble.
    804805         */
     806        unsigned int uMacLen = pBuf->mac_len;
    805807        struct sk_buff *pCopy = skb_copy(pBuf, GFP_ATOMIC);
    806808        kfree_skb(pBuf);
     
    811813        }
    812814        pBuf = pCopy;
     815        /* Somehow skb_copy ignores mac_len */
     816        pBuf->mac_len = uMacLen;
     817# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
     818        /* Restore VLAN tag stripped by host hardware */
     819        if (vlan_tx_tag_present(pBuf) && skb_headroom(pBuf) >= VLAN_ETH_HLEN)
     820        {
     821            uint8_t *pMac = (uint8_t*)skb_mac_header(pBuf);
     822            struct vlan_ethhdr *pVHdr = (struct vlan_ethhdr *)(pMac - VLAN_HLEN);
     823            memmove(pVHdr, pMac, VLAN_ETH_ALEN * 2);
     824            pVHdr->h_vlan_proto = RT_H2N_U16(ETH_P_8021Q);
     825            pVHdr->h_vlan_TCI   = RT_H2N_U16(vlan_tx_tag_get(pBuf));
     826            pBuf->mac_header   -= VLAN_HLEN;
     827            pBuf->mac_len      += VLAN_HLEN;
     828        }
     829# endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */
     830
    813831# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 18)
    814832        Log3(("vboxNetFltLinuxPacketHandler: skb copy len=%u data_len=%u truesize=%u next=%p nr_frags=%u gso_size=%u gso_seqs=%u gso_type=%x frag_list=%p pkt_type=%x\n",
     
    12041222                /*
    12051223                 * The packet came from wire, ethernet header was removed by device driver.
    1206                  * Restore it.
     1224                 * Restore it using mac_len field. This takes into account VLAN headers too.
    12071225                 */
    1208                 skb_push(pBuf, ETH_HLEN);
     1226                skb_push(pBuf, pBuf->mac_len);
    12091227            }
    12101228
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