summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2021-03-01 21:16:08 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2021-03-08 10:31:51 +0100
commit8df3ef5063cf0f8ee904f8fd39e9e64cc60836eb (patch)
tree942531367ec4f94933d6e630fa740eaf38e15da6
parent7ad2b8f20a60c5c8faebda343c7ee948e11c0a93 (diff)
downloadNetworkManager-bg/initrd-bond-mtu.tar.gz
initrd: apply the MTU from bond= argument to the bond connectionbg/initrd-bond-mtu
Currently the MTU specified in: bond=<bondname>[:<bondslaves>:[:<options>[:<mtu>]]] gets applied to the bond ports. Instead it should be applied to the bond itself. Fixes: ecc074b2f8a6 ('initrd: add command line parser') https://bugzilla.redhat.com/show_bug.cgi?id=1932502 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/767
-rw-r--r--src/core/initrd/nmi-cmdline-reader.c5
-rw-r--r--src/core/initrd/tests/test-cmdline-reader.c7
2 files changed, 9 insertions, 3 deletions
diff --git a/src/core/initrd/nmi-cmdline-reader.c b/src/core/initrd/nmi-cmdline-reader.c
index 646faefbd3..d3e4bdf8be 100644
--- a/src/core/initrd/nmi-cmdline-reader.c
+++ b/src/core/initrd/nmi-cmdline-reader.c
@@ -757,6 +757,9 @@ reader_parse_master(Reader *reader, char *argument, const char *type_name, const
mtu = get_word(&argument, ':');
}
+ if (mtu)
+ connection_set(connection, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MTU, mtu);
+
do {
slave = get_word(&slaves, ',');
if (slave == NULL)
@@ -770,8 +773,6 @@ reader_parse_master(Reader *reader, char *argument, const char *type_name, const
NM_SETTING_CONNECTION_MASTER,
master,
NULL);
- if (mtu)
- connection_set(connection, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MTU, mtu);
} while (slaves && *slaves != '\0');
if (argument && *argument)
diff --git a/src/core/initrd/tests/test-cmdline-reader.c b/src/core/initrd/tests/test-cmdline-reader.c
index e1f7bd7030..153d9442df 100644
--- a/src/core/initrd/tests/test-cmdline-reader.c
+++ b/src/core/initrd/tests/test-cmdline-reader.c
@@ -825,13 +825,14 @@ test_bond(void)
{
gs_unref_hashtable GHashTable *connections = NULL;
const char *const * ARGV = NM_MAKE_STRV("rd.route=192.0.2.53::bong0",
- "bond=bong0:eth0,eth1:mode=balance-rr",
+ "bond=bong0:eth0,eth1:mode=balance-rr:9000",
"nameserver=203.0.113.53");
NMConnection * connection;
NMSettingConnection * s_con;
NMSettingIPConfig * s_ip4;
NMSettingIPConfig * s_ip6;
NMSettingBond * s_bond;
+ NMSettingWired * s_wired;
NMIPRoute * ip_route;
const char * master_uuid;
@@ -847,6 +848,10 @@ test_bond(void)
master_uuid = nm_connection_get_uuid(connection);
g_assert(master_uuid);
+ s_wired = nm_connection_get_setting_wired(connection);
+ g_assert(s_wired);
+ g_assert_cmpint(nm_setting_wired_get_mtu(s_wired), ==, 9000);
+
s_ip4 = nm_connection_get_setting_ip4_config(connection);
g_assert(s_ip4);
g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO);