diff options
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 0b2d777e5b9e..ec96f50b0782 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -4258,6 +4258,9 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, | |||
4258 | struct netdev_rx_queue *rxqueue; | 4258 | struct netdev_rx_queue *rxqueue; |
4259 | void *orig_data, *orig_data_end; | 4259 | void *orig_data, *orig_data_end; |
4260 | u32 metalen, act = XDP_DROP; | 4260 | u32 metalen, act = XDP_DROP; |
4261 | __be16 orig_eth_type; | ||
4262 | struct ethhdr *eth; | ||
4263 | bool orig_bcast; | ||
4261 | int hlen, off; | 4264 | int hlen, off; |
4262 | u32 mac_len; | 4265 | u32 mac_len; |
4263 | 4266 | ||
@@ -4298,6 +4301,9 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, | |||
4298 | xdp->data_hard_start = skb->data - skb_headroom(skb); | 4301 | xdp->data_hard_start = skb->data - skb_headroom(skb); |
4299 | orig_data_end = xdp->data_end; | 4302 | orig_data_end = xdp->data_end; |
4300 | orig_data = xdp->data; | 4303 | orig_data = xdp->data; |
4304 | eth = (struct ethhdr *)xdp->data; | ||
4305 | orig_bcast = is_multicast_ether_addr_64bits(eth->h_dest); | ||
4306 | orig_eth_type = eth->h_proto; | ||
4301 | 4307 | ||
4302 | rxqueue = netif_get_rxqueue(skb); | 4308 | rxqueue = netif_get_rxqueue(skb); |
4303 | xdp->rxq = &rxqueue->xdp_rxq; | 4309 | xdp->rxq = &rxqueue->xdp_rxq; |
@@ -4321,6 +4327,14 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, | |||
4321 | 4327 | ||
4322 | } | 4328 | } |
4323 | 4329 | ||
4330 | /* check if XDP changed eth hdr such SKB needs update */ | ||
4331 | eth = (struct ethhdr *)xdp->data; | ||
4332 | if ((orig_eth_type != eth->h_proto) || | ||
4333 | (orig_bcast != is_multicast_ether_addr_64bits(eth->h_dest))) { | ||
4334 | __skb_push(skb, ETH_HLEN); | ||
4335 | skb->protocol = eth_type_trans(skb, skb->dev); | ||
4336 | } | ||
4337 | |||
4324 | switch (act) { | 4338 | switch (act) { |
4325 | case XDP_REDIRECT: | 4339 | case XDP_REDIRECT: |
4326 | case XDP_TX: | 4340 | case XDP_TX: |