• Jesper Dangaard Brouer's avatar
    net: fix generic XDP to handle if eth header was mangled · 29724956
    Jesper Dangaard Brouer authored
    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: default avatarJesper Dangaard Brouer <brouer@redhat.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    29724956
dev.c 241 KB