* [PATCH bpf-next] bpf: fix virtio-net's length calc for XDP_PASS
@ 2018-04-23 4:16 Nikita V. Shirokov
2018-04-23 6:33 ` Jason Wang
0 siblings, 1 reply; 3+ messages in thread
From: Nikita V. Shirokov @ 2018-04-23 4:16 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Michael S. Tsirkin,
Jason Wang
Cc: netdev, David Ahern, Nikita V. Shirokov
In commit 6870de435b90 ("bpf: make virtio compatible w/
bpf_xdp_adjust_tail") i didn't account for vi->hdr_len during new
packet's length calculation after bpf_prog_run in receive_mergeable.
because of this all packets, if they were passed to the kernel,
were truncated by 12 bytes.
Fixes:6870de435b90 ("bpf: make virtio compatible w/ bpf_xdp_adjust_tail")
Reported-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Nikita V. Shirokov <tehnerd@tehnerd.com>
---
Notes:
unfortunately it looks like that xdp_tx is still broken because
fix by Jason (introduced in "XDP_TX for virtio_net not working in recent kernel?
" thread) haven't landed yet)
drivers/net/virtio_net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 779a4f798522..08ac2cc986aa 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -761,7 +761,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
/* recalculate len if xdp.data or xdp.data_end were
* adjusted
*/
- len = xdp.data_end - xdp.data;
+ len = xdp.data_end - xdp.data + vi->hdr_len;
/* We can only create skb based on xdp_page. */
if (unlikely(xdp_page != page)) {
rcu_read_unlock();
--
2.15.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] bpf: fix virtio-net's length calc for XDP_PASS
2018-04-23 4:16 [PATCH bpf-next] bpf: fix virtio-net's length calc for XDP_PASS Nikita V. Shirokov
@ 2018-04-23 6:33 ` Jason Wang
2018-04-23 9:30 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2018-04-23 6:33 UTC (permalink / raw)
To: Nikita V. Shirokov, Alexei Starovoitov, Daniel Borkmann,
Michael S. Tsirkin
Cc: netdev, David Ahern
On 2018年04月23日 12:16, Nikita V. Shirokov wrote:
> In commit 6870de435b90 ("bpf: make virtio compatible w/
> bpf_xdp_adjust_tail") i didn't account for vi->hdr_len during new
> packet's length calculation after bpf_prog_run in receive_mergeable.
> because of this all packets, if they were passed to the kernel,
> were truncated by 12 bytes.
>
> Fixes:6870de435b90 ("bpf: make virtio compatible w/ bpf_xdp_adjust_tail")
> Reported-by: David Ahern <dsahern@gmail.com>
>
> Signed-off-by: Nikita V. Shirokov <tehnerd@tehnerd.com>
> ---
>
> Notes:
> unfortunately it looks like that xdp_tx is still broken because
> fix by Jason (introduced in "XDP_TX for virtio_net not working in recent kernel?
> " thread) haven't landed yet)
>
> drivers/net/virtio_net.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 779a4f798522..08ac2cc986aa 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -761,7 +761,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
> /* recalculate len if xdp.data or xdp.data_end were
> * adjusted
> */
> - len = xdp.data_end - xdp.data;
> + len = xdp.data_end - xdp.data + vi->hdr_len;
> /* We can only create skb based on xdp_page. */
> if (unlikely(xdp_page != page)) {
> rcu_read_unlock();
Acked-by: Jason Wang <jasowang@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] bpf: fix virtio-net's length calc for XDP_PASS
2018-04-23 6:33 ` Jason Wang
@ 2018-04-23 9:30 ` Daniel Borkmann
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2018-04-23 9:30 UTC (permalink / raw)
To: Jason Wang, Nikita V. Shirokov, Alexei Starovoitov,
Michael S. Tsirkin
Cc: netdev, David Ahern
On 04/23/2018 08:33 AM, Jason Wang wrote:
> On 2018年04月23日 12:16, Nikita V. Shirokov wrote:
>> In commit 6870de435b90 ("bpf: make virtio compatible w/
>> bpf_xdp_adjust_tail") i didn't account for vi->hdr_len during new
>> packet's length calculation after bpf_prog_run in receive_mergeable.
>> because of this all packets, if they were passed to the kernel,
>> were truncated by 12 bytes.
>>
>> Fixes:6870de435b90 ("bpf: make virtio compatible w/ bpf_xdp_adjust_tail")
>> Reported-by: David Ahern <dsahern@gmail.com>
>>
>> Signed-off-by: Nikita V. Shirokov <tehnerd@tehnerd.com>
[...]
>
> Acked-by: Jason Wang <jasowang@redhat.com>
Applied to bpf-next, thanks everyone!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-23 9:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-23 4:16 [PATCH bpf-next] bpf: fix virtio-net's length calc for XDP_PASS Nikita V. Shirokov
2018-04-23 6:33 ` Jason Wang
2018-04-23 9:30 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox