summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWen Liang <liangwen12year@gmail.com>2022-07-22 10:28:30 -0400
committerThomas Haller <thaller@redhat.com>2022-09-08 19:51:46 +0200
commit16d8ce4d4c8eddc9d84b98f60e3047cf729d39ea (patch)
tree85c10a60fce77f013af6fab3ffb6fdfcb6a0f986
parentd96bfb88b967b8f3f0282ce9a9e0dc7f16554174 (diff)
device: allow autoconnect on externalth/wl/tmp
In some scenarios, autoconnect should not be blocked if the device is activated on the external connection (e.g. autoconnect on the loopback device). Adding the `allow_autoconnect_on_external` flag to support such behavior.
-rw-r--r--src/core/devices/nm-device-loopback.c1
-rw-r--r--src/core/devices/nm-device.c6
-rw-r--r--src/core/devices/nm-device.h4
-rw-r--r--src/core/nm-policy.c13
4 files changed, 21 insertions, 3 deletions
diff --git a/src/core/devices/nm-device-loopback.c b/src/core/devices/nm-device-loopback.c
index 129cbb8a85..b7d8a24c3b 100644
--- a/src/core/devices/nm-device-loopback.c
+++ b/src/core/devices/nm-device-loopback.c
@@ -126,6 +126,7 @@ nm_device_loopback_class_init(NMDeviceLoopbackClass *klass)
device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE;
device_class->get_auto_ip_config_method = get_auto_ip_config_method;
device_class->get_configured_mtu = get_configured_mtu;
+ device_class->allow_autoconnect_on_external = TRUE;
device_class->can_reapply_change = can_reapply_change;
}
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c
index d3aa41b7cd..0a17f8f4f2 100644
--- a/src/core/devices/nm-device.c
+++ b/src/core/devices/nm-device.c
@@ -17108,6 +17108,12 @@ nm_device_clear_dns_lookup_data(NMDevice *self)
nm_clear_pointer(&priv->hostname_resolver_x[i], _hostname_resolver_free);
}
+gboolean
+nm_device_get_allow_autoconnect_on_external(NMDevice *self)
+{
+ return NM_DEVICE_GET_CLASS(self)->allow_autoconnect_on_external;
+}
+
static GInetAddress *
get_address_for_hostname_dns_lookup(NMDevice *self, int addr_family)
{
diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h
index cbf5929f54..decd8b16e5 100644
--- a/src/core/devices/nm-device.h
+++ b/src/core/devices/nm-device.h
@@ -208,6 +208,8 @@ typedef struct _NMDeviceClass {
bool can_reapply_change_ovs_external_ids : 1;
+ bool allow_autoconnect_on_external : 1;
+
NMRfkillType rfkill_type : 4;
void (*state_changed)(NMDevice *device,
@@ -819,4 +821,6 @@ nm_device_get_hostname_from_dns_lookup(NMDevice *self, int addr_family, gboolean
void nm_device_clear_dns_lookup_data(NMDevice *self);
+gboolean nm_device_get_allow_autoconnect_on_external(NMDevice *self);
+
#endif /* __NETWORKMANAGER_DEVICE_H__ */
diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c
index 5999bc0590..9205496c95 100644
--- a/src/core/nm-policy.c
+++ b/src/core/nm-policy.c
@@ -1338,7 +1338,9 @@ auto_activate_device(NMPolicy *self, NMDevice *device)
// but another connection now overrides the current one for that device,
// deactivate the device and activate the new connection instead of just
// bailing if the device is already active
- if (nm_device_get_act_request(device))
+ if (nm_device_get_act_request(device)
+ && !(nm_device_sys_iface_state_is_external(device)
+ && nm_device_get_allow_autoconnect_on_external(device)))
return;
if (!nm_device_autoconnect_allowed(device))
@@ -1666,8 +1668,13 @@ schedule_activate_check(NMPolicy *self, NMDevice *device)
return;
nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) {
- if (nm_active_connection_get_device(ac) == device)
- return;
+ if (nm_active_connection_get_device(ac) == device) {
+ if (nm_device_sys_iface_state_is_external(device)
+ && nm_device_get_allow_autoconnect_on_external(device)) {
+ /* pass */
+ } else
+ return;
+ }
}
nm_device_add_pending_action(device, NM_PENDING_ACTION_AUTOACTIVATE, TRUE);