Re: [PATCH net-next v2 19/33] tun: add XDP frame size

Michael S. Tsirkin
2020-05-06T20:33:02Z

On Thu, Apr 30, 2020 at 01:21:58PM +0200, Jesper Dangaard Brouer wrote:
> The tun driver have two code paths for running XDP (bpf_prog_run_xdp).
> In both cases 'buflen' contains enough tailroom for skb_shared_info.
>
> Cc: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> Acked-by: Jason Wang <jasowang@redhat.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
> drivers/net/tun.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 44889eba1dbc..c54f967e2c66 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1671,6 +1671,7 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
> xdp_set_data_meta_invalid(&xdp);
> xdp.data_end = xdp.data + len;
> xdp.rxq = &tfile->xdp_rxq;
> + xdp.frame_sz = buflen;
>
> act = bpf_prog_run_xdp(xdp_prog, &xdp);
> if (act == XDP_REDIRECT || act == XDP_TX) {
> @@ -2411,6 +2412,7 @@ static int tun_xdp_one(struct tun_struct *tun,
> }
> xdp_set_data_meta_invalid(xdp);
> xdp->rxq = &tfile->xdp_rxq;
> + xdp->frame_sz = buflen;
>
> act = bpf_prog_run_xdp(xdp_prog, xdp);
> err = tun_xdp_act(tun, xdp_prog, xdp, act);
>
>