diff options
author | Thomas Haller <thaller@redhat.com> | 2015-04-17 14:12:10 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-05-05 16:53:51 +0200 |
commit | 8ebb8d0d0ff4571cf301d80beec4d4f59d5f762e (patch) | |
tree | 6fd91d1c059445bdd87d2b162de542a48101de9b | |
parent | 2d333a1769e0a67abf2bb5b93fe1586260017565 (diff) | |
download | NetworkManager-8ebb8d0d0ff4571cf301d80beec4d4f59d5f762e.tar.gz |
device: allow reloading of the ignore-carrier flag
Now on SIGHUP, when reloading NetworkManager configuration, also reload
the ignore-carrier flag.
While a device is activated, the reload is ignored until the device
deactivates.
Maybe it would be simpler just not to cache ignore_carrer and let it
take effect immediately. But not caching ignore_carrer has the
additional downside that every call to is_available must check the
specs -- which in sum is potentially expensive for something that
almost never changes.
https://bugzilla.gnome.org/show_bug.cgi?id=748050
-rw-r--r-- | src/devices/nm-device.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index a45852bb06..f0ef6572e3 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -8082,6 +8082,12 @@ _set_state_full (NMDevice *self, case NM_DEVICE_STATE_DEACTIVATING: _cancel_activation (self); + if (nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) { + /* We cache the ignore_carrier state to not react on config-reloads while the connection + * is active. But on deactivating, reset the ignore-carrier flag to the current state. */ + priv->ignore_carrier = nm_config_data_get_ignore_carrier (nm_config_get_data (nm_config_get ()), self); + } + if (quitting) { nm_dispatcher_call_sync (DISPATCHER_ACTION_PRE_DOWN, nm_act_request_get_connection (req), @@ -8447,6 +8453,20 @@ spec_match_list (NMDevice *self, const GSList *specs) return matched; } +static void +config_changed_update_ignore_carrier (NMConfig *config, + NMConfigData *config_data, + NMConfigChangeFlags changes, + NMConfigData *old_data, + NMDevice *self) +{ + NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + + if ( priv->state <= NM_DEVICE_STATE_DISCONNECTED + || priv->state > NM_DEVICE_STATE_ACTIVATED) + priv->ignore_carrier = nm_config_data_get_ignore_carrier (config_data, self); +} + /***********************************************************/ #define DEFAULT_AUTOCONNECT TRUE @@ -8593,7 +8613,13 @@ constructed (GObject *object) /* Have to call update_initial_hw_address() before calling get_ignore_carrier() */ if (nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) { - priv->ignore_carrier = nm_config_data_get_ignore_carrier (nm_config_get_data_orig (nm_config_get ()), self); + NMConfig *config = nm_config_get (); + + priv->ignore_carrier = nm_config_data_get_ignore_carrier (nm_config_get_data (config), self); + g_signal_connect (G_OBJECT (config), + NM_CONFIG_SIGNAL_CONFIG_CHANGED, + G_CALLBACK (config_changed_update_ignore_carrier), + self); check_carrier (self); _LOGD (LOGD_HW, @@ -8658,6 +8684,8 @@ dispose (GObject *object) _LOGD (LOGD_DEVICE, "dispose(): %s", G_OBJECT_TYPE_NAME (self)); + g_signal_handlers_disconnect_by_func (nm_config_get (), config_changed_update_ignore_carrier, self); + dispatcher_cleanup (self); _cleanup_generic_pre (self, FALSE); |