提交 4516f7fc 编写于 作者: J Jesper Dangaard Brouer 提交者: Yang Yingliang

net: fix bpf_xdp_adjust_head regression for generic-XDP

stable inclusion
from linux-4.19.99
commit 50176c0d22ea2347867c6196c99b0f778f81f7be

--------------------------------

[ Upstream commit 065af355 ]

When generic-XDP was moved to a later processing step by commit
458bf2f2 ("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: 458bf2f2 ("net: core: support XDP generic on stacked devices.")
Reported-by: NBrandon Cazander <brandon.cazander@multapplied.net>
Signed-off-by: NJesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NLi Aichun <liaichun@huawei.com>
Reviewed-by: Nguodeqing <geffrey.guo@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 6c61a726
...@@ -4349,12 +4349,17 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, ...@@ -4349,12 +4349,17 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
act = bpf_prog_run_xdp(xdp_prog, xdp); act = bpf_prog_run_xdp(xdp_prog, xdp);
/* check if bpf_xdp_adjust_head was used */
off = xdp->data - orig_data; off = xdp->data - orig_data;
if (off > 0) if (off) {
__skb_pull(skb, off); if (off > 0)
else if (off < 0) __skb_pull(skb, off);
__skb_push(skb, -off); else if (off < 0)
skb->mac_header += off; __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" /* check if bpf_xdp_adjust_tail was used. it can only "shrink"
* pckt. * pckt.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册