From 7dde8d81060405c9c8f45be76300cdac7868fba4 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 18 Jan 2017 11:25:38 +0100 Subject: [PATCH] vlan: use parent interface mtu as default After commit 22e8af624285 ("device: set a per-device default MTU on activation") we explicitly set the VLAN MTU to 1500 if not overridden by user settings. This has the advantage that the MTU is set to a predictable value, while before it could have different values depending on when the interface was created (for example, the interface would get a 1500 MTU if created during boot, or would inherit the parent's MTU if activated manually). However, a better default value is the MTU of the parent interface which is in most cases what the user wants. This value was the default before commit 22e8af624285 for manually activated connections. https://bugzilla.redhat.com/show_bug.cgi?id=1414186 --- src/devices/nm-device-vlan.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 3979c95d8d..45d7cf679c 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -572,6 +572,24 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason) return ret; } +static guint32 +get_configured_mtu (NMDevice *self, gboolean *out_is_user_config) +{ + guint32 mtu = 0; + int ifindex; + + mtu = nm_device_get_configured_mtu_for_wired (self, out_is_user_config); + if (*out_is_user_config) + return mtu; + + /* Inherit the MTU from parent device, if any */ + ifindex = nm_device_parent_get_ifindex (self); + if (ifindex > 0) + mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex); + + return mtu ?: NM_DEVICE_DEFAULT_MTU_WIRED; +} + /*****************************************************************************/ static void @@ -612,7 +630,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass) parent_class->unrealize_notify = unrealize_notify; parent_class->get_generic_capabilities = get_generic_capabilities; parent_class->act_stage1_prepare = act_stage1_prepare; - parent_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; + parent_class->get_configured_mtu = get_configured_mtu; parent_class->is_available = is_available; parent_class->parent_changed_notify = parent_changed_notify;