mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-15 18:18:06 +02:00
device: allow autoconnect on external
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.
This commit is contained in:
parent
2f25e96f5d
commit
bcc9d2b0c2
4 changed files with 21 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17104,6 +17104,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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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__ */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue