From 32ab60f960c59020a88fc00ca0e910e70e9f7148 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 18 Apr 2025 10:56:04 +0200 Subject: [PATCH] device: remove the "can_reapply_change_ovs_external_ids" device field NMDevices have a special "can_reapply_change_ovs_external_ids" boolean field indicating whether the device type supports reapplying the ovs-external-ids and ovs-other-config settings. Remove this field and use the standard can_reapply_change() method. No change in behavior is expected. --- src/core/devices/nm-device.c | 9 --- src/core/devices/nm-device.h | 2 - src/core/devices/ovs/nm-device-ovs-bridge.c | 28 +++++---- .../devices/ovs/nm-device-ovs-interface.c | 58 +++++++++++++------ src/core/devices/ovs/nm-device-ovs-port.c | 28 +++++---- 5 files changed, 74 insertions(+), 51 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 636a5fe91..fc6efb2b3 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -14020,15 +14020,6 @@ can_reapply_change(NMDevice *self, goto out_fail; } - if (NM_IN_STRSET(setting_name, - NM_SETTING_OVS_EXTERNAL_IDS_SETTING_NAME, - NM_SETTING_OVS_OTHER_CONFIG_SETTING_NAME) - && NM_DEVICE_GET_CLASS(self)->can_reapply_change_ovs_external_ids) { - /* TODO: this means, you cannot reapply changes to the external-ids for - * OVS system interfaces. */ - return TRUE; - } - out_fail: g_set_error(error, NM_DEVICE_ERROR, diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index 143e47eeb..9a663c2a9 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -209,8 +209,6 @@ typedef struct _NMDeviceClass { bool act_stage1_prepare_set_hwaddr_ethernet : 1; - bool can_reapply_change_ovs_external_ids : 1; - bool allow_autoconnect_on_external : 1; NMRfkillType rfkill_type : 4; diff --git a/src/core/devices/ovs/nm-device-ovs-bridge.c b/src/core/devices/ovs/nm-device-ovs-bridge.c index c9b1f4c6a..c9736eeb6 100644 --- a/src/core/devices/ovs/nm-device-ovs-bridge.c +++ b/src/core/devices/ovs/nm-device-ovs-bridge.c @@ -162,6 +162,11 @@ can_reapply_change(NMDevice *device, NM_SETTING_OVS_BRIDGE_STP_ENABLE); } + if (NM_IN_STRSET(setting_name, + NM_SETTING_OVS_EXTERNAL_IDS_SETTING_NAME, + NM_SETTING_OVS_OTHER_CONFIG_SETTING_NAME)) + return TRUE; + return device_class->can_reapply_change(device, setting_name, s_old, s_new, diffs, error); } @@ -194,16 +199,15 @@ nm_device_ovs_bridge_class_init(NMDeviceOvsBridgeClass *klass) device_class->connection_type_check_compatible = NM_SETTING_OVS_BRIDGE_SETTING_NAME; device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES(); - device_class->is_controller = TRUE; - device_class->get_type_description = get_type_description; - device_class->create_and_realize = create_and_realize; - device_class->unrealize = unrealize; - device_class->get_generic_capabilities = get_generic_capabilities; - device_class->act_stage3_ip_config = act_stage3_ip_config; - device_class->ready_for_ip_config = ready_for_ip_config; - device_class->attach_port = attach_port; - device_class->detach_port = detach_port; - device_class->can_reapply_change = can_reapply_change; - device_class->can_reapply_change_ovs_external_ids = TRUE; - device_class->reapply_connection = nm_device_ovs_reapply_connection; + device_class->is_controller = TRUE; + device_class->get_type_description = get_type_description; + device_class->create_and_realize = create_and_realize; + device_class->unrealize = unrealize; + device_class->get_generic_capabilities = get_generic_capabilities; + device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->ready_for_ip_config = ready_for_ip_config; + device_class->attach_port = attach_port; + device_class->detach_port = detach_port; + device_class->can_reapply_change = can_reapply_change; + device_class->reapply_connection = nm_device_ovs_reapply_connection; } diff --git a/src/core/devices/ovs/nm-device-ovs-interface.c b/src/core/devices/ovs/nm-device-ovs-interface.c index 06a1da15e..271dedeab 100644 --- a/src/core/devices/ovs/nm-device-ovs-interface.c +++ b/src/core/devices/ovs/nm-device-ovs-interface.c @@ -16,6 +16,8 @@ #include "nm-setting-ovs-bridge.h" #include "nm-setting-ovs-interface.h" #include "nm-setting-ovs-port.h" +#include "nm-setting-ovs-external-ids.h" +#include "nm-setting-ovs-other-config.h" #define _NMLOG_DEVICE_TYPE NMDeviceOvsInterface #include "devices/nm-device-logging.h" @@ -647,6 +649,28 @@ can_update_from_platform_link(NMDevice *device, const NMPlatformLink *plink) return !plink || nm_device_get_state(device) != NM_DEVICE_STATE_DEACTIVATING; } +static gboolean +can_reapply_change(NMDevice *device, + const char *setting_name, + NMSetting *s_old, + NMSetting *s_new, + GHashTable *diffs, + GError **error) +{ + NMDeviceClass *device_class = NM_DEVICE_CLASS(nm_device_ovs_interface_parent_class); + + if (NM_IN_STRSET(setting_name, + NM_SETTING_OVS_EXTERNAL_IDS_SETTING_NAME, + NM_SETTING_OVS_OTHER_CONFIG_SETTING_NAME)) { + /* TODO: it's currently not possible to reapply those settings on OVS + * system interfaces because they have type != "ovs-interface" (e.g. + * "ethernet") */ + return TRUE; + } + + return device_class->can_reapply_change(device, setting_name, s_old, s_new, diffs, error); +} + /*****************************************************************************/ static void @@ -712,21 +736,21 @@ nm_device_ovs_interface_class_init(NMDeviceOvsInterfaceClass *klass) device_class->connection_type_check_compatible = NM_SETTING_OVS_INTERFACE_SETTING_NAME; device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES(NM_LINK_TYPE_OPENVSWITCH); - device_class->can_auto_connect = can_auto_connect; - device_class->can_update_from_platform_link = can_update_from_platform_link; - device_class->deactivate = deactivate; - device_class->deactivate_async = deactivate_async; - device_class->get_type_description = get_type_description; - device_class->create_and_realize = create_and_realize; - device_class->get_generic_capabilities = get_generic_capabilities; - device_class->is_available = is_available; - device_class->check_connection_compatible = check_connection_compatible; - device_class->link_changed = link_changed; - device_class->act_stage3_ip_config = act_stage3_ip_config; - device_class->ready_for_ip_config = ready_for_ip_config; - device_class->can_unmanaged_external_down = can_unmanaged_external_down; - device_class->set_platform_mtu = set_platform_mtu; - device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; - device_class->can_reapply_change_ovs_external_ids = TRUE; - device_class->reapply_connection = nm_device_ovs_reapply_connection; + device_class->can_auto_connect = can_auto_connect; + device_class->can_update_from_platform_link = can_update_from_platform_link; + device_class->deactivate = deactivate; + device_class->deactivate_async = deactivate_async; + device_class->get_type_description = get_type_description; + device_class->create_and_realize = create_and_realize; + device_class->get_generic_capabilities = get_generic_capabilities; + device_class->is_available = is_available; + device_class->check_connection_compatible = check_connection_compatible; + device_class->link_changed = link_changed; + device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->ready_for_ip_config = ready_for_ip_config; + device_class->can_unmanaged_external_down = can_unmanaged_external_down; + device_class->set_platform_mtu = set_platform_mtu; + device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired; + device_class->can_reapply_change = can_reapply_change; + device_class->reapply_connection = nm_device_ovs_reapply_connection; } diff --git a/src/core/devices/ovs/nm-device-ovs-port.c b/src/core/devices/ovs/nm-device-ovs-port.c index e9928548f..0e3ef92c9 100644 --- a/src/core/devices/ovs/nm-device-ovs-port.c +++ b/src/core/devices/ovs/nm-device-ovs-port.c @@ -16,6 +16,8 @@ #include "nm-setting-connection.h" #include "nm-setting-ovs-port.h" #include "nm-setting-ovs-interface.h" +#include "nm-setting-ovs-external-ids.h" +#include "nm-setting-ovs-other-config.h" #include "nm-setting-wired.h" #define _NMLOG_DEVICE_TYPE NMDeviceOvsPort @@ -279,6 +281,11 @@ can_reapply_change(NMDevice *device, NM_SETTING_OVS_PORT_TRUNKS); } + if (NM_IN_STRSET(setting_name, + NM_SETTING_OVS_EXTERNAL_IDS_SETTING_NAME, + NM_SETTING_OVS_OTHER_CONFIG_SETTING_NAME)) + return TRUE; + return device_class->can_reapply_change(device, setting_name, s_old, s_new, diffs, error); } @@ -311,15 +318,14 @@ nm_device_ovs_port_class_init(NMDeviceOvsPortClass *klass) device_class->connection_type_check_compatible = NM_SETTING_OVS_PORT_SETTING_NAME; device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES(); - device_class->is_controller = TRUE; - device_class->get_type_description = get_type_description; - device_class->create_and_realize = create_and_realize; - device_class->get_generic_capabilities = get_generic_capabilities; - device_class->act_stage3_ip_config = act_stage3_ip_config; - device_class->ready_for_ip_config = ready_for_ip_config; - device_class->attach_port = attach_port; - device_class->detach_port = detach_port; - device_class->can_reapply_change = can_reapply_change; - device_class->can_reapply_change_ovs_external_ids = TRUE; - device_class->reapply_connection = nm_device_ovs_reapply_connection; + device_class->is_controller = TRUE; + device_class->get_type_description = get_type_description; + device_class->create_and_realize = create_and_realize; + device_class->get_generic_capabilities = get_generic_capabilities; + device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->ready_for_ip_config = ready_for_ip_config; + device_class->attach_port = attach_port; + device_class->detach_port = detach_port; + device_class->can_reapply_change = can_reapply_change; + device_class->reapply_connection = nm_device_ovs_reapply_connection; }