From ad3fdcd90dd221e93830526bdde37f55d26262a8 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 7 Mar 2017 10:27:11 +0100 Subject: [PATCH] device: allow reapply of MTU The MTU is reapplied together with IP configuration: modify device subclasses to announce they support the property in can_reapply_change(). --- src/devices/nm-device-ethernet.c | 1 + src/devices/nm-device-ip-tunnel.c | 28 ++++++++++++++++++++++++++++ src/devices/wifi/nm-device-wifi.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 9913378ea..55867516f 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -1637,6 +1637,7 @@ can_reapply_change (NMDevice *device, return nm_device_hash_check_invalid_keys (diffs, NM_SETTING_WIRED_SETTING_NAME, error, + NM_SETTING_WIRED_MTU, /* reapplied with IP config */ NM_SETTING_WIRED_SPEED, NM_SETTING_WIRED_DUPLEX, NM_SETTING_WIRED_AUTO_NEGOTIATE, diff --git a/src/devices/nm-device-ip-tunnel.c b/src/devices/nm-device-ip-tunnel.c index 409551121..ab3f34225 100644 --- a/src/devices/nm-device-ip-tunnel.c +++ b/src/devices/nm-device-ip-tunnel.c @@ -784,6 +784,33 @@ unrealize_notify (NMDevice *device) update_properties_from_ifindex (device, 0); } +static gboolean +can_reapply_change (NMDevice *device, + const char *setting_name, + NMSetting *s_old, + NMSetting *s_new, + GHashTable *diffs, + GError **error) +{ + NMDeviceClass *device_class; + + /* Only handle ip-tunnel setting here, delegate other settings to parent class */ + if (nm_streq (setting_name, NM_SETTING_IP_TUNNEL_SETTING_NAME)) { + return nm_device_hash_check_invalid_keys (diffs, + NM_SETTING_IP_TUNNEL_SETTING_NAME, + error, + NM_SETTING_IP_TUNNEL_MTU); /* reapplied with IP config */ + } + + device_class = NM_DEVICE_CLASS (nm_device_ip_tunnel_parent_class); + return device_class->can_reapply_change (device, + setting_name, + s_old, + s_new, + diffs, + error); +} + /*****************************************************************************/ static void @@ -891,6 +918,7 @@ nm_device_ip_tunnel_class_init (NMDeviceIPTunnelClass *klass) object_class->set_property = set_property; device_class->link_changed = link_changed; + device_class->can_reapply_change = can_reapply_change; device_class->complete_connection = complete_connection; device_class->update_connection = update_connection; device_class->check_connection_compatible = check_connection_compatible; diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index b4e42d45e..a02bb0999 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -3067,6 +3067,33 @@ set_enabled (NMDevice *device, gboolean enabled) } } +static gboolean +can_reapply_change (NMDevice *device, + const char *setting_name, + NMSetting *s_old, + NMSetting *s_new, + GHashTable *diffs, + GError **error) +{ + NMDeviceClass *device_class; + + /* Only handle wireless setting here, delegate other settings to parent class */ + if (nm_streq (setting_name, NM_SETTING_WIRELESS_SETTING_NAME)) { + return nm_device_hash_check_invalid_keys (diffs, + NM_SETTING_WIRELESS_SETTING_NAME, + error, + NM_SETTING_WIRELESS_MTU); /* reapplied with IP config */ + } + + device_class = NM_DEVICE_CLASS (nm_device_wifi_parent_class); + return device_class->can_reapply_change (device, + setting_name, + s_old, + s_new, + diffs, + error); +} + /*****************************************************************************/ static void @@ -3232,6 +3259,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass) parent_class->deactivate = deactivate; parent_class->deactivate_reset_hw_addr = deactivate_reset_hw_addr; parent_class->unmanaged_on_quit = unmanaged_on_quit; + parent_class->can_reapply_change = can_reapply_change; parent_class->state_changed = device_state_changed;