• J
    net: fix generic XDP to handle if eth header was mangled · 00af91bc
    Jesper Dangaard Brouer 提交于
    [ Upstream commit 2972495699320229b55b8e5065a310be5c81485b ]
    
    XDP can modify (and resize) the Ethernet header in the packet.
    
    There is a bug in generic-XDP, because skb->protocol and skb->pkt_type
    are setup before reaching (netif_receive_)generic_xdp.
    
    This bug was hit when XDP were popping VLAN headers (changing
    eth->h_proto), as skb->protocol still contains VLAN-indication
    (ETH_P_8021Q) causing invocation of skb_vlan_untag(skb), which corrupt
    the packet (basically popping the VLAN again).
    
    This patch catch if XDP changed eth header in such a way, that SKB
    fields needs to be updated.
    
    V2: on request from Song Liu, use ETH_HLEN instead of mac_len,
    in __skb_push() as eth_type_trans() use ETH_HLEN in paired skb_pull_inline().
    
    Fixes: d4455169 ("net: xdp: support xdp generic on virtual devices")
    Signed-off-by: NJesper Dangaard Brouer <brouer@redhat.com>
    Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
    Signed-off-by: NSasha Levin <sashal@kernel.org>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    00af91bc
dev.c 242.7 KB