[PATCH net] net: change skb->mac_header when Generic XDP calls adjust_head

Subsystems: networking [general], the rest

STALE3271d

2 messages, 2 authors, 2017-09-20 · open the first message on its own page

[PATCH net] net: change skb->mac_header when Generic XDP calls adjust_head

From: Edward Cree <hidden>
Date: 2017-09-19 17:46:03

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 <redacted>
---
 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:

Re: [PATCH net] net: change skb->mac_header when Generic XDP calls adjust_head

From: David Miller <davem@davemloft.net>
Date: 2017-09-20 22:45:04

From: Edward Cree <redacted>
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 <redacted>
Applied and queued up for -stable, thanks Edward.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help