From: John Fastabend <john.fastabend@gmail.com>
To: jasowang@redhat.com, mst@redhat.com
Cc: john.r.fastabend@intel.com, netdev@vger.kernel.org
Subject: Re: [net PATCH 1/2] virtio_net: cap mtu when XDP programs are running
Date: Wed, 4 Jan 2017 19:14:01 -0800 [thread overview]
Message-ID: <586DB9F9.9090701@gmail.com> (raw)
In-Reply-To: <20170105031118.2636.82374.stgit@john-Precision-Tower-5810>
On 17-01-04 07:11 PM, John Fastabend wrote:
> XDP programs can not consume multiple pages so we cap the MTU to
> avoid this case. Virtio-net however only checks the MTU at XDP
> program load and does not block MTU changes after the program
> has loaded.
>
> This patch sets/clears the max_mtu value at XDP load/unload time.
>
> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
> ---
> drivers/net/virtio_net.c | 26 ++++++++++++++++++++++----
> 1 file changed, 22 insertions(+), 4 deletions(-)
[...]
> static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog)
> {
> - unsigned long int max_sz = PAGE_SIZE - sizeof(struct padded_vnet_hdr);
> struct virtnet_info *vi = netdev_priv(dev);
> struct bpf_prog *old_prog;
> + unsigned long int max_sz;
> u16 xdp_qp = 0, curr_qp;
> int i, err;
>
> @@ -1720,6 +1737,7 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog)
> return -EINVAL;
> }
>
> + max_sz = virtnet_xdp_mtu(prog, vi);
> if (dev->mtu > max_sz) {
> netdev_warn(dev, "XDP requires MTU less than %lu\n", max_sz);
> return -EINVAL;
> @@ -1748,6 +1766,9 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog)
> virtnet_set_queues(vi, curr_qp);
> return PTR_ERR(prog);
> }
> + dev->max_mtu = max_sz;
> + } else {
> + dev->max_mtu = ETH_MAX_MTU;
> }
oops v2 needed. The else branch is not required anymore. :/
next prev parent reply other threads:[~2017-01-05 3:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-05 3:11 [net PATCH 1/2] virtio_net: cap mtu when XDP programs are running John Fastabend
2017-01-05 3:11 ` [net PATCH 2/2] virtio_net: use dev_kfree_skb for small buffer XDP receive John Fastabend
2017-01-05 3:14 ` John Fastabend [this message]
2017-01-05 3:18 ` [net PATCH 1/2] virtio_net: cap mtu when XDP programs are running Michael S. Tsirkin
2017-01-05 9:34 ` Jason Wang
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=586DB9F9.9090701@gmail.com \
--to=john.fastabend@gmail.com \
--cc=jasowang@redhat.com \
--cc=john.r.fastabend@intel.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
/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 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.