summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-10-24 09:10:49 +0200
committerThomas Haller <thaller@redhat.com>2017-10-31 19:35:28 +0100
commit361a199a0639dd8a82c61912df301028efca5f33 (patch)
tree4f4ccdccdc9bb53df6aea331d4968ee7f26ff290
parent447dc874ce8c8a9f6669d73f655de17fe05365d4 (diff)
downloadNetworkManager-361a199a0639dd8a82c61912df301028efca5f33.tar.gz
device: move resetting autoconnect retries from subtype to NMDevice
-rw-r--r--src/devices/nm-device-ethernet.c20
-rw-r--r--src/devices/nm-device-macsec.c17
-rw-r--r--src/devices/nm-device.c23
-rw-r--r--src/devices/nm-device.h1
-rw-r--r--src/settings/nm-settings-connection.c5
5 files changed, 31 insertions, 35 deletions
diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c
index ef7530212d..8b9ae1d8ba 100644
--- a/src/devices/nm-device-ethernet.c
+++ b/src/devices/nm-device-ethernet.c
@@ -255,22 +255,6 @@ _update_s390_subchannels (NMDeviceEthernet *self)
}
static void
-reset_8021x_autoconnect_retries (NMDevice *device)
-{
- NMActRequest *req;
- NMSettingsConnection *connection;
-
- req = nm_device_get_act_request (device);
- if ( req
- && nm_device_get_applied_setting (device, NM_TYPE_SETTING_802_1X)) {
- connection = nm_act_request_get_settings_connection (req);
- g_return_if_fail (connection);
- /* Reset autoconnect retries on success, failure, or when deactivating */
- nm_settings_connection_autoconnect_retries_reset (connection);
- }
-}
-
-static void
device_state_changed (NMDevice *device,
NMDeviceState new_state,
NMDeviceState old_state,
@@ -283,7 +267,7 @@ device_state_changed (NMDevice *device,
NM_DEVICE_STATE_ACTIVATED,
NM_DEVICE_STATE_FAILED,
NM_DEVICE_STATE_DISCONNECTED))
- reset_8021x_autoconnect_retries (device);
+ nm_device_autoconnect_retries_reset (device, NM_TYPE_SETTING_802_1X);
}
static void
@@ -1356,7 +1340,7 @@ deactivate (NMDevice *device)
GError *error = NULL;
/* Clear wired secrets tries when deactivating */
- reset_8021x_autoconnect_retries (device);
+ nm_device_autoconnect_retries_reset (device, NM_TYPE_SETTING_802_1X);
nm_clear_g_source (&priv->pppoe_wait_id);
diff --git a/src/devices/nm-device-macsec.c b/src/devices/nm-device-macsec.c
index cda175e175..e5df99bd39 100644
--- a/src/devices/nm-device-macsec.c
+++ b/src/devices/nm-device-macsec.c
@@ -738,21 +738,6 @@ link_changed (NMDevice *device,
static void
-reset_autoconnect_retries (NMDevice *device)
-{
- NMActRequest *req;
- NMSettingsConnection *connection;
-
- req = nm_device_get_act_request (device);
- if (req) {
- connection = nm_act_request_get_settings_connection (req);
- g_return_if_fail (connection);
- /* Reset autoconnect retries on success, failure, or when deactivating */
- nm_settings_connection_autoconnect_retries_reset (connection);
- }
-}
-
-static void
device_state_changed (NMDevice *device,
NMDeviceState new_state,
NMDeviceState old_state,
@@ -764,7 +749,7 @@ device_state_changed (NMDevice *device,
if ( new_state == NM_DEVICE_STATE_ACTIVATED
|| new_state == NM_DEVICE_STATE_FAILED
|| new_state == NM_DEVICE_STATE_DISCONNECTED)
- reset_autoconnect_retries (device);
+ nm_device_autoconnect_retries_reset (device, G_TYPE_NONE);
}
/******************************************************************/
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index fc6d216690..a6ad278e6d 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -4213,6 +4213,29 @@ nm_device_set_enabled (NMDevice *self, gboolean enabled)
NM_DEVICE_GET_CLASS (self)->set_enabled (self, enabled);
}
+void
+nm_device_autoconnect_retries_reset (NMDevice *device, GType required_applied_setting)
+{
+ NMActRequest *req;
+ NMSettingsConnection *connection;
+
+ req = nm_device_get_act_request (device);
+ if (!req)
+ return;
+
+ if ( !NM_IN_SET (required_applied_setting, G_TYPE_INVALID, G_TYPE_NONE)
+ && !nm_device_get_applied_setting (device, required_applied_setting)) {
+ /* if the setting doesn't have the required setting in the applied
+ * connection, we do nothing. */
+ return;
+ }
+
+ connection = nm_act_request_get_settings_connection (req);
+
+ /* Reset autoconnect retries on success, failure, or when deactivating */
+ nm_settings_connection_autoconnect_retries_reset (connection);
+}
+
/**
* nm_device_get_autoconnect:
* @self: the #NMDevice
diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h
index 921db8aa5e..aafa31d3af 100644
--- a/src/devices/nm-device.h
+++ b/src/devices/nm-device.h
@@ -663,6 +663,7 @@ gboolean nm_device_unrealize (NMDevice *device,
void nm_device_update_from_platform_link (NMDevice *self,
const NMPlatformLink *plink);
+void nm_device_autoconnect_retries_reset (NMDevice *device, GType required_applied_setting);
gboolean nm_device_get_autoconnect (NMDevice *device);
void nm_device_set_autoconnect_intern (NMDevice *device, gboolean autoconnect);
void nm_device_emit_recheck_auto_activate (NMDevice *device);
diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
index 6f66394c12..a7b28792b2 100644
--- a/src/settings/nm-settings-connection.c
+++ b/src/settings/nm-settings-connection.c
@@ -2576,10 +2576,13 @@ void
nm_settings_connection_autoconnect_retries_set (NMSettingsConnection *self,
int retries)
{
- NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
+ NMSettingsConnectionPrivate *priv;
+ g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self));
nm_assert (retries == AUTOCONNECT_RETRIES_UNSET || retries >= 0);
+ priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
+
if (priv->autoconnect_retries != retries) {
_LOGT ("autoconnect-retries: set %d", retries);
priv->autoconnect_retries = retries;