From 4134023a298040bd55260ef00984989eb1ff484d Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 5 Dec 2019 15:39:32 +0100 Subject: [PATCH 1/2] infiniband: allow reapply of MTU (cherry picked from commit ceeefa82c54fe1e37f9a97ccf98dc9cb8773b0e6) (cherry picked from commit 1aedf602440f70aef4dfc38ba552bf40ebf184c4) --- src/devices/nm-device-infiniband.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index e39329a9c4..437f7861ca 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -209,6 +209,32 @@ update_connection (NMDevice *device, NMConnection *connection) g_object_set (G_OBJECT (s_infiniband), NM_SETTING_INFINIBAND_TRANSPORT_MODE, transport_mode, NULL); } +static gboolean +can_reapply_change (NMDevice *device, + const char *setting_name, + NMSetting *s_old, + NMSetting *s_new, + GHashTable *diffs, + GError **error) +{ + NMDeviceClass *device_class; + + if (nm_streq (setting_name, NM_SETTING_INFINIBAND_SETTING_NAME)) { + return nm_device_hash_check_invalid_keys (diffs, + NM_SETTING_INFINIBAND_SETTING_NAME, + error, + NM_SETTING_INFINIBAND_MTU); /* reapplied with IP config */ + } + + device_class = NM_DEVICE_CLASS (nm_device_infiniband_parent_class); + return device_class->can_reapply_change (device, + setting_name, + s_old, + s_new, + diffs, + error); +} + static gboolean create_and_realize (NMDevice *device, NMConnection *connection, @@ -361,6 +387,7 @@ nm_device_infiniband_class_init (NMDeviceInfinibandClass *klass) device_class->connection_type_check_compatible = NM_SETTING_INFINIBAND_SETTING_NAME; device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES (NM_LINK_TYPE_INFINIBAND); + device_class->can_reapply_change = can_reapply_change; device_class->create_and_realize = create_and_realize; device_class->unrealize = unrealize; device_class->get_generic_capabilities = get_generic_capabilities; From 0064401e35674093aaa2f4d05c30cbc38ec01fb2 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 5 Dec 2019 15:39:56 +0100 Subject: [PATCH 2/2] device: always allow reapply of MTU from wired setting Many device types take the MTU value from the wired setting; usually they don't implement the can_reapply_change() method and so the MTU can't be changed with the Reapply() API. Instead of implementing the method for all such devices to support the same property (adding a lot of duplicated code), add a check in NMDevice to allow the reapply of MTU when we recognize that the device uses the MTU from the wired setting. Device types can still decide to implement can_reapply_change() and support whatever properties they want, even from the wired setting. (cherry picked from commit 9339d3310e48e14f58428ec923ed9c653df1693b) (cherry picked from commit 1191eba15aee386c8f01dc931da5925712bdbaf8) --- src/devices/nm-device.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 81913ca9f1..b2295ef1ae 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -11497,6 +11497,14 @@ can_reapply_change (NMDevice *self, NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_SETTING_NAME)) { return TRUE; + } else if ( nm_streq (setting_name, NM_SETTING_WIRED_SETTING_NAME) + && NM_IN_SET (NM_DEVICE_GET_CLASS (self)->get_configured_mtu, + nm_device_get_configured_mtu_wired_parent, + nm_device_get_configured_mtu_for_wired)) { + return nm_device_hash_check_invalid_keys (diffs, + NM_SETTING_WIRED_SETTING_NAME, + error, + NM_SETTING_WIRED_MTU); } else { g_set_error (error, NM_DEVICE_ERROR,