[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <466155ef-1e7d-3f2b-72ae-d4f2e6920ded@redhat.com>
Date: Wed, 18 Apr 2018 10:16:47 +0800
From: Jason Wang <jasowang@...hat.com>
To: "Nikita V. Shirokov" <tehnerd@...nerd.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH bpf-next 10/10] [bpf]: make virtio compatible w/
bpf_xdp_adjust_tail
On 2018年04月17日 14:51, Nikita V. Shirokov wrote:
> 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 virtio driver we need to adjust XDP_PASS handling by recalculating
> length of the packet if it was passed to the TCP/IP stack
>
> Signed-off-by: Nikita V. Shirokov <tehnerd@...nerd.com>
> ---
> drivers/net/virtio_net.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7b187ec7411e..115d85f7360a 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -604,6 +604,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
> case XDP_PASS:
> /* Recalculate length in case bpf program changed it */
> delta = orig_data - xdp.data;
> + len = xdp.data_end - xdp.data;
> break;
> case XDP_TX:
> sent = __virtnet_xdp_xmit(vi, &xdp);
> @@ -637,7 +638,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
> goto err;
> }
> skb_reserve(skb, headroom - delta);
> - skb_put(skb, len + delta);
> + skb_put(skb, len);
> if (!delta) {
> buf += header_offset;
> memcpy(skb_vnet_hdr(skb), buf, vi->hdr_len);
> @@ -752,6 +753,10 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
> offset = xdp.data -
> page_address(xdp_page) - vi->hdr_len;
>
> + /* recalculate len if xdp.data or xdp.data_end were
> + * adjusted
> + */
> + len = xdp.data_end - xdp.data;
> /* We can only create skb based on xdp_page. */
> if (unlikely(xdp_page != page)) {
> rcu_read_unlock();
Reviewed-by: Jason Wang <jasowang@...hat.com>
Powered by blists - more mailing lists