diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2023-03-06 15:49:43 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2023-04-04 08:21:22 +0200 |
commit | 82d0fa2a87c5621c9b0412cf1914bb02130e4de5 (patch) | |
tree | 301a4a20493011ee406c6f5b965813a8f0485528 | |
parent | de8104c71c4bafb472f921cdbcca6e7750e6a1ef (diff) | |
download | NetworkManager-82d0fa2a87c5621c9b0412cf1914bb02130e4de5.tar.gz |
device: make detach_port() method asynchronous
This changes the signature of detach_port() to be asynchronous,
similarly to attach_port(). The implementation can return TRUE/FALSE
on immediate completion.
Current implementations return immediately and so there is no change
in behavior for now.
-rw-r--r-- | src/core/devices/nm-device-bond.c | 11 | ||||
-rw-r--r-- | src/core/devices/nm-device-bridge.c | 13 | ||||
-rw-r--r-- | src/core/devices/nm-device-vrf.c | 11 | ||||
-rw-r--r-- | src/core/devices/nm-device.c | 15 | ||||
-rw-r--r-- | src/core/devices/nm-device.h | 10 | ||||
-rw-r--r-- | src/core/devices/ovs/nm-device-ovs-bridge.c | 13 | ||||
-rw-r--r-- | src/core/devices/ovs/nm-device-ovs-port.c | 11 | ||||
-rw-r--r-- | src/core/devices/team/nm-device-team.c | 11 |
8 files changed, 76 insertions, 19 deletions
diff --git a/src/core/devices/nm-device-bond.c b/src/core/devices/nm-device-bond.c index cb32331921..8e0cf33fe6 100644 --- a/src/core/devices/nm-device-bond.c +++ b/src/core/devices/nm-device-bond.c @@ -695,8 +695,13 @@ attach_port(NMDevice *device, return TRUE; } -static void -detach_port(NMDevice *device, NMDevice *port, gboolean configure) +static NMTernary +detach_port(NMDevice *device, + NMDevice *port, + gboolean configure, + GCancellable *cancellable, + NMDeviceAttachPortCallback callback, + gpointer user_data) { NMDeviceBond *self = NM_DEVICE_BOND(device); gboolean success; @@ -758,6 +763,8 @@ detach_port(NMDevice *device, NMDevice *port, gboolean configure) _LOGI(LOGD_BOND, "bond port %s was detached", nm_device_get_ip_iface(port)); } } + + return TRUE; } static gboolean diff --git a/src/core/devices/nm-device-bridge.c b/src/core/devices/nm-device-bridge.c index a2d0db6192..c07b154979 100644 --- a/src/core/devices/nm-device-bridge.c +++ b/src/core/devices/nm-device-bridge.c @@ -1052,8 +1052,13 @@ attach_port(NMDevice *device, return TRUE; } -static void -detach_port(NMDevice *device, NMDevice *port, gboolean configure) +static NMTernary +detach_port(NMDevice *device, + NMDevice *port, + gboolean configure, + GCancellable *cancellable, + NMDeviceAttachPortCallback callback, + gpointer user_data) { NMDeviceBridge *self = NM_DEVICE_BRIDGE(device); gboolean success; @@ -1070,7 +1075,7 @@ detach_port(NMDevice *device, NMDevice *port, gboolean configure) if (ifindex_slave <= 0) { _LOGD(LOGD_TEAM, "bridge port %s is already detached", nm_device_get_ip_iface(port)); - return; + return TRUE; } if (configure) { @@ -1086,6 +1091,8 @@ detach_port(NMDevice *device, NMDevice *port, gboolean configure) } else { _LOGI(LOGD_BRIDGE, "bridge port %s was detached", nm_device_get_ip_iface(port)); } + + return TRUE; } static gboolean diff --git a/src/core/devices/nm-device-vrf.c b/src/core/devices/nm-device-vrf.c index b037e8e2a6..a13de1cb66 100644 --- a/src/core/devices/nm-device-vrf.c +++ b/src/core/devices/nm-device-vrf.c @@ -241,8 +241,13 @@ attach_port(NMDevice *device, return TRUE; } -static void -detach_port(NMDevice *device, NMDevice *port, gboolean configure) +static NMTernary +detach_port(NMDevice *device, + NMDevice *port, + gboolean configure, + GCancellable *cancellable, + NMDeviceAttachPortCallback callback, + gpointer user_data) { NMDeviceVrf *self = NM_DEVICE_VRF(device); gboolean success; @@ -277,6 +282,8 @@ detach_port(NMDevice *device, NMDevice *port, gboolean configure) _LOGI(LOGD_DEVICE, "VRF port %s was detached", nm_device_get_ip_iface(port)); } } + + return TRUE; } /*****************************************************************************/ diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 6117c6889a..8f697d5731 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -6402,10 +6402,17 @@ nm_device_master_release_slave(NMDevice *self, /* first, let subclasses handle the release ... */ if (info->slave_is_enslaved || nm_device_sys_iface_state_is_external(slave) - || release_type >= RELEASE_SLAVE_TYPE_CONFIG_FORCE) - NM_DEVICE_GET_CLASS(self)->detach_port(self, - slave, - release_type >= RELEASE_SLAVE_TYPE_CONFIG); + || release_type >= RELEASE_SLAVE_TYPE_CONFIG_FORCE) { + NMTernary ret; + + ret = NM_DEVICE_GET_CLASS(self)->detach_port(self, + slave, + release_type >= RELEASE_SLAVE_TYPE_CONFIG, + NULL, + NULL, + NULL); + nm_assert(NM_IN_SET(ret, TRUE, FALSE)); + } /* raise notifications about the release, including clearing is_enslaved. */ nm_device_slave_notify_release(slave, reason, release_type); diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index 581df9a358..4794d9af87 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -389,7 +389,15 @@ typedef struct _NMDeviceClass { GCancellable *cancellable, NMDeviceAttachPortCallback callback, gpointer user_data); - void (*detach_port)(NMDevice *self, NMDevice *port, gboolean configure); + /* This works similarly to attach_port(). However, current + * implementations don't report errors and so the only possible + * return values are TRUE and DEFAULT. */ + NMTernary (*detach_port)(NMDevice *self, + NMDevice *port, + gboolean configure, + GCancellable *cancellable, + NMDeviceAttachPortCallback callback, + gpointer user_data); void (*parent_changed_notify)(NMDevice *self, int old_ifindex, diff --git a/src/core/devices/ovs/nm-device-ovs-bridge.c b/src/core/devices/ovs/nm-device-ovs-bridge.c index 7b319af344..ff1917b133 100644 --- a/src/core/devices/ovs/nm-device-ovs-bridge.c +++ b/src/core/devices/ovs/nm-device-ovs-bridge.c @@ -97,9 +97,16 @@ attach_port(NMDevice *device, return TRUE; } -static void -detach_port(NMDevice *device, NMDevice *port, gboolean configure) -{} +static NMTernary +detach_port(NMDevice *device, + NMDevice *port, + gboolean configure, + GCancellable *cancellable, + NMDeviceAttachPortCallback callback, + gpointer user_data) +{ + return TRUE; +} void nm_device_ovs_reapply_connection(NMDevice *self, NMConnection *con_old, NMConnection *con_new) diff --git a/src/core/devices/ovs/nm-device-ovs-port.c b/src/core/devices/ovs/nm-device-ovs-port.c index 5510e39fbd..f9b24ee5ac 100644 --- a/src/core/devices/ovs/nm-device-ovs-port.c +++ b/src/core/devices/ovs/nm-device-ovs-port.c @@ -221,8 +221,13 @@ del_iface_cb(GError *error, gpointer user_data) g_object_unref(slave); } -static void -detach_port(NMDevice *device, NMDevice *port, gboolean configure) +static NMTernary +detach_port(NMDevice *device, + NMDevice *port, + gboolean configure, + GCancellable *cancellable, + NMDeviceAttachPortCallback callback, + gpointer user_data) { NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT(device); bool port_not_managed = !NM_IN_SET(nm_device_sys_iface_state_get(port), @@ -248,6 +253,8 @@ detach_port(NMDevice *device, NMDevice *port, gboolean configure) if (NM_IS_DEVICE_OVS_INTERFACE(port)) nm_device_update_from_platform_link(port, NULL); } + + return TRUE; } /*****************************************************************************/ diff --git a/src/core/devices/team/nm-device-team.c b/src/core/devices/team/nm-device-team.c index 3e3fe52b67..60b15049a0 100644 --- a/src/core/devices/team/nm-device-team.c +++ b/src/core/devices/team/nm-device-team.c @@ -913,8 +913,13 @@ attach_port(NMDevice *device, return TRUE; } -static void -detach_port(NMDevice *device, NMDevice *port, gboolean configure) +static NMTernary +detach_port(NMDevice *device, + NMDevice *port, + gboolean configure, + GCancellable *cancellable, + NMDeviceAttachPortCallback callback, + gpointer user_data) { NMDeviceTeam *self = NM_DEVICE_TEAM(device); NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self); @@ -964,6 +969,8 @@ detach_port(NMDevice *device, NMDevice *port, gboolean configure) _update_port_config(self, port_iface, "{}"); g_hash_table_remove(priv->port_configs, port_iface); } + + return TRUE; } static gboolean |