提交 198d83bb 编写于 作者: N Nikita V. Shirokov 提交者: Daniel Borkmann

bpf: make generic xdp compatible w/ bpf_xdp_adjust_tail

w/ bpf_xdp_adjust_tail helper xdp's data_end pointer could be changed as
well (only "decrease" of pointer's location is going to be supported).
changing of this pointer will change packet's size.
for generic XDP we need to reflect this packet's length change by
adjusting skb's tail pointer
Acked-by: NAlexei Starovoitov <ast@kernel.org>
Signed-off-by: NNikita V. Shirokov <tehnerd@tehnerd.com>
Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
上级 b32cc5b9
...@@ -3996,9 +3996,9 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, ...@@ -3996,9 +3996,9 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
struct bpf_prog *xdp_prog) struct bpf_prog *xdp_prog)
{ {
struct netdev_rx_queue *rxqueue; struct netdev_rx_queue *rxqueue;
void *orig_data, *orig_data_end;
u32 metalen, act = XDP_DROP; u32 metalen, act = XDP_DROP;
struct xdp_buff xdp; struct xdp_buff xdp;
void *orig_data;
int hlen, off; int hlen, off;
u32 mac_len; u32 mac_len;
...@@ -4037,6 +4037,7 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, ...@@ -4037,6 +4037,7 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
xdp.data_meta = xdp.data; xdp.data_meta = xdp.data;
xdp.data_end = xdp.data + hlen; xdp.data_end = xdp.data + hlen;
xdp.data_hard_start = skb->data - skb_headroom(skb); xdp.data_hard_start = skb->data - skb_headroom(skb);
orig_data_end = xdp.data_end;
orig_data = xdp.data; orig_data = xdp.data;
rxqueue = netif_get_rxqueue(skb); rxqueue = netif_get_rxqueue(skb);
...@@ -4051,6 +4052,13 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, ...@@ -4051,6 +4052,13 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
__skb_push(skb, -off); __skb_push(skb, -off);
skb->mac_header += off; skb->mac_header += off;
/* check if bpf_xdp_adjust_tail was used. it can only "shrink"
* pckt.
*/
off = orig_data_end - xdp.data_end;
if (off != 0)
skb_set_tail_pointer(skb, xdp.data_end - xdp.data);
switch (act) { switch (act) {
case XDP_REDIRECT: case XDP_REDIRECT:
case XDP_TX: case XDP_TX:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册