netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: "Nikita V. Shirokov" <tehnerd@tehnerd.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next 10/10] [bpf]: make virtio compatible w/ bpf_xdp_adjust_tail
Date: Wed, 18 Apr 2018 10:16:47 +0800	[thread overview]
Message-ID: <466155ef-1e7d-3f2b-72ae-d4f2e6920ded@redhat.com> (raw)
In-Reply-To: <20180417065131.3632-11-tehnerd@tehnerd.com>



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@tehnerd.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@redhat.com>

      reply	other threads:[~2018-04-18  2:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-17  6:51 [PATCH bpf-next 00/10] introduction of bpf_xdp_adjust_tail Nikita V. Shirokov
2018-04-17  6:51 ` [PATCH bpf-next 01/10] [bpf]: adding bpf_xdp_adjust_tail helper Nikita V. Shirokov
2018-04-17 14:14   ` kbuild test robot
2018-04-17 22:58   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 02/10] [bpf]: adding tests for bpf_xdp_adjust_tail Nikita V. Shirokov
2018-04-17 23:04   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 03/10] [bpf]: add bpf_xdp_adjust_tail sample prog Nikita V. Shirokov
2018-04-17  6:51 ` [PATCH bpf-next 04/10] [bpf]: make generic xdp compatible w/ bpf_xdp_adjust_tail Nikita V. Shirokov
2018-04-17 23:06   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 05/10] [bpf]: make mlx4 " Nikita V. Shirokov
2018-04-17 23:06   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 06/10] [bpf]: make bnxt " Nikita V. Shirokov
2018-04-17 23:07   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 07/10] [bpf]: make cavium thunder " Nikita V. Shirokov
2018-04-17 23:07   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 08/10] [bpf]: make netronome nfp " Nikita V. Shirokov
2018-04-17 23:08   ` Alexei Starovoitov
2018-04-18  0:40     ` Jakub Kicinski
2018-04-17  6:51 ` [PATCH bpf-next 09/10] [bpf]: make tun " Nikita V. Shirokov
2018-04-18  2:16   ` Jason Wang
2018-04-17  6:51 ` [PATCH bpf-next 10/10] [bpf]: make virtio " Nikita V. Shirokov
2018-04-18  2:16   ` Jason Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=466155ef-1e7d-3f2b-72ae-d4f2e6920ded@redhat.com \
    --to=jasowang@redhat.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=tehnerd@tehnerd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).