Blame SOURCES/1002-initrd-apply-mtu-to-bond-connection.patch

964b59
From 9ab6906ea1c2ddd23a3926b35ed75128dd302d13 Mon Sep 17 00:00:00 2001
964b59
From: Beniamino Galvani <bgalvani@redhat.com>
964b59
Date: Mon, 1 Mar 2021 21:16:08 +0100
964b59
Subject: [PATCH] initrd: apply the MTU from bond= argument to the bond
964b59
 connection
964b59
964b59
Currently the MTU specified in:
964b59
964b59
 bond=<bondname>[:<bondslaves>:[:<options>[:<mtu>]]]
964b59
964b59
gets applied to the bond ports. Instead it should be applied to the
964b59
bond itself.
964b59
964b59
Fixes: ecc074b2f8a6 ('initrd: add command line parser')
964b59
964b59
https://bugzilla.redhat.com/show_bug.cgi?id=1932502
964b59
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/767
964b59
(cherry picked from commit 8df3ef5063cf0f8ee904f8fd39e9e64cc60836eb)
964b59
(cherry picked from commit 43d16d2cd63a3443704ca7bb539ba5cb673ba183)
964b59
---
964b59
 src/core/initrd/nmi-cmdline-reader.c        | 5 +++--
964b59
 src/core/initrd/tests/test-cmdline-reader.c | 7 ++++++-
964b59
 2 files changed, 9 insertions(+), 3 deletions(-)
964b59
964b59
diff --git a/src/core/initrd/nmi-cmdline-reader.c b/src/core/initrd/nmi-cmdline-reader.c
964b59
index 508ef2b25c..5f40f63ef2 100644
964b59
--- a/src/core/initrd/nmi-cmdline-reader.c
964b59
+++ b/src/core/initrd/nmi-cmdline-reader.c
964b59
@@ -764,6 +764,9 @@ reader_parse_master(Reader *reader, char *argument, const char *type_name, const
964b59
         mtu = get_word(&argument, ':');
964b59
     }
964b59
 
964b59
+    if (mtu)
964b59
+        connection_set(connection, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MTU, mtu);
964b59
+
964b59
     do {
964b59
         slave = get_word(&slaves, ',');
964b59
         if (slave == NULL)
964b59
@@ -777,8 +780,6 @@ reader_parse_master(Reader *reader, char *argument, const char *type_name, const
964b59
                      NM_SETTING_CONNECTION_MASTER,
964b59
                      master,
964b59
                      NULL);
964b59
-        if (mtu)
964b59
-            connection_set(connection, NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MTU, mtu);
964b59
     } while (slaves && *slaves != '\0');
964b59
 
964b59
     if (argument && *argument)
964b59
diff --git a/src/core/initrd/tests/test-cmdline-reader.c b/src/core/initrd/tests/test-cmdline-reader.c
964b59
index 33fb22d364..4b450aae0f 100644
964b59
--- a/src/core/initrd/tests/test-cmdline-reader.c
964b59
+++ b/src/core/initrd/tests/test-cmdline-reader.c
964b59
@@ -825,13 +825,14 @@ test_bond(void)
964b59
 {
964b59
     gs_unref_hashtable GHashTable *connections = NULL;
964b59
     const char *const *            ARGV        = NM_MAKE_STRV("rd.route=192.0.2.53::bong0",
964b59
-                                           "bond=bong0:eth0,eth1:mode=balance-rr",
964b59
+                                           "bond=bong0:eth0,eth1:mode=balance-rr:9000",
964b59
                                            "nameserver=203.0.113.53");
964b59
     NMConnection *                 connection;
964b59
     NMSettingConnection *          s_con;
964b59
     NMSettingIPConfig *            s_ip4;
964b59
     NMSettingIPConfig *            s_ip6;
964b59
     NMSettingBond *                s_bond;
964b59
+    NMSettingWired *               s_wired;
964b59
     NMIPRoute *                    ip_route;
964b59
     const char *                   master_uuid;
964b59
 
964b59
@@ -847,6 +848,10 @@ test_bond(void)
964b59
     master_uuid = nm_connection_get_uuid(connection);
964b59
     g_assert(master_uuid);
964b59
 
964b59
+    s_wired = nm_connection_get_setting_wired(connection);
964b59
+    g_assert(s_wired);
964b59
+    g_assert_cmpint(nm_setting_wired_get_mtu(s_wired), ==, 9000);
964b59
+
964b59
     s_ip4 = nm_connection_get_setting_ip4_config(connection);
964b59
     g_assert(s_ip4);
964b59
     g_assert_cmpstr(nm_setting_ip_config_get_method(s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_AUTO);
964b59
-- 
964b59
2.29.2
964b59