summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-05-05 16:56:41 +0200
committerThomas Haller <thaller@redhat.com>2015-05-05 16:57:25 +0200
commit9847ab7147465de089b0093ad74bd8b07f5d1b27 (patch)
tree6fd91d1c059445bdd87d2b162de542a48101de9b
parent4d4f5fff5ce48a92dfdc19e8ecfb39a40c95b687 (diff)
parent8ebb8d0d0ff4571cf301d80beec4d4f59d5f762e (diff)
downloadNetworkManager-9847ab7147465de089b0093ad74bd8b07f5d1b27.tar.gz
core: merge branch 'th/reload-ignore-carrier-bgo748050'
Make the main.ignore-carrier configuration option reloadable via our usual SIGHUP mechanism. https://bugzilla.gnome.org/show_bug.cgi?id=748050
-rw-r--r--src/devices/nm-device.c30
-rw-r--r--src/nm-config-data.c16
-rw-r--r--src/nm-config-data.h2
-rw-r--r--src/nm-config.c14
-rw-r--r--src/nm-config.h2
5 files changed, 47 insertions, 17 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 7c264c7c85..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_get_ignore_carrier (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);
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index a987a8f3ef..2400e6dda6 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -25,6 +25,7 @@
#include "nm-config.h"
#include "gsystem-local-alloc.h"
+#include "nm-device.h"
typedef struct {
char *config_main_file;
@@ -43,6 +44,8 @@ typedef struct {
GSList *specs;
} no_auto_default;
+ GSList *ignore_carrier;
+
char *dns_mode;
char *rc_manager;
} NMConfigDataPrivate;
@@ -147,6 +150,15 @@ nm_config_data_get_rc_manager (const NMConfigData *self)
return NM_CONFIG_DATA_GET_PRIVATE (self)->rc_manager;
}
+gboolean
+nm_config_data_get_ignore_carrier (const NMConfigData *self, NMDevice *device)
+{
+ g_return_val_if_fail (NM_IS_CONFIG_DATA (self), FALSE);
+ g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
+
+ return nm_device_spec_match_list (device, NM_CONFIG_DATA_GET_PRIVATE (self)->ignore_carrier);
+}
+
/************************************************************************/
static gboolean
@@ -314,6 +326,8 @@ finalize (GObject *gobject)
g_free (priv->dns_mode);
g_free (priv->rc_manager);
+ g_slist_free_full (priv->ignore_carrier, g_free);
+
g_key_file_unref (priv->keyfile);
G_OBJECT_CLASS (nm_config_data_parent_class)->finalize (gobject);
@@ -340,6 +354,8 @@ constructed (GObject *object)
priv->dns_mode = g_key_file_get_value (priv->keyfile, "main", "dns", NULL);
priv->rc_manager = g_key_file_get_value (priv->keyfile, "main", "rc-manager", NULL);
+ priv->ignore_carrier = nm_config_get_device_match_spec (priv->keyfile, "main", "ignore-carrier");
+
G_OBJECT_CLASS (nm_config_data_parent_class)->constructed (object);
}
diff --git a/src/nm-config-data.h b/src/nm-config-data.h
index 50c53995ad..ea99931cf8 100644
--- a/src/nm-config-data.h
+++ b/src/nm-config-data.h
@@ -91,6 +91,8 @@ const GSList * nm_config_data_get_no_auto_default_list (const NMConfigData *c
const char *nm_config_data_get_dns_mode (const NMConfigData *self);
const char *nm_config_data_get_rc_manager (const NMConfigData *self);
+gboolean nm_config_data_get_ignore_carrier (const NMConfigData *self, NMDevice *device);
+
G_END_DECLS
#endif /* NM_CONFIG_DATA_H */
diff --git a/src/nm-config.c b/src/nm-config.c
index 8e8100fe89..ff81302f91 100644
--- a/src/nm-config.c
+++ b/src/nm-config.c
@@ -76,8 +76,6 @@ typedef struct {
char *debug;
- GSList *ignore_carrier;
-
gboolean configure_and_quit;
} NMConfigPrivate;
@@ -226,15 +224,6 @@ nm_config_get_configure_and_quit (NMConfig *config)
return NM_CONFIG_GET_PRIVATE (config)->configure_and_quit;
}
-gboolean
-nm_config_get_ignore_carrier (NMConfig *config, NMDevice *device)
-{
- g_return_val_if_fail (NM_IS_CONFIG (config), FALSE);
- g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
-
- return nm_device_spec_match_list (device, NM_CONFIG_GET_PRIVATE (config)->ignore_carrier);
-}
-
/************************************************************************/
static char **
@@ -860,8 +849,6 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
priv->debug = g_key_file_get_value (keyfile, "main", "debug", NULL);
- priv->ignore_carrier = nm_config_get_device_match_spec (keyfile, "main", "ignore-carrier");
-
priv->configure_and_quit = _get_bool_value (keyfile, "main", "configure-and-quit", FALSE);
no_auto_default_orig_list = nm_config_get_device_match_spec (keyfile, "main", "no-auto-default");
@@ -915,7 +902,6 @@ finalize (GObject *gobject)
g_free (priv->log_level);
g_free (priv->log_domains);
g_free (priv->debug);
- g_slist_free_full (priv->ignore_carrier, g_free);
_nm_config_cmd_line_options_clear (&priv->cli);
diff --git a/src/nm-config.h b/src/nm-config.h
index b82dfb3e9f..ecd083a62c 100644
--- a/src/nm-config.h
+++ b/src/nm-config.h
@@ -73,8 +73,6 @@ const char *nm_config_get_log_domains (NMConfig *config);
const char *nm_config_get_debug (NMConfig *config);
gboolean nm_config_get_configure_and_quit (NMConfig *config);
-gboolean nm_config_get_ignore_carrier (NMConfig *config, NMDevice *device);
-
/* for main.c only */
NMConfigCmdLineOptions *nm_config_cmd_line_options_new (void);
void nm_config_cmd_line_options_free (NMConfigCmdLineOptions *cli);