summaryrefslogtreecommitdiff
path: root/src/devices
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-10-12 19:36:09 +0200
committerThomas Haller <thaller@redhat.com>2017-10-23 17:53:22 +0200
commit667aed8aeb3ebd7f3abbf34fd6acf16d9dcd4dff (patch)
tree495a64ac53ab39a8bb55efa8750464cf5e1e25d0 /src/devices
parent05c4497bddffbd1ab024d2f249b3e2400373d325 (diff)
downloadNetworkManager-667aed8aeb3ebd7f3abbf34fd6acf16d9dcd4dff.tar.gz
device: reset MTU when VLAN's parent device changes MTU
Kernel does not allow setting the MTU of a VLAN larger then the MTU of the underlying device. Hence, we might initially fail to set a large MTU of the VLAN, but we have to retry when the MTU of the parent changes. https://bugzilla.redhat.com/show_bug.cgi?id=1414901
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/nm-device-private.h2
-rw-r--r--src/devices/nm-device-vlan.c21
-rw-r--r--src/devices/nm-device.c19
3 files changed, 39 insertions, 3 deletions
diff --git a/src/devices/nm-device-private.h b/src/devices/nm-device-private.h
index 416ae845c8..f1486c5490 100644
--- a/src/devices/nm-device-private.h
+++ b/src/devices/nm-device-private.h
@@ -118,6 +118,8 @@ gint64 nm_device_get_configured_mtu_from_connection_default (NMDevice *self,
guint32 nm_device_get_configured_mtu_for_wired (NMDevice *self, gboolean *out_is_user_config);
+void nm_device_commit_mtu (NMDevice *self);
+
/*****************************************************************************/
#define NM_DEVICE_CLASS_DECLARE_TYPES(klass, conn_type, ...) \
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index 06f19c408c..e30dae7449 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -51,6 +51,7 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMDeviceVlan,
typedef struct {
gulong parent_state_id;
gulong parent_hwaddr_id;
+ gulong parent_mtu_id;
guint vlan_id;
} NMDeviceVlanPrivate;
@@ -86,6 +87,17 @@ parent_state_changed (NMDevice *parent,
}
static void
+parent_mtu_maybe_changed (NMDevice *parent,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ /* the MTU of a VLAN device is limited by the parent's MTU.
+ *
+ * When the parent's MTU changes, try to re-set the MTU. */
+ nm_device_commit_mtu (user_data);
+}
+
+static void
parent_hwaddr_maybe_changed (NMDevice *parent,
GParamSpec *pspec,
gpointer user_data)
@@ -143,6 +155,7 @@ parent_changed_notify (NMDevice *device,
* parent_changed_notify(). */
nm_clear_g_signal_handler (old_parent, &priv->parent_state_id);
nm_clear_g_signal_handler (old_parent, &priv->parent_hwaddr_id);
+ nm_clear_g_signal_handler (old_parent, &priv->parent_mtu_id);
if (new_parent) {
priv->parent_state_id = g_signal_connect (new_parent,
@@ -154,6 +167,10 @@ parent_changed_notify (NMDevice *device,
G_CALLBACK (parent_hwaddr_maybe_changed), device);
parent_hwaddr_maybe_changed (new_parent, NULL, self);
+ priv->parent_mtu_id = g_signal_connect (new_parent, "notify::" NM_DEVICE_MTU,
+ G_CALLBACK (parent_mtu_maybe_changed), device);
+ parent_mtu_maybe_changed (new_parent, NULL, self);
+
/* Set parent-dependent unmanaged flag */
nm_device_set_unmanaged_by_flags (device,
NM_UNMANAGED_PARENT,
@@ -482,8 +499,10 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
/* Change MAC address to parent's one if needed */
parent_device = nm_device_parent_get_device (device);
- if (parent_device)
+ if (parent_device) {
parent_hwaddr_maybe_changed (parent_device, NULL, device);
+ parent_mtu_maybe_changed (parent_device, NULL, device);
+ }
s_vlan = (NMSettingVlan *) nm_device_get_applied_setting (device, NM_TYPE_SETTING_VLAN);
if (s_vlan) {
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index f3ae934e22..9a5a401365 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -7231,8 +7231,7 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
return;
if (nm_device_sys_iface_state_is_external_or_assume (self)) {
- /* for assumed connections we don't tamper with the MTU. This is
- * a bug and supposed to be fixed by the unmanaged/assumed rework. */
+ /* for assumed connections we don't tamper with the MTU. */
return;
}
@@ -7354,6 +7353,22 @@ _commit_mtu (NMDevice *self, const NMIP4Config *config)
#undef _IP6_MTU_SYS
}
+void
+nm_device_commit_mtu (NMDevice *self)
+{
+ NMDeviceState state;
+
+ g_return_if_fail (NM_IS_DEVICE (self));
+
+ state = nm_device_get_state (self);
+ if ( state >= NM_DEVICE_STATE_CONFIG
+ && state < NM_DEVICE_STATE_DEACTIVATING) {
+ _LOGT (LOGD_DEVICE, "mtu: commit-mtu...");
+ _commit_mtu (self, NM_DEVICE_GET_PRIVATE (self)->ip4_config);
+ } else
+ _LOGT (LOGD_DEVICE, "mtu: commit-mtu... skip due to state %s", nm_device_state_to_str (state));
+}
+
static void
ndisc_config_changed (NMNDisc *ndisc, const NMNDiscData *rdata, guint changed_int, NMDevice *self)
{