From ae906e42da106cc1e86da59b6191e5263fa4c9b2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 25 Jan 2023 09:03:49 +0100 Subject: [PATCH] platform: detect EINVAL as failure to set the MTU Some drivers will reject an invalid MTU size with EINVAL. Quote from [1]: While investigating, I did notice that do_change_link in nm-linux-platform.c really ought to count -EINVAL as an MTU out-of-range error and not just -ERANGE. Even if the hardware supports a large MTU, if the transmit FIFO is set too small, stmmac_change_mtu [2] will return -EINVAL. For example, on my device, the maxmtu is 9000 but in practice I can't set an MTU larger than 4096 unless I first run ethtool --set-channels eno1 tx 3. [1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1198#note_1738311 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c?h=v6.1#n5577 (cherry picked from commit 621b41ebfa009ff11a41fe47f77fd162a98072a1) --- src/libnm-platform/nm-linux-platform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 762b1645e1..41d7163ae6 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -8217,7 +8217,8 @@ retry: } else if (NM_IN_SET(seq_result, -ESRCH, -ENOENT)) { log_detail = ", firmware not found"; result = -NME_PL_NO_FIRMWARE; - } else if (NM_IN_SET(seq_result, -ERANGE) && change_link_type == CHANGE_LINK_TYPE_SET_MTU) { + } else if (NM_IN_SET(seq_result, -ERANGE, -EINVAL) + && change_link_type == CHANGE_LINK_TYPE_SET_MTU) { log_detail = ", setting MTU to requested size is not possible"; result = -NME_PL_CANT_SET_MTU; } else if (NM_IN_SET(seq_result, -ENFILE) && change_link_type == CHANGE_LINK_TYPE_SET_ADDRESS