netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net PATCH] net: virtio: cap mtu when XDP programs are running
@ 2017-01-02 22:30 John Fastabend
  2017-01-03  6:14 ` Jason Wang
  0 siblings, 1 reply; 21+ messages in thread
From: John Fastabend @ 2017-01-02 22:30 UTC (permalink / raw)
  To: jasowang, mst
  Cc: john.r.fastabend, netdev, john.fastabend, alexei.starovoitov,
	daniel

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 |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 5deeda6..783e842 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1699,6 +1699,9 @@ static void virtnet_init_settings(struct net_device *dev)
 	.set_settings = virtnet_set_settings,
 };
 
+#define MIN_MTU ETH_MIN_MTU
+#define MAX_MTU ETH_MAX_MTU
+
 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);
@@ -1748,6 +1751,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;
 	}
 
 	vi->xdp_queue_pairs = xdp_qp;
@@ -2133,9 +2139,6 @@ static bool virtnet_validate_features(struct virtio_device *vdev)
 	return true;
 }
 
-#define MIN_MTU ETH_MIN_MTU
-#define MAX_MTU ETH_MAX_MTU
-
 static int virtnet_probe(struct virtio_device *vdev)
 {
 	int i, err;

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2017-01-11  3:37 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-02 22:30 [net PATCH] net: virtio: cap mtu when XDP programs are running John Fastabend
2017-01-03  6:14 ` Jason Wang
2017-01-03 16:48   ` John Fastabend
2017-01-04  3:16     ` Jason Wang
2017-01-04 18:57       ` John Fastabend
2017-01-05  3:09         ` Jason Wang
2017-01-09 23:05           ` Michael S. Tsirkin
2017-01-09 23:13             ` John Fastabend
2017-01-09 23:24               ` Michael S. Tsirkin
2017-01-09 23:49                 ` John Fastabend
2017-01-09 23:58                   ` Michael S. Tsirkin
2017-01-10  2:29                     ` Jason Wang
2017-01-10  2:51                       ` Michael S. Tsirkin
2017-01-10  3:30                         ` John Fastabend
2017-01-10  3:55                           ` Michael S. Tsirkin
2017-01-10  4:25                             ` John Fastabend
2017-01-10  5:00                               ` Michael S. Tsirkin
2017-01-11  3:37                                 ` Jason Wang
2017-01-10  3:34                         ` Jason Wang
2017-01-10 14:51                         ` Michael S. Tsirkin
2017-01-03 16:48   ` John Fastabend

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).