All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] bpf: Align packet data properly in program testing framework.
@ 2017-05-02 15:36 David Miller
  2017-05-02 15:41 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2017-05-02 15:36 UTC (permalink / raw)
  To: ast; +Cc: daniel, netdev


Make sure we apply NET_IP_ALIGN when reserving headroom for SKB
and XDP test runs, just like a real driver would.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/bpf/test_run.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index f946912..6be41a4 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -100,7 +100,7 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
 	void *data;
 	int ret;
 
-	data = bpf_test_init(kattr, size, NET_SKB_PAD,
+	data = bpf_test_init(kattr, size, NET_SKB_PAD + NET_IP_ALIGN,
 			     SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
 	if (IS_ERR(data))
 		return PTR_ERR(data);
@@ -125,7 +125,7 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
 		return -ENOMEM;
 	}
 
-	skb_reserve(skb, NET_SKB_PAD);
+	skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN);
 	__skb_put(skb, size);
 	skb->protocol = eth_type_trans(skb, current->nsproxy->net_ns->loopback_dev);
 	skb_reset_network_header(skb);
@@ -156,16 +156,16 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
 	void *data;
 	int ret;
 
-	data = bpf_test_init(kattr, size, XDP_PACKET_HEADROOM, 0);
+	data = bpf_test_init(kattr, size, XDP_PACKET_HEADROOM + NET_IP_ALIGN, 0);
 	if (IS_ERR(data))
 		return PTR_ERR(data);
 
 	xdp.data_hard_start = data;
-	xdp.data = data + XDP_PACKET_HEADROOM;
+	xdp.data = data + XDP_PACKET_HEADROOM + NET_IP_ALIGN;
 	xdp.data_end = xdp.data + size;
 
 	retval = bpf_test_run(prog, &xdp, repeat, &duration);
-	if (xdp.data != data + XDP_PACKET_HEADROOM)
+	if (xdp.data != data + XDP_PACKET_HEADROOM + NET_IP_ALIGN)
 		size = xdp.data_end - xdp.data;
 	ret = bpf_test_finish(kattr, uattr, xdp.data, size, retval, duration);
 	kfree(data);
-- 
2.1.2.532.g19b5d50

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

* Re: [PATCH 2/2] bpf: Align packet data properly in program testing framework.
  2017-05-02 15:36 [PATCH 2/2] bpf: Align packet data properly in program testing framework David Miller
@ 2017-05-02 15:41 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2017-05-02 15:41 UTC (permalink / raw)
  To: David Miller, ast; +Cc: netdev

On 05/02/2017 05:36 PM, David Miller wrote:
>
> Make sure we apply NET_IP_ALIGN when reserving headroom for SKB
> and XDP test runs, just like a real driver would.
>
> Signed-off-by: David S. Miller <davem@davemloft.net>

Thanks for fixing!

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

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

end of thread, other threads:[~2017-05-02 15:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-02 15:36 [PATCH 2/2] bpf: Align packet data properly in program testing framework David Miller
2017-05-02 15:41 ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.