mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-28 05:20:40 +02:00
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
This commit is contained in:
commit
9847ab7147
5 changed files with 47 additions and 17 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue