On 8 Nov 2019, at 2:34, William Tu wrote:

On Thu, Nov 07, 2019 at 03:01:18PM +0100, Eelco Chaudron wrote:
Any feedback on this?


On 1 Oct 2019, at 11:55, Eelco Chaudron wrote:

Drivers natively supporting AF_XDP will check that a configured MTU size
will not exceed the allowed size for AF_XDP. However, when the skb
compatibility mode is used there is no check and any value is accepted.
This, for example, is the case when using the TAP interface.

This fix adds a check to make sure only AF_XDP valid values are excepted.

Signed-off-by: Eelco Chaudron <echau...@redhat.com>
---
lib/netdev-afxdp.c |   17 +++++++++++++++++
lib/netdev-afxdp.h |    1 +
lib/netdev-linux.c |    9 +++++++++
3 files changed, 27 insertions(+)

diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c
index 6e0180327..140150f29 100644
--- a/lib/netdev-afxdp.c
+++ b/lib/netdev-afxdp.c
@@ -1001,6 +1001,23 @@ netdev_afxdp_destruct(struct netdev *netdev)
    ovs_mutex_destroy(&dev->mutex);
}

+int
+netdev_afxdp_verify_mtu_size(const struct netdev *netdev, int mtu)
+{
+    /*
+ * If a device is used in xdpmode skb, no driver-specific MTU size is
+     * checked and any value is allowed resulting in packet drops.
+ * This check will verify the maximum supported value based on the
+     * buffer size allocated and the additional headroom required.
+     */
+    if (netdev == NULL || mtu <= 0
+ || mtu > (FRAME_SIZE - OVS_XDP_HEADROOM - XDP_PACKET_HEADROOM)) {

I remember XDP max MTU = 3520 bytes,
and it's (page_size(4096) - headroom(256) - shinfo(320))
so here we should also subtract shinfo?

That is the theoretical maximum, however you’re code allocated chunks of FRAME_SIZE, so that dictated the maximum value.

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to