netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: change skb->mac_header when Generic XDP calls adjust_head
@ 2017-09-19 17:45 Edward Cree
  2017-09-20 22:45 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Edward Cree @ 2017-09-19 17:45 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

Since XDP's view of the packet includes the MAC header, moving the start-
 of-packet with bpf_xdp_adjust_head needs to also update the offset of the
 MAC header (which is relative to skb->head, not to the skb->data that was
 changed).
Without this, tcpdump sees packets starting from the old MAC header rather
 than the new one, at least in my tests on the loopback device.

Fixes: b5cdae3291f7 ("net: Generic XDP")
Signed-off-by: Edward Cree <ecree@solarflare.com>
---
 net/core/dev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index fb766d9..9a2254f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3892,6 +3892,7 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
 		__skb_pull(skb, off);
 	else if (off < 0)
 		__skb_push(skb, -off);
+	skb->mac_header += off;
 
 	switch (act) {
 	case XDP_REDIRECT:

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: change skb->mac_header when Generic XDP calls adjust_head
  2017-09-19 17:45 [PATCH net] net: change skb->mac_header when Generic XDP calls adjust_head Edward Cree
@ 2017-09-20 22:45 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-09-20 22:45 UTC (permalink / raw)
  To: ecree; +Cc: netdev

From: Edward Cree <ecree@solarflare.com>
Date: Tue, 19 Sep 2017 18:45:56 +0100

> Since XDP's view of the packet includes the MAC header, moving the start-
>  of-packet with bpf_xdp_adjust_head needs to also update the offset of the
>  MAC header (which is relative to skb->head, not to the skb->data that was
>  changed).
> Without this, tcpdump sees packets starting from the old MAC header rather
>  than the new one, at least in my tests on the loopback device.
> 
> Fixes: b5cdae3291f7 ("net: Generic XDP")
> Signed-off-by: Edward Cree <ecree@solarflare.com>

Applied and queued up for -stable, thanks Edward.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-20 22:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-19 17:45 [PATCH net] net: change skb->mac_header when Generic XDP calls adjust_head Edward Cree
2017-09-20 22:45 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).