Blob Blame History Raw
From 29fb28ca6cf192442886b11c85a8581e2e5c3518 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Mon, 10 Apr 2017 18:19:18 +0200
Subject: [PATCH] vlan: use parent interface mtu as default

VLANs already inherit the MTU from parent device when manually
activated. At boot, since the vlan interface is created before
activating the parent, the MTU is left to the default value.

Fix this by inheriting the MTU from parent when activating the
VLAN. Note that this change is effective only when the connection has
an actual IPv4 configuration; for all other cases users should
explicitly set the desired MTU value in the 'ethernet.mtu' property.

See master commit 7dde8d810604 ("vlan: use parent interface mtu as default")

https://bugzilla.redhat.com/show_bug.cgi?id=1439166
(cherry picked from commit 1c06d66a056b6a31e01ad3c91a15e80f3ba79078)
---
 src/devices/nm-device-vlan.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index 461bae6..b053fcc 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -598,19 +598,29 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
 static void
 ip4_config_pre_commit (NMDevice *device, NMIP4Config *config)
 {
+	NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
 	NMConnection *connection;
 	NMSettingWired *s_wired;
-	guint32 mtu;
+	guint32 mtu = 0;
+	int ifindex;
 
 	connection = nm_device_get_applied_connection (device);
 	g_assert (connection);
 
 	s_wired = nm_connection_get_setting_wired (connection);
-	if (s_wired) {
+	if (s_wired)
 		mtu = nm_setting_wired_get_mtu (s_wired);
-		if (mtu)
-			nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
+
+	if (!mtu && priv->parent) {
+		/* Inherit the MTU from parent device, if any */
+		ifindex = nm_device_get_ifindex (priv->parent);
+		if (ifindex > 0)
+			mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex);
 	}
+
+	if (mtu)
+		nm_ip4_config_set_mtu (config, mtu, NM_IP_CONFIG_SOURCE_USER);
+
 }
 
 /******************************************************************/
-- 
2.7.4