diff options
author | Jesper Dangaard Brouer <brouer@redhat.com> | 2019-08-01 20:00:31 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-09 17:51:47 +0200 |
commit | 78407cb40864a21b677f9f9b28f62251a4146997 (patch) | |
tree | 70b2b152c3217690426bc2b442dc528b6e2a69f9 /net | |
parent | b0e50d6ddf454831f7f7b6aeacd5de3b815e3ecc (diff) | |
download | linux-stable-78407cb40864a21b677f9f9b28f62251a4146997.tar.gz linux-stable-78407cb40864a21b677f9f9b28f62251a4146997.tar.bz2 linux-stable-78407cb40864a21b677f9f9b28f62251a4146997.zip |
net: fix bpf_xdp_adjust_head regression for generic-XDP
[ Upstream commit 065af355470519bd184019a93ac579f22b036045 ]
When generic-XDP was moved to a later processing step by commit
458bf2f224f0 ("net: core: support XDP generic on stacked devices.")
a regression was introduced when using bpf_xdp_adjust_head.
The issue is that after this commit the skb->network_header is now
changed prior to calling generic XDP and not after. Thus, if the header
is changed by XDP (via bpf_xdp_adjust_head), then skb->network_header
also need to be updated again. Fix by calling skb_reset_network_header().
Fixes: 458bf2f224f0 ("net: core: support XDP generic on stacked devices.")
Reported-by: Brandon Cazander <brandon.cazander@multapplied.net>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/dev.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index d490c7b0ca2b..29fcff2c3d51 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4382,12 +4382,17 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, act = bpf_prog_run_xdp(xdp_prog, xdp); + /* check if bpf_xdp_adjust_head was used */ off = xdp->data - orig_data; - if (off > 0) - __skb_pull(skb, off); - else if (off < 0) - __skb_push(skb, -off); - skb->mac_header += off; + if (off) { + if (off > 0) + __skb_pull(skb, off); + else if (off < 0) + __skb_push(skb, -off); + + skb->mac_header += off; + skb_reset_network_header(skb); + } /* check if bpf_xdp_adjust_tail was used. it can only "shrink" * pckt. |