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.
This commit is contained in:
Thomas Haller 2021-09-16 16:50:15 +02:00
parent 44e484a6aa
commit b7b275dead
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 23 additions and 0 deletions

View file

@ -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;

View file

@ -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);
}