diff options
author | Thomas Haller <thaller@redhat.com> | 2021-09-16 16:50:15 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-09-21 08:29:47 +0200 |
commit | b7b275deadd60670097078e70288457f3f247f96 (patch) | |
tree | 851d0c67c7e0fca822925a51fdc21d7f082b2c44 | |
parent | 44e484a6aa14c388c28750df2cb26b4810b3b399 (diff) | |
download | NetworkManager-b7b275deadd60670097078e70288457f3f247f96.tar.gz |
initrd: warn about disabling autoneg without setting speed
To NetworkManager, "autoneg=FALSE && speed=0" has the meaning to
not configure these options and leave whatever is configured previously.
That is also the default.
Explicitly configuring "rd.ethtool=eth0:off:0" is thus likely a misconfiguration,
because it tells NetworkManager to not configure the interface.
Note that the user can configure that, via "rd.ethtool=eth0::", that
is by omitting all parameters. That is a valid configuration and causes
no warning. The reason to support this silently, is so that we can
add in the future more positional arguments that the user can set
without changing autoneg/speed.
-rw-r--r-- | src/nm-initrd-generator/nmi-cmdline-reader.c | 5 | ||||
-rw-r--r-- | src/nm-initrd-generator/tests/test-cmdline-reader.c | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/nm-initrd-generator/nmi-cmdline-reader.c b/src/nm-initrd-generator/nmi-cmdline-reader.c index f6aa87b924..9606b45427 100644 --- a/src/nm-initrd-generator/nmi-cmdline-reader.c +++ b/src/nm-initrd-generator/nmi-cmdline-reader.c @@ -1205,6 +1205,11 @@ reader_parse_ethtool(Reader *reader, char *argument) _LOGW(LOGD_CORE, "Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set"); } + if (speed == 0 && autoneg == FALSE) { + _LOGW(LOGD_CORE, + "rd.ethtool: autoneg ignored. Cannot disable autoneg without setting speed"); + } + if (autoneg == -1) autoneg = FALSE; diff --git a/src/nm-initrd-generator/tests/test-cmdline-reader.c b/src/nm-initrd-generator/tests/test-cmdline-reader.c index 6f747fed1a..c20f8c29bd 100644 --- a/src/nm-initrd-generator/tests/test-cmdline-reader.c +++ b/src/nm-initrd-generator/tests/test-cmdline-reader.c @@ -2330,14 +2330,20 @@ test_rd_ethtool(void) _ethtool_check("rd.ethtool=eth0:on::", TRUE, 0); _ethtool_check("rd.ethtool=eth0:on:0:", TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); _ethtool_check("rd.ethtool=eth0:off", FALSE, 0); _ethtool_check("rd.ethtool=eth0:true", TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); _ethtool_check("rd.ethtool=eth0:false", FALSE, 0); _ethtool_check("rd.ethtool=eth0:1", TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); _ethtool_check("rd.ethtool=eth0:0", FALSE, 0); NMTST_EXPECT_NM_WARN( @@ -2397,13 +2403,25 @@ test_rd_ethtool(void) NMTST_EXPECT_NM_WARN("cmdline-reader: Impossible to set rd.ethtool options: invalid format"); _ethtool_check_inval("rd.ethtool=:::"); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:0", "rd.ethtool=eth0:on"), TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:0", "rd.ethtool=eth0:off"), FALSE, 0); _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:on:0", "rd.ethtool=eth0:on"), TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:on:0", "rd.ethtool=eth0:off"), FALSE, 0); _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:100", "rd.ethtool=eth0:on"), TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:100", "rd.ethtool=eth0:off"), FALSE, 0); _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:on:100", "rd.ethtool=eth0:on"), TRUE, 0); + NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg " + "without setting speed"); _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:on:100", "rd.ethtool=eth0:off"), FALSE, 0); _ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:100", "rd.ethtool=eth0:"), FALSE, 0); } |