2008-11-03 04:13:42 +00:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
2008-03-26 13:43:01 +00:00
|
|
|
/* NetworkManager -- Network link manager
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
2008-06-26 18:31:52 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-03-26 13:43:01 +00:00
|
|
|
*
|
2014-03-03 15:01:36 +01:00
|
|
|
* Copyright (C) 2008 - 2014 Red Hat, Inc.
|
2008-03-26 13:43:01 +00:00
|
|
|
*/
|
|
|
|
|
|
2014-11-13 10:07:02 -05:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2008-03-26 13:43:01 +00:00
|
|
|
#include <glib.h>
|
2014-10-23 17:04:49 -05:00
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
#include "nm-types.h"
|
2008-03-26 13:43:01 +00:00
|
|
|
#include "nm-active-connection.h"
|
2014-07-05 16:23:30 -04:00
|
|
|
#include "nm-dbus-interface.h"
|
2010-04-07 12:28:57 -07:00
|
|
|
#include "nm-logging.h"
|
2011-01-25 12:41:03 -06:00
|
|
|
#include "nm-dbus-glib-types.h"
|
2012-02-03 14:53:09 -06:00
|
|
|
#include "nm-dbus-manager.h"
|
2012-08-22 09:38:01 -05:00
|
|
|
#include "nm-device.h"
|
2012-08-22 17:34:42 -05:00
|
|
|
#include "nm-settings-connection.h"
|
2014-08-16 01:33:46 +02:00
|
|
|
#include "nm-auth-utils.h"
|
2014-07-17 17:06:44 -04:00
|
|
|
#include "nm-auth-subject.h"
|
2012-09-17 10:53:41 -05:00
|
|
|
#include "NetworkManagerUtils.h"
|
2014-10-23 17:04:49 -05:00
|
|
|
#include "gsystem-local-alloc.h"
|
2012-02-03 14:53:09 -06:00
|
|
|
#include "nm-active-connection-glue.h"
|
2014-11-07 17:03:20 +01:00
|
|
|
#include "nm-glib-compat.h"
|
2012-02-03 14:53:09 -06:00
|
|
|
|
|
|
|
|
/* Base class for anything implementing the Connection.Active D-Bus interface */
|
|
|
|
|
G_DEFINE_ABSTRACT_TYPE (NMActiveConnection, nm_active_connection, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
#define NM_ACTIVE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
|
|
|
|
|
NM_TYPE_ACTIVE_CONNECTION, \
|
|
|
|
|
NMActiveConnectionPrivate))
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
NMConnection *connection;
|
|
|
|
|
char *path;
|
|
|
|
|
char *specific_object;
|
2012-08-22 09:38:01 -05:00
|
|
|
NMDevice *device;
|
|
|
|
|
|
core: fix NMActiveConnection to properly add/remove pending action "activation"
When a new activation request is received, NetworkManager creates a new
NMActiveConnection to track that request. The device may already be activated,
in which case NetworkManager stops the old activation and starts the new one,
but both exist in parallel for a short period of time. If the old
NMActiveConnection is activating and already has a pending 'activation'
action, when the new NMActiveConnection adds its own 'activating' action,
they will clash. This is fixed by making each NMActiveConnection's activation
pending action uniquely named.
This fixes a g_warning with the following back trace:
#0 0x000000328224edfd in g_logv () from /lib64/libglib-2.0.so.0
#1 0x000000328224efe2 in g_log () from /lib64/libglib-2.0.so.0
#2 0x000000328224f2e6 in g_warn_message () from /lib64/libglib-2.0.so.0
#3 0x0000000000440aee in nm_device_add_pending_action (device=0x14002e0, action=0x50704a "activation") at devices/nm-device.c:7172
#4 0x000000000047525c in nm_active_connection_set_device (self=0x141b3c0, device=0x14002e0) at nm-active-connection.c:364
#5 0x0000000000475ec1 in set_property (object=0x141b3c0, prop_id=11, value=0x7fff7ff36c20, pspec=0x1405f70) at nm-active-connection.c:647
#6 0x0000003282615d3e in g_object_newv () from /lib64/libgobject-2.0.so.0
#7 0x00000032826162e6 in g_object_new_valist () from /lib64/libgobject-2.0.so.0
#8 0x0000003282616654 in g_object_new () from /lib64/libgobject-2.0.so.0
#9 0x0000000000474193 in nm_act_request_new (connection=0x13bb0e0, specific_object=0x0, subject=0x1447740, device=0x14002e0) at nm-activation-request.c:376
#10 0x000000000048e477 in _new_active_connection (self=0x13e8060, connection=0x13bb0e0, specific_object=0x0, device=0x14002e0, subject=0x1447740, error=0x7fff7ff36f90) at nm-manager.c:2947
#11 0x000000000048ed77 in impl_manager_activate_connection (self=0x13e8060, connection_path=0x134d590 "/org/freedesktop/NetworkManager/Settings/9", device_path=0x134d550 "/org/freedesktop/NetworkManager/Devices/1",
specific_object_path=0x0, context=0x143a9b0) at nm-manager.c:3206
#12 0x00000000004876c8 in dbus_glib_marshal_nm_manager_VOID__BOXED_BOXED_BOXED_POINTER (closure=0x7fff7ff37220, return_value=0x0, n_param_values=5, param_values=0x1448830, invocation_hint=0x0,
marshal_data=0x48e9dd <impl_manager_activate_connection>) at nm-manager-glue.h:189
#13 0x0000003284a0d6a9 in object_registration_message () from /lib64/libdbus-glib-1.so.2
#14 0x000000348ea1ce66 in _dbus_object_tree_dispatch_and_unlock () from /lib64/libdbus-1.so.3
#15 0x000000348ea0fa31 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#16 0x0000003284a0acc5 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#17 0x0000003282247df6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#18 0x0000003282248148 in g_main_context_iterate.isra.22 () from /lib64/libglib-2.0.so.0
#19 0x000000328224854a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#20 0x000000000042c6c0 in main (argc=1, argv=0x7fff7ff379b8) at main.c:629
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-16 15:02:38 +01:00
|
|
|
char *pending_activation_id;
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
gboolean is_default;
|
|
|
|
|
gboolean is_default6;
|
|
|
|
|
NMActiveConnectionState state;
|
2014-10-16 18:00:54 -04:00
|
|
|
gboolean state_set;
|
2012-02-03 14:53:09 -06:00
|
|
|
gboolean vpn;
|
2012-08-22 09:38:01 -05:00
|
|
|
|
2013-07-29 13:11:47 -05:00
|
|
|
NMAuthSubject *subject;
|
2013-08-27 12:16:57 -05:00
|
|
|
NMActiveConnection *master;
|
2013-09-27 17:13:43 -05:00
|
|
|
gboolean master_ready;
|
2012-09-17 10:53:41 -05:00
|
|
|
|
2013-11-07 01:04:06 -06:00
|
|
|
gboolean assumed;
|
|
|
|
|
|
2012-09-17 10:53:41 -05:00
|
|
|
NMAuthChain *chain;
|
|
|
|
|
const char *wifi_shared_permission;
|
|
|
|
|
NMActiveConnectionAuthResultFunc result_func;
|
|
|
|
|
gpointer user_data1;
|
|
|
|
|
gpointer user_data2;
|
2012-02-03 14:53:09 -06:00
|
|
|
} NMActiveConnectionPrivate;
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_CONNECTION,
|
2014-03-03 15:01:36 +01:00
|
|
|
PROP_ID,
|
2012-02-03 14:53:09 -06:00
|
|
|
PROP_UUID,
|
2014-03-03 15:01:36 +01:00
|
|
|
PROP_TYPE,
|
2012-02-03 14:53:09 -06:00
|
|
|
PROP_SPECIFIC_OBJECT,
|
|
|
|
|
PROP_DEVICES,
|
|
|
|
|
PROP_STATE,
|
|
|
|
|
PROP_DEFAULT,
|
2013-12-18 08:46:43 -05:00
|
|
|
PROP_IP4_CONFIG,
|
|
|
|
|
PROP_DHCP4_CONFIG,
|
2012-02-03 14:53:09 -06:00
|
|
|
PROP_DEFAULT6,
|
2013-12-18 08:46:43 -05:00
|
|
|
PROP_IP6_CONFIG,
|
|
|
|
|
PROP_DHCP6_CONFIG,
|
2012-02-03 14:53:09 -06:00
|
|
|
PROP_VPN,
|
|
|
|
|
PROP_MASTER,
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
PROP_INT_CONNECTION,
|
|
|
|
|
PROP_INT_DEVICE,
|
2013-07-29 13:11:47 -05:00
|
|
|
PROP_INT_SUBJECT,
|
2012-08-22 09:38:01 -05:00
|
|
|
PROP_INT_MASTER,
|
2013-09-27 17:13:43 -05:00
|
|
|
PROP_INT_MASTER_READY,
|
2012-08-22 09:38:01 -05:00
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
LAST_PROP
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-23 17:04:49 -05:00
|
|
|
enum {
|
|
|
|
|
DEVICE_CHANGED,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2013-09-27 17:13:43 -05:00
|
|
|
static void check_master_ready (NMActiveConnection *self);
|
2014-01-02 14:59:46 -05:00
|
|
|
static void _device_cleanup (NMActiveConnection *self);
|
2013-09-27 17:13:43 -05:00
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
/****************************************************************/
|
|
|
|
|
|
2013-10-25 19:33:01 -05:00
|
|
|
static const char *
|
|
|
|
|
state_to_string (NMActiveConnectionState state)
|
|
|
|
|
{
|
|
|
|
|
switch (state) {
|
|
|
|
|
case NM_ACTIVE_CONNECTION_STATE_UNKNOWN:
|
|
|
|
|
return "unknown";
|
|
|
|
|
case NM_ACTIVE_CONNECTION_STATE_ACTIVATING:
|
|
|
|
|
return "activating";
|
|
|
|
|
case NM_ACTIVE_CONNECTION_STATE_ACTIVATED:
|
|
|
|
|
return "activated";
|
|
|
|
|
case NM_ACTIVE_CONNECTION_STATE_DEACTIVATING:
|
|
|
|
|
return "deactivating";
|
|
|
|
|
case NM_ACTIVE_CONNECTION_STATE_DEACTIVATED:
|
|
|
|
|
return "deactivated";
|
|
|
|
|
}
|
|
|
|
|
return "(none)";
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-26 17:38:41 -06:00
|
|
|
NMActiveConnectionState
|
|
|
|
|
nm_active_connection_get_state (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->state;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
void
|
|
|
|
|
nm_active_connection_set_state (NMActiveConnection *self,
|
|
|
|
|
NMActiveConnectionState new_state)
|
2008-03-26 13:43:01 +00:00
|
|
|
{
|
2012-02-03 14:53:09 -06:00
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
2012-08-22 17:34:42 -05:00
|
|
|
NMActiveConnectionState old_state;
|
2012-02-03 14:53:09 -06:00
|
|
|
|
2012-08-22 17:34:42 -05:00
|
|
|
if (priv->state == new_state)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-02-11 11:15:45 -06:00
|
|
|
/* DEACTIVATED is a terminal state */
|
|
|
|
|
if (priv->state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED)
|
|
|
|
|
g_return_if_fail (new_state != NM_ACTIVE_CONNECTION_STATE_DEACTIVATED);
|
|
|
|
|
|
2012-08-22 17:34:42 -05:00
|
|
|
old_state = priv->state;
|
|
|
|
|
priv->state = new_state;
|
2014-10-16 18:00:54 -04:00
|
|
|
priv->state_set = TRUE;
|
2012-08-22 17:34:42 -05:00
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_STATE);
|
|
|
|
|
|
2013-09-27 17:13:43 -05:00
|
|
|
check_master_ready (self);
|
|
|
|
|
|
2012-08-22 17:34:42 -05:00
|
|
|
if ( new_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|
|
|
|
|
|| old_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
|
|
|
|
nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (priv->connection),
|
|
|
|
|
(guint64) time (NULL), TRUE);
|
2012-02-03 14:53:09 -06:00
|
|
|
}
|
2013-02-11 11:15:45 -06:00
|
|
|
|
core: ensure 'activation' pending action encompasses full activation process
The NMActiveConnection class tracks the full activation request, and internal
activation requests go through the same process as external ones, including
some authentication. Sometimes that means activation is scheduled, control
returns to the mainloop, and then the activation proceeds from an idle
handler.
Unfortunately, that means that adding a pending "activation" action from
nm-device.c doesn't always work, since there is a short window between when
the activation is started in nm-manager.c (in nm_manager_activate_connection())
and when the device actually changes state. Inside that window, the pending
actions may drop to zero, and startup will be declared complete before the
device actually starts activating.
Instead, ensure that the pending action is added when the internal activation
is actually started (eg, when NMActiveConnection receives the NMDevice object).
2013-12-10 22:11:09 -06:00
|
|
|
if (priv->device) {
|
|
|
|
|
if ( old_state < NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|
core: fix NMActiveConnection to properly add/remove pending action "activation"
When a new activation request is received, NetworkManager creates a new
NMActiveConnection to track that request. The device may already be activated,
in which case NetworkManager stops the old activation and starts the new one,
but both exist in parallel for a short period of time. If the old
NMActiveConnection is activating and already has a pending 'activation'
action, when the new NMActiveConnection adds its own 'activating' action,
they will clash. This is fixed by making each NMActiveConnection's activation
pending action uniquely named.
This fixes a g_warning with the following back trace:
#0 0x000000328224edfd in g_logv () from /lib64/libglib-2.0.so.0
#1 0x000000328224efe2 in g_log () from /lib64/libglib-2.0.so.0
#2 0x000000328224f2e6 in g_warn_message () from /lib64/libglib-2.0.so.0
#3 0x0000000000440aee in nm_device_add_pending_action (device=0x14002e0, action=0x50704a "activation") at devices/nm-device.c:7172
#4 0x000000000047525c in nm_active_connection_set_device (self=0x141b3c0, device=0x14002e0) at nm-active-connection.c:364
#5 0x0000000000475ec1 in set_property (object=0x141b3c0, prop_id=11, value=0x7fff7ff36c20, pspec=0x1405f70) at nm-active-connection.c:647
#6 0x0000003282615d3e in g_object_newv () from /lib64/libgobject-2.0.so.0
#7 0x00000032826162e6 in g_object_new_valist () from /lib64/libgobject-2.0.so.0
#8 0x0000003282616654 in g_object_new () from /lib64/libgobject-2.0.so.0
#9 0x0000000000474193 in nm_act_request_new (connection=0x13bb0e0, specific_object=0x0, subject=0x1447740, device=0x14002e0) at nm-activation-request.c:376
#10 0x000000000048e477 in _new_active_connection (self=0x13e8060, connection=0x13bb0e0, specific_object=0x0, device=0x14002e0, subject=0x1447740, error=0x7fff7ff36f90) at nm-manager.c:2947
#11 0x000000000048ed77 in impl_manager_activate_connection (self=0x13e8060, connection_path=0x134d590 "/org/freedesktop/NetworkManager/Settings/9", device_path=0x134d550 "/org/freedesktop/NetworkManager/Devices/1",
specific_object_path=0x0, context=0x143a9b0) at nm-manager.c:3206
#12 0x00000000004876c8 in dbus_glib_marshal_nm_manager_VOID__BOXED_BOXED_BOXED_POINTER (closure=0x7fff7ff37220, return_value=0x0, n_param_values=5, param_values=0x1448830, invocation_hint=0x0,
marshal_data=0x48e9dd <impl_manager_activate_connection>) at nm-manager-glue.h:189
#13 0x0000003284a0d6a9 in object_registration_message () from /lib64/libdbus-glib-1.so.2
#14 0x000000348ea1ce66 in _dbus_object_tree_dispatch_and_unlock () from /lib64/libdbus-1.so.3
#15 0x000000348ea0fa31 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#16 0x0000003284a0acc5 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#17 0x0000003282247df6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#18 0x0000003282248148 in g_main_context_iterate.isra.22 () from /lib64/libglib-2.0.so.0
#19 0x000000328224854a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#20 0x000000000042c6c0 in main (argc=1, argv=0x7fff7ff379b8) at main.c:629
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-16 15:02:38 +01:00
|
|
|
&& new_state >= NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
|
|
|
|
|
priv->pending_activation_id)
|
|
|
|
|
{
|
2014-04-28 11:18:05 +02:00
|
|
|
nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE);
|
core: fix NMActiveConnection to properly add/remove pending action "activation"
When a new activation request is received, NetworkManager creates a new
NMActiveConnection to track that request. The device may already be activated,
in which case NetworkManager stops the old activation and starts the new one,
but both exist in parallel for a short period of time. If the old
NMActiveConnection is activating and already has a pending 'activation'
action, when the new NMActiveConnection adds its own 'activating' action,
they will clash. This is fixed by making each NMActiveConnection's activation
pending action uniquely named.
This fixes a g_warning with the following back trace:
#0 0x000000328224edfd in g_logv () from /lib64/libglib-2.0.so.0
#1 0x000000328224efe2 in g_log () from /lib64/libglib-2.0.so.0
#2 0x000000328224f2e6 in g_warn_message () from /lib64/libglib-2.0.so.0
#3 0x0000000000440aee in nm_device_add_pending_action (device=0x14002e0, action=0x50704a "activation") at devices/nm-device.c:7172
#4 0x000000000047525c in nm_active_connection_set_device (self=0x141b3c0, device=0x14002e0) at nm-active-connection.c:364
#5 0x0000000000475ec1 in set_property (object=0x141b3c0, prop_id=11, value=0x7fff7ff36c20, pspec=0x1405f70) at nm-active-connection.c:647
#6 0x0000003282615d3e in g_object_newv () from /lib64/libgobject-2.0.so.0
#7 0x00000032826162e6 in g_object_new_valist () from /lib64/libgobject-2.0.so.0
#8 0x0000003282616654 in g_object_new () from /lib64/libgobject-2.0.so.0
#9 0x0000000000474193 in nm_act_request_new (connection=0x13bb0e0, specific_object=0x0, subject=0x1447740, device=0x14002e0) at nm-activation-request.c:376
#10 0x000000000048e477 in _new_active_connection (self=0x13e8060, connection=0x13bb0e0, specific_object=0x0, device=0x14002e0, subject=0x1447740, error=0x7fff7ff36f90) at nm-manager.c:2947
#11 0x000000000048ed77 in impl_manager_activate_connection (self=0x13e8060, connection_path=0x134d590 "/org/freedesktop/NetworkManager/Settings/9", device_path=0x134d550 "/org/freedesktop/NetworkManager/Devices/1",
specific_object_path=0x0, context=0x143a9b0) at nm-manager.c:3206
#12 0x00000000004876c8 in dbus_glib_marshal_nm_manager_VOID__BOXED_BOXED_BOXED_POINTER (closure=0x7fff7ff37220, return_value=0x0, n_param_values=5, param_values=0x1448830, invocation_hint=0x0,
marshal_data=0x48e9dd <impl_manager_activate_connection>) at nm-manager-glue.h:189
#13 0x0000003284a0d6a9 in object_registration_message () from /lib64/libdbus-glib-1.so.2
#14 0x000000348ea1ce66 in _dbus_object_tree_dispatch_and_unlock () from /lib64/libdbus-1.so.3
#15 0x000000348ea0fa31 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#16 0x0000003284a0acc5 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#17 0x0000003282247df6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#18 0x0000003282248148 in g_main_context_iterate.isra.22 () from /lib64/libglib-2.0.so.0
#19 0x000000328224854a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#20 0x000000000042c6c0 in main (argc=1, argv=0x7fff7ff379b8) at main.c:629
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-16 15:02:38 +01:00
|
|
|
g_clear_pointer (&priv->pending_activation_id, g_free);
|
|
|
|
|
}
|
core: ensure 'activation' pending action encompasses full activation process
The NMActiveConnection class tracks the full activation request, and internal
activation requests go through the same process as external ones, including
some authentication. Sometimes that means activation is scheduled, control
returns to the mainloop, and then the activation proceeds from an idle
handler.
Unfortunately, that means that adding a pending "activation" action from
nm-device.c doesn't always work, since there is a short window between when
the activation is started in nm-manager.c (in nm_manager_activate_connection())
and when the device actually changes state. Inside that window, the pending
actions may drop to zero, and startup will be declared complete before the
device actually starts activating.
Instead, ensure that the pending action is added when the internal activation
is actually started (eg, when NMActiveConnection receives the NMDevice object).
2013-12-10 22:11:09 -06:00
|
|
|
}
|
|
|
|
|
|
2013-12-18 08:46:43 -05:00
|
|
|
if ( new_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|
|
|
|
|
|| old_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_IP4_CONFIG);
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DHCP4_CONFIG);
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_IP6_CONFIG);
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DHCP6_CONFIG);
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-11 11:15:45 -06:00
|
|
|
if (priv->state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
|
2013-12-03 16:49:21 +01:00
|
|
|
/* Device is no longer relevant when deactivated. So remove it and
|
|
|
|
|
* emit property change notification so clients re-read the value,
|
|
|
|
|
* which will be NULL due to conditions in get_property().
|
2013-09-27 14:40:18 -05:00
|
|
|
*/
|
2014-01-02 14:59:46 -05:00
|
|
|
_device_cleanup (self);
|
2013-02-11 11:15:45 -06:00
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DEVICES);
|
|
|
|
|
}
|
2012-02-03 14:53:09 -06:00
|
|
|
}
|
|
|
|
|
|
2012-09-21 12:33:13 +02:00
|
|
|
const char *
|
2014-03-05 21:15:09 +01:00
|
|
|
nm_active_connection_get_id (NMActiveConnection *self)
|
2012-09-21 12:33:13 +02:00
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), NULL);
|
|
|
|
|
|
|
|
|
|
return nm_connection_get_id (NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->connection);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-05 21:11:54 +01:00
|
|
|
const char *
|
|
|
|
|
nm_active_connection_get_uuid (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), NULL);
|
|
|
|
|
|
|
|
|
|
return nm_connection_get_uuid (NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->connection);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
NMConnection *
|
|
|
|
|
nm_active_connection_get_connection (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->connection;
|
|
|
|
|
}
|
2008-03-26 13:43:01 +00:00
|
|
|
|
2014-10-23 13:56:52 -04:00
|
|
|
const char *
|
|
|
|
|
nm_active_connection_get_connection_type (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->connection == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
return nm_connection_get_connection_type (priv->connection);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-28 11:43:50 -05:00
|
|
|
void
|
|
|
|
|
nm_active_connection_set_connection (NMActiveConnection *self,
|
|
|
|
|
NMConnection *connection)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
/* Can't change connection after the ActiveConnection is exported over D-Bus */
|
|
|
|
|
g_return_if_fail (priv->path == NULL);
|
|
|
|
|
g_return_if_fail (priv->connection == NULL || !NM_IS_SETTINGS_CONNECTION (priv->connection));
|
|
|
|
|
|
|
|
|
|
if (priv->connection)
|
|
|
|
|
g_object_unref (priv->connection);
|
|
|
|
|
priv->connection = g_object_ref (connection);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
const char *
|
|
|
|
|
nm_active_connection_get_path (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
nm_active_connection_get_specific_object (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->specific_object;
|
2008-03-26 13:43:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2012-02-03 14:53:09 -06:00
|
|
|
nm_active_connection_set_specific_object (NMActiveConnection *self,
|
|
|
|
|
const char *specific_object)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
|
2012-09-17 10:28:11 -05:00
|
|
|
/* Nothing that calls this function should be using paths from D-Bus,
|
|
|
|
|
* where NM uses "/" to mean NULL.
|
|
|
|
|
*/
|
|
|
|
|
g_assert (g_strcmp0 (specific_object, "/") != 0);
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
if (g_strcmp0 (priv->specific_object, specific_object) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
g_free (priv->specific_object);
|
|
|
|
|
priv->specific_object = g_strdup (specific_object);
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_active_connection_set_default (NMActiveConnection *self, gboolean is_default)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (self));
|
|
|
|
|
|
2014-06-20 17:56:06 +02:00
|
|
|
is_default = !!is_default;
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
if (priv->is_default == is_default)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
priv->is_default = is_default;
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DEFAULT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_active_connection_get_default (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->is_default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
nm_active_connection_set_default6 (NMActiveConnection *self, gboolean is_default6)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (self));
|
|
|
|
|
|
2014-06-20 17:56:06 +02:00
|
|
|
is_default6 = !!is_default6;
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
if (priv->is_default6 == is_default6)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
priv->is_default6 = is_default6;
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DEFAULT6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_active_connection_get_default6 (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->is_default6;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
void
|
|
|
|
|
nm_active_connection_export (NMActiveConnection *self)
|
2012-02-03 14:53:09 -06:00
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
static guint32 counter = 0;
|
|
|
|
|
|
2013-04-26 11:06:58 -05:00
|
|
|
g_assert (priv->device || priv->vpn);
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
priv->path = g_strdup_printf (NM_DBUS_PATH "/ActiveConnection/%d", counter++);
|
2013-04-10 11:37:05 -05:00
|
|
|
nm_dbus_manager_register_object (nm_dbus_manager_get (), priv->path, self);
|
2012-02-03 14:53:09 -06:00
|
|
|
}
|
|
|
|
|
|
2013-07-29 13:11:47 -05:00
|
|
|
NMAuthSubject *
|
|
|
|
|
nm_active_connection_get_subject (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->subject;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
gboolean
|
|
|
|
|
nm_active_connection_get_user_requested (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), FALSE);
|
2012-02-03 14:53:09 -06:00
|
|
|
|
2014-08-14 13:34:57 +02:00
|
|
|
return nm_auth_subject_is_unix_process (NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->subject);
|
2012-08-22 09:38:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMDevice *
|
|
|
|
|
nm_active_connection_get_device (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), NULL);
|
2012-02-03 14:53:09 -06:00
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->device;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-27 14:40:18 -05:00
|
|
|
static void
|
|
|
|
|
device_state_changed (NMDevice *device,
|
|
|
|
|
NMDeviceState new_state,
|
|
|
|
|
NMDeviceState old_state,
|
|
|
|
|
NMDeviceStateReason reason,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnection *self = NM_ACTIVE_CONNECTION (user_data);
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
|
2014-02-19 13:09:17 -06:00
|
|
|
/* When already deactivated or before activation, device state changes are useless */
|
|
|
|
|
if (priv->state >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATED)
|
|
|
|
|
return;
|
2013-09-27 14:40:18 -05:00
|
|
|
if (old_state < NM_DEVICE_STATE_DISCONNECTED)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Let subclasses handle the state change */
|
|
|
|
|
if (NM_ACTIVE_CONNECTION_GET_CLASS (self)->device_state_changed)
|
|
|
|
|
NM_ACTIVE_CONNECTION_GET_CLASS (self)->device_state_changed (self, device, new_state, old_state);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-02 14:59:46 -05:00
|
|
|
static void
|
|
|
|
|
device_master_changed (GObject *object,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMDevice *device = NM_DEVICE (object);
|
|
|
|
|
NMActiveConnection *self = NM_ACTIVE_CONNECTION (user_data);
|
|
|
|
|
NMActiveConnection *master;
|
|
|
|
|
NMActiveConnectionState master_state;
|
|
|
|
|
|
2014-02-19 13:09:17 -06:00
|
|
|
if (NM_ACTIVE_CONNECTION (nm_device_get_act_request (device)) != self)
|
|
|
|
|
return;
|
2014-01-02 14:59:46 -05:00
|
|
|
if (!nm_device_get_master (device))
|
|
|
|
|
return;
|
2014-09-24 16:02:37 +02:00
|
|
|
if (!nm_active_connection_get_master (self))
|
|
|
|
|
return;
|
2014-01-02 14:59:46 -05:00
|
|
|
g_signal_handlers_disconnect_by_func (device, G_CALLBACK (device_master_changed), self);
|
|
|
|
|
|
|
|
|
|
master = nm_active_connection_get_master (self);
|
|
|
|
|
master_state = nm_active_connection_get_state (master);
|
|
|
|
|
if (master_state >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATING) {
|
|
|
|
|
/* Master failed before attaching the slave */
|
|
|
|
|
if (NM_ACTIVE_CONNECTION_GET_CLASS (self)->master_failed)
|
|
|
|
|
NM_ACTIVE_CONNECTION_GET_CLASS (self)->master_failed (self);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-16 17:43:31 -05:00
|
|
|
gboolean
|
|
|
|
|
nm_active_connection_set_device (NMActiveConnection *self, NMDevice *device)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv;
|
2014-10-23 17:04:49 -05:00
|
|
|
gs_unref_object NMDevice *old_device = NULL;
|
2013-09-16 17:43:31 -05:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), FALSE);
|
|
|
|
|
g_return_val_if_fail (!device || NM_IS_DEVICE (device), FALSE);
|
|
|
|
|
|
|
|
|
|
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
2014-10-23 17:04:49 -05:00
|
|
|
if (device == priv->device)
|
|
|
|
|
return TRUE;
|
2013-09-16 17:43:31 -05:00
|
|
|
|
2014-10-23 17:04:49 -05:00
|
|
|
old_device = priv->device ? g_object_ref (priv->device) : NULL;
|
|
|
|
|
_device_cleanup (self);
|
2013-09-16 17:43:31 -05:00
|
|
|
|
2014-10-23 17:04:49 -05:00
|
|
|
if (device) {
|
2013-09-16 17:43:31 -05:00
|
|
|
/* Device obviously can't be its own master */
|
|
|
|
|
g_return_val_if_fail (!priv->master || device != nm_active_connection_get_device (priv->master), FALSE);
|
|
|
|
|
|
|
|
|
|
priv->device = g_object_ref (device);
|
|
|
|
|
|
2014-01-02 14:59:46 -05:00
|
|
|
g_signal_connect (device, "state-changed",
|
|
|
|
|
G_CALLBACK (device_state_changed), self);
|
|
|
|
|
g_signal_connect (device, "notify::master",
|
|
|
|
|
G_CALLBACK (device_master_changed), self);
|
core: ensure 'activation' pending action encompasses full activation process
The NMActiveConnection class tracks the full activation request, and internal
activation requests go through the same process as external ones, including
some authentication. Sometimes that means activation is scheduled, control
returns to the mainloop, and then the activation proceeds from an idle
handler.
Unfortunately, that means that adding a pending "activation" action from
nm-device.c doesn't always work, since there is a short window between when
the activation is started in nm-manager.c (in nm_manager_activate_connection())
and when the device actually changes state. Inside that window, the pending
actions may drop to zero, and startup will be declared complete before the
device actually starts activating.
Instead, ensure that the pending action is added when the internal activation
is actually started (eg, when NMActiveConnection receives the NMDevice object).
2013-12-10 22:11:09 -06:00
|
|
|
|
2014-02-12 10:40:24 -05:00
|
|
|
if (!priv->assumed) {
|
|
|
|
|
priv->pending_activation_id = g_strdup_printf ("activation::%p", (void *)self);
|
2014-04-28 11:18:05 +02:00
|
|
|
nm_device_add_pending_action (device, priv->pending_activation_id, TRUE);
|
2014-02-12 10:40:24 -05:00
|
|
|
}
|
2014-10-23 17:04:49 -05:00
|
|
|
} else
|
|
|
|
|
priv->device = NULL;
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_INT_DEVICE);
|
|
|
|
|
|
|
|
|
|
g_signal_emit (self, signals[DEVICE_CHANGED], 0, priv->device, old_device);
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DEVICES);
|
|
|
|
|
|
2013-09-16 17:43:31 -05:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-27 12:16:57 -05:00
|
|
|
NMActiveConnection *
|
2012-08-22 09:38:01 -05:00
|
|
|
nm_active_connection_get_master (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->master;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-27 17:13:43 -05:00
|
|
|
/**
|
|
|
|
|
* nm_active_connection_get_master_ready:
|
|
|
|
|
* @self: the #NMActiveConnection
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the connection has a master connection, and that
|
|
|
|
|
* master connection is ready to accept slaves. Otherwise %FALSE.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_active_connection_get_master_ready (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_ACTIVE_CONNECTION (self), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->master_ready;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
check_master_ready (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
NMActiveConnectionState master_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
|
|
|
|
|
|
2013-10-25 19:33:01 -05:00
|
|
|
if (priv->state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING) {
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (not activating)", self);
|
2013-09-27 17:13:43 -05:00
|
|
|
return;
|
2013-10-25 19:33:01 -05:00
|
|
|
}
|
|
|
|
|
if (!priv->master) {
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (no master)", self);
|
2013-09-27 17:13:43 -05:00
|
|
|
return;
|
2013-10-25 19:33:01 -05:00
|
|
|
}
|
|
|
|
|
if (priv->master_ready) {
|
|
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (already signaled)", self);
|
2013-09-27 17:13:43 -05:00
|
|
|
return;
|
2013-10-25 19:33:01 -05:00
|
|
|
}
|
2013-09-27 17:13:43 -05:00
|
|
|
|
|
|
|
|
/* ActiveConnetions don't enter the ACTIVATING state until they have a
|
|
|
|
|
* NMDevice in PREPARE or higher states, so the master active connection's
|
|
|
|
|
* device will be ready to accept slaves when the master is in ACTIVATING
|
|
|
|
|
* or higher states.
|
|
|
|
|
*/
|
|
|
|
|
master_state = nm_active_connection_get_state (priv->master);
|
2013-10-25 19:33:01 -05:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection [%p] state now '%s' (%d)",
|
|
|
|
|
self, priv->master, state_to_string (master_state), master_state);
|
|
|
|
|
|
2013-09-27 17:13:43 -05:00
|
|
|
if ( master_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATING
|
|
|
|
|
|| master_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
2013-10-25 19:33:01 -05:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%p): signalling master-ready", self);
|
|
|
|
|
|
2013-09-27 17:13:43 -05:00
|
|
|
priv->master_ready = TRUE;
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_INT_MASTER_READY);
|
|
|
|
|
|
|
|
|
|
/* Also notify clients to recheck the exported 'master' property to
|
|
|
|
|
* ensure that if the master connection was created without a device
|
|
|
|
|
* that we notify clients when the master device is known.
|
|
|
|
|
*/
|
|
|
|
|
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_MASTER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-28 09:08:43 -05:00
|
|
|
static void
|
|
|
|
|
master_state_cb (NMActiveConnection *master,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnection *self = NM_ACTIVE_CONNECTION (user_data);
|
|
|
|
|
NMActiveConnectionState master_state = nm_active_connection_get_state (master);
|
|
|
|
|
|
2013-09-27 17:13:43 -05:00
|
|
|
check_master_ready (self);
|
|
|
|
|
|
2013-10-25 19:33:01 -05:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection [%p] state now '%s' (%d)",
|
|
|
|
|
self, master, state_to_string (master_state), master_state);
|
|
|
|
|
|
2014-01-02 14:59:46 -05:00
|
|
|
if (master_state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATING &&
|
|
|
|
|
nm_active_connection_get_device (master) == NULL) {
|
|
|
|
|
/* Master failed without ever creating its device */
|
2013-08-28 09:08:43 -05:00
|
|
|
if (NM_ACTIVE_CONNECTION_GET_CLASS (self)->master_failed)
|
|
|
|
|
NM_ACTIVE_CONNECTION_GET_CLASS (self)->master_failed (self);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-29 16:26:09 -05:00
|
|
|
/**
|
|
|
|
|
* nm_active_connection_set_master:
|
|
|
|
|
* @self: the #NMActiveConnection
|
|
|
|
|
* @master: if the activation depends on another device (ie, bond or bridge
|
2013-08-27 12:16:57 -05:00
|
|
|
* master to which this device will be enslaved) pass the #NMActiveConnection
|
|
|
|
|
* that this activation request is a child of
|
2013-07-29 16:26:09 -05:00
|
|
|
*
|
2013-08-27 12:16:57 -05:00
|
|
|
* Sets the master active connection of @self.
|
2013-07-29 16:26:09 -05:00
|
|
|
*/
|
|
|
|
|
void
|
2013-08-27 12:16:57 -05:00
|
|
|
nm_active_connection_set_master (NMActiveConnection *self, NMActiveConnection *master)
|
2013-07-29 16:26:09 -05:00
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (self));
|
2013-08-27 12:16:57 -05:00
|
|
|
g_return_if_fail (NM_IS_ACTIVE_CONNECTION (master));
|
2013-07-29 16:26:09 -05:00
|
|
|
|
|
|
|
|
priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
2013-08-27 12:16:57 -05:00
|
|
|
|
2013-07-29 16:26:09 -05:00
|
|
|
/* Master is write-once, and must be set before exporting the object */
|
|
|
|
|
g_return_if_fail (priv->master == NULL);
|
|
|
|
|
g_return_if_fail (priv->path == NULL);
|
2013-09-16 17:43:31 -05:00
|
|
|
if (priv->device) {
|
|
|
|
|
/* Note, the master ActiveConnection may not yet have a device */
|
|
|
|
|
g_return_if_fail (priv->device != nm_active_connection_get_device (master));
|
|
|
|
|
}
|
2013-07-29 16:26:09 -05:00
|
|
|
|
2013-10-25 19:33:01 -05:00
|
|
|
nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection is [%p] %s",
|
2014-03-05 21:15:09 +01:00
|
|
|
self, master, nm_active_connection_get_id (master));
|
2013-10-25 19:33:01 -05:00
|
|
|
|
2013-07-29 16:26:09 -05:00
|
|
|
priv->master = g_object_ref (master);
|
2013-08-28 09:08:43 -05:00
|
|
|
g_signal_connect (priv->master,
|
|
|
|
|
"notify::" NM_ACTIVE_CONNECTION_STATE,
|
|
|
|
|
(GCallback) master_state_cb,
|
|
|
|
|
self);
|
2013-09-27 17:13:43 -05:00
|
|
|
|
|
|
|
|
check_master_ready (self);
|
2013-07-29 16:26:09 -05:00
|
|
|
}
|
|
|
|
|
|
2013-11-07 01:04:06 -06:00
|
|
|
void
|
|
|
|
|
nm_active_connection_set_assumed (NMActiveConnection *self, gboolean assumed)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (priv->assumed == FALSE);
|
|
|
|
|
priv->assumed = assumed;
|
2014-02-12 10:40:24 -05:00
|
|
|
|
|
|
|
|
if (priv->pending_activation_id) {
|
2014-04-28 11:18:05 +02:00
|
|
|
nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE);
|
2014-02-12 10:40:24 -05:00
|
|
|
g_clear_pointer (&priv->pending_activation_id, g_free);
|
|
|
|
|
}
|
2013-11-07 01:04:06 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
nm_active_connection_get_assumed (NMActiveConnection *self)
|
|
|
|
|
{
|
|
|
|
|
return NM_ACTIVE_CONNECTION_GET_PRIVATE (self)->assumed;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
/****************************************************************/
|
|
|
|
|
|
2012-09-17 10:53:41 -05:00
|
|
|
static void
|
|
|
|
|
auth_done (NMAuthChain *chain,
|
|
|
|
|
GError *error,
|
|
|
|
|
DBusGMethodInvocation *unused,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnection *self = NM_ACTIVE_CONNECTION (user_data);
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
NMAuthCallResult result;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->chain == chain);
|
|
|
|
|
g_assert (priv->result_func != NULL);
|
|
|
|
|
|
|
|
|
|
/* Must stay alive over the callback */
|
|
|
|
|
g_object_ref (self);
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
priv->result_func (self, FALSE, error->message, priv->user_data1, priv->user_data2);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Caller has had a chance to obtain authorization, so we only need to
|
|
|
|
|
* check for 'yes' here.
|
|
|
|
|
*/
|
|
|
|
|
result = nm_auth_chain_get_result (chain, NM_AUTH_PERMISSION_NETWORK_CONTROL);
|
|
|
|
|
if (result != NM_AUTH_CALL_RESULT_YES) {
|
|
|
|
|
priv->result_func (self,
|
|
|
|
|
FALSE,
|
|
|
|
|
"Not authorized to control networking.",
|
|
|
|
|
priv->user_data1,
|
|
|
|
|
priv->user_data2);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->wifi_shared_permission) {
|
|
|
|
|
result = nm_auth_chain_get_result (chain, priv->wifi_shared_permission);
|
|
|
|
|
if (result != NM_AUTH_CALL_RESULT_YES) {
|
|
|
|
|
priv->result_func (self,
|
|
|
|
|
FALSE,
|
|
|
|
|
"Not authorized to share connections via wifi.",
|
|
|
|
|
priv->user_data1,
|
|
|
|
|
priv->user_data2);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Otherwise authorized and available to activate */
|
|
|
|
|
priv->result_func (self, TRUE, NULL, priv->user_data1, priv->user_data2);
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
nm_auth_chain_unref (chain);
|
|
|
|
|
priv->chain = NULL;
|
|
|
|
|
priv->result_func = NULL;
|
|
|
|
|
priv->user_data1 = NULL;
|
|
|
|
|
priv->user_data2 = NULL;
|
|
|
|
|
|
|
|
|
|
g_object_unref (self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_active_connection_authorize:
|
|
|
|
|
* @self: the #NMActiveConnection
|
|
|
|
|
* @result_func: function to be called on success or error
|
|
|
|
|
* @user_data1: pointer passed to @result_func
|
|
|
|
|
* @user_data2: additional pointer passed to @result_func
|
|
|
|
|
*
|
|
|
|
|
* Checks whether the subject that initiated the active connection (read from
|
|
|
|
|
* the #NMActiveConnection::subject property) is authorized to complete this
|
|
|
|
|
* activation request.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
nm_active_connection_authorize (NMActiveConnection *self,
|
|
|
|
|
NMActiveConnectionAuthResultFunc result_func,
|
|
|
|
|
gpointer user_data1,
|
|
|
|
|
gpointer user_data2)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
const char *wifi_permission = NULL;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (result_func != NULL);
|
|
|
|
|
g_return_if_fail (priv->chain == NULL);
|
|
|
|
|
|
|
|
|
|
priv->chain = nm_auth_chain_new_subject (priv->subject, NULL, auth_done, self);
|
|
|
|
|
g_assert (priv->chain);
|
|
|
|
|
|
|
|
|
|
/* Check that the subject is allowed to use networking at all */
|
|
|
|
|
nm_auth_chain_add_call (priv->chain, NM_AUTH_PERMISSION_NETWORK_CONTROL, TRUE);
|
|
|
|
|
|
|
|
|
|
/* Shared wifi connections require special permissions too */
|
|
|
|
|
wifi_permission = nm_utils_get_shared_wifi_permission (priv->connection);
|
|
|
|
|
if (wifi_permission) {
|
|
|
|
|
priv->wifi_shared_permission = wifi_permission;
|
|
|
|
|
nm_auth_chain_add_call (priv->chain, wifi_permission, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Wait for authorization */
|
|
|
|
|
priv->result_func = result_func;
|
|
|
|
|
priv->user_data1 = user_data1;
|
|
|
|
|
priv->user_data2 = user_data2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
static void
|
|
|
|
|
nm_active_connection_init (NMActiveConnection *self)
|
|
|
|
|
{
|
2012-02-03 14:53:09 -06:00
|
|
|
}
|
|
|
|
|
|
2013-07-29 13:11:47 -05:00
|
|
|
static void
|
|
|
|
|
constructed (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object);
|
|
|
|
|
g_assert (NM_ACTIVE_CONNECTION_GET_PRIVATE (object)->subject);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
static void
|
|
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
|
2012-09-17 10:28:11 -05:00
|
|
|
const char *tmp;
|
2012-02-03 14:53:09 -06:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2012-08-22 09:38:01 -05:00
|
|
|
case PROP_INT_CONNECTION:
|
|
|
|
|
g_warn_if_fail (priv->connection == NULL);
|
|
|
|
|
priv->connection = g_value_dup_object (value);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_INT_DEVICE:
|
2013-09-16 17:43:31 -05:00
|
|
|
nm_active_connection_set_device (NM_ACTIVE_CONNECTION (object), g_value_get_object (value));
|
2012-08-22 09:38:01 -05:00
|
|
|
break;
|
2013-07-29 13:11:47 -05:00
|
|
|
case PROP_INT_SUBJECT:
|
|
|
|
|
priv->subject = g_value_dup_object (value);
|
2012-08-22 09:38:01 -05:00
|
|
|
break;
|
|
|
|
|
case PROP_INT_MASTER:
|
2013-07-29 16:26:09 -05:00
|
|
|
nm_active_connection_set_master (NM_ACTIVE_CONNECTION (object), g_value_get_object (value));
|
2012-08-22 09:38:01 -05:00
|
|
|
break;
|
2012-02-03 14:53:09 -06:00
|
|
|
case PROP_SPECIFIC_OBJECT:
|
2012-09-17 10:28:11 -05:00
|
|
|
tmp = g_value_get_boxed (value);
|
|
|
|
|
/* NM uses "/" to mean NULL */
|
|
|
|
|
if (g_strcmp0 (tmp, "/") != 0)
|
|
|
|
|
priv->specific_object = g_value_dup_boxed (value);
|
2012-02-03 14:53:09 -06:00
|
|
|
break;
|
|
|
|
|
case PROP_DEFAULT:
|
2014-06-20 17:56:06 +02:00
|
|
|
priv->is_default = !!g_value_get_boolean (value);
|
2012-02-03 14:53:09 -06:00
|
|
|
break;
|
|
|
|
|
case PROP_DEFAULT6:
|
2014-06-20 17:56:06 +02:00
|
|
|
priv->is_default6 = !!g_value_get_boolean (value);
|
2012-02-03 14:53:09 -06:00
|
|
|
break;
|
|
|
|
|
case PROP_VPN:
|
|
|
|
|
priv->vpn = g_value_get_boolean (value);
|
|
|
|
|
break;
|
2012-08-22 09:38:01 -05:00
|
|
|
case PROP_MASTER:
|
|
|
|
|
break;
|
2012-02-03 14:53:09 -06:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (object);
|
|
|
|
|
GPtrArray *devices;
|
2013-08-27 12:16:57 -05:00
|
|
|
NMDevice *master_device = NULL;
|
2012-02-03 14:53:09 -06:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_CONNECTION:
|
|
|
|
|
g_value_set_boxed (value, nm_connection_get_path (priv->connection));
|
|
|
|
|
break;
|
2014-03-03 15:01:36 +01:00
|
|
|
case PROP_ID:
|
|
|
|
|
g_value_set_string (value, nm_connection_get_id (priv->connection));
|
|
|
|
|
break;
|
2012-02-03 14:53:09 -06:00
|
|
|
case PROP_UUID:
|
|
|
|
|
g_value_set_string (value, nm_connection_get_uuid (priv->connection));
|
|
|
|
|
break;
|
2014-03-03 15:01:36 +01:00
|
|
|
case PROP_TYPE:
|
|
|
|
|
g_value_set_string (value, nm_connection_get_connection_type (priv->connection));
|
|
|
|
|
break;
|
2012-02-03 14:53:09 -06:00
|
|
|
case PROP_SPECIFIC_OBJECT:
|
|
|
|
|
g_value_set_boxed (value, priv->specific_object ? priv->specific_object : "/");
|
|
|
|
|
break;
|
|
|
|
|
case PROP_DEVICES:
|
|
|
|
|
devices = g_ptr_array_sized_new (1);
|
2013-09-27 14:40:18 -05:00
|
|
|
if (priv->device && priv->state < NM_ACTIVE_CONNECTION_STATE_DEACTIVATED)
|
2012-08-22 09:38:01 -05:00
|
|
|
g_ptr_array_add (devices, g_strdup (nm_device_get_path (priv->device)));
|
2012-02-03 14:53:09 -06:00
|
|
|
g_value_take_boxed (value, devices);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_STATE:
|
2014-10-16 18:00:54 -04:00
|
|
|
if (priv->state_set)
|
|
|
|
|
g_value_set_uint (value, priv->state);
|
|
|
|
|
else {
|
|
|
|
|
/* When the AC has just been created, its externally-visible state should
|
|
|
|
|
* be "ACTIVATING", even though internally it is "UNKNOWN".
|
|
|
|
|
*/
|
|
|
|
|
g_value_set_uint (value, NM_ACTIVE_CONNECTION_STATE_ACTIVATING);
|
|
|
|
|
}
|
2012-02-03 14:53:09 -06:00
|
|
|
break;
|
|
|
|
|
case PROP_DEFAULT:
|
|
|
|
|
g_value_set_boolean (value, priv->is_default);
|
|
|
|
|
break;
|
2013-12-18 08:46:43 -05:00
|
|
|
case PROP_IP4_CONFIG:
|
|
|
|
|
/* The IP and DHCP config properties may be overridden by a subclass */
|
|
|
|
|
g_value_set_boxed (value, "/");
|
|
|
|
|
break;
|
|
|
|
|
case PROP_DHCP4_CONFIG:
|
|
|
|
|
g_value_set_boxed (value, "/");
|
|
|
|
|
break;
|
2012-02-03 14:53:09 -06:00
|
|
|
case PROP_DEFAULT6:
|
|
|
|
|
g_value_set_boolean (value, priv->is_default6);
|
|
|
|
|
break;
|
2013-12-18 08:46:43 -05:00
|
|
|
case PROP_IP6_CONFIG:
|
|
|
|
|
g_value_set_boxed (value, "/");
|
|
|
|
|
break;
|
|
|
|
|
case PROP_DHCP6_CONFIG:
|
|
|
|
|
g_value_set_boxed (value, "/");
|
|
|
|
|
break;
|
2012-02-03 14:53:09 -06:00
|
|
|
case PROP_VPN:
|
|
|
|
|
g_value_set_boolean (value, priv->vpn);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_MASTER:
|
2013-08-27 12:16:57 -05:00
|
|
|
if (priv->master)
|
|
|
|
|
master_device = nm_active_connection_get_device (priv->master);
|
|
|
|
|
g_value_set_boxed (value, master_device ? nm_device_get_path (master_device) : "/");
|
2012-02-03 14:53:09 -06:00
|
|
|
break;
|
2013-07-29 13:11:47 -05:00
|
|
|
case PROP_INT_SUBJECT:
|
|
|
|
|
g_value_set_object (value, priv->subject);
|
|
|
|
|
break;
|
2013-09-27 17:13:43 -05:00
|
|
|
case PROP_INT_MASTER_READY:
|
|
|
|
|
g_value_set_boolean (value, priv->master_ready);
|
|
|
|
|
break;
|
2012-02-03 14:53:09 -06:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-03 16:49:21 +01:00
|
|
|
static void
|
2014-01-02 14:59:46 -05:00
|
|
|
_device_cleanup (NMActiveConnection *self)
|
2013-12-03 16:49:21 +01:00
|
|
|
{
|
2014-01-02 14:59:46 -05:00
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
|
|
|
|
|
|
|
|
|
if (priv->device) {
|
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_state_changed), self);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->device, G_CALLBACK (device_master_changed), self);
|
2013-12-03 16:49:21 +01:00
|
|
|
}
|
2014-01-02 14:59:46 -05:00
|
|
|
|
core: fix NMActiveConnection to properly add/remove pending action "activation"
When a new activation request is received, NetworkManager creates a new
NMActiveConnection to track that request. The device may already be activated,
in which case NetworkManager stops the old activation and starts the new one,
but both exist in parallel for a short period of time. If the old
NMActiveConnection is activating and already has a pending 'activation'
action, when the new NMActiveConnection adds its own 'activating' action,
they will clash. This is fixed by making each NMActiveConnection's activation
pending action uniquely named.
This fixes a g_warning with the following back trace:
#0 0x000000328224edfd in g_logv () from /lib64/libglib-2.0.so.0
#1 0x000000328224efe2 in g_log () from /lib64/libglib-2.0.so.0
#2 0x000000328224f2e6 in g_warn_message () from /lib64/libglib-2.0.so.0
#3 0x0000000000440aee in nm_device_add_pending_action (device=0x14002e0, action=0x50704a "activation") at devices/nm-device.c:7172
#4 0x000000000047525c in nm_active_connection_set_device (self=0x141b3c0, device=0x14002e0) at nm-active-connection.c:364
#5 0x0000000000475ec1 in set_property (object=0x141b3c0, prop_id=11, value=0x7fff7ff36c20, pspec=0x1405f70) at nm-active-connection.c:647
#6 0x0000003282615d3e in g_object_newv () from /lib64/libgobject-2.0.so.0
#7 0x00000032826162e6 in g_object_new_valist () from /lib64/libgobject-2.0.so.0
#8 0x0000003282616654 in g_object_new () from /lib64/libgobject-2.0.so.0
#9 0x0000000000474193 in nm_act_request_new (connection=0x13bb0e0, specific_object=0x0, subject=0x1447740, device=0x14002e0) at nm-activation-request.c:376
#10 0x000000000048e477 in _new_active_connection (self=0x13e8060, connection=0x13bb0e0, specific_object=0x0, device=0x14002e0, subject=0x1447740, error=0x7fff7ff36f90) at nm-manager.c:2947
#11 0x000000000048ed77 in impl_manager_activate_connection (self=0x13e8060, connection_path=0x134d590 "/org/freedesktop/NetworkManager/Settings/9", device_path=0x134d550 "/org/freedesktop/NetworkManager/Devices/1",
specific_object_path=0x0, context=0x143a9b0) at nm-manager.c:3206
#12 0x00000000004876c8 in dbus_glib_marshal_nm_manager_VOID__BOXED_BOXED_BOXED_POINTER (closure=0x7fff7ff37220, return_value=0x0, n_param_values=5, param_values=0x1448830, invocation_hint=0x0,
marshal_data=0x48e9dd <impl_manager_activate_connection>) at nm-manager-glue.h:189
#13 0x0000003284a0d6a9 in object_registration_message () from /lib64/libdbus-glib-1.so.2
#14 0x000000348ea1ce66 in _dbus_object_tree_dispatch_and_unlock () from /lib64/libdbus-1.so.3
#15 0x000000348ea0fa31 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#16 0x0000003284a0acc5 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#17 0x0000003282247df6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#18 0x0000003282248148 in g_main_context_iterate.isra.22 () from /lib64/libglib-2.0.so.0
#19 0x000000328224854a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#20 0x000000000042c6c0 in main (argc=1, argv=0x7fff7ff379b8) at main.c:629
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-16 15:02:38 +01:00
|
|
|
if (priv->pending_activation_id) {
|
2014-04-28 11:18:05 +02:00
|
|
|
nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE);
|
core: fix NMActiveConnection to properly add/remove pending action "activation"
When a new activation request is received, NetworkManager creates a new
NMActiveConnection to track that request. The device may already be activated,
in which case NetworkManager stops the old activation and starts the new one,
but both exist in parallel for a short period of time. If the old
NMActiveConnection is activating and already has a pending 'activation'
action, when the new NMActiveConnection adds its own 'activating' action,
they will clash. This is fixed by making each NMActiveConnection's activation
pending action uniquely named.
This fixes a g_warning with the following back trace:
#0 0x000000328224edfd in g_logv () from /lib64/libglib-2.0.so.0
#1 0x000000328224efe2 in g_log () from /lib64/libglib-2.0.so.0
#2 0x000000328224f2e6 in g_warn_message () from /lib64/libglib-2.0.so.0
#3 0x0000000000440aee in nm_device_add_pending_action (device=0x14002e0, action=0x50704a "activation") at devices/nm-device.c:7172
#4 0x000000000047525c in nm_active_connection_set_device (self=0x141b3c0, device=0x14002e0) at nm-active-connection.c:364
#5 0x0000000000475ec1 in set_property (object=0x141b3c0, prop_id=11, value=0x7fff7ff36c20, pspec=0x1405f70) at nm-active-connection.c:647
#6 0x0000003282615d3e in g_object_newv () from /lib64/libgobject-2.0.so.0
#7 0x00000032826162e6 in g_object_new_valist () from /lib64/libgobject-2.0.so.0
#8 0x0000003282616654 in g_object_new () from /lib64/libgobject-2.0.so.0
#9 0x0000000000474193 in nm_act_request_new (connection=0x13bb0e0, specific_object=0x0, subject=0x1447740, device=0x14002e0) at nm-activation-request.c:376
#10 0x000000000048e477 in _new_active_connection (self=0x13e8060, connection=0x13bb0e0, specific_object=0x0, device=0x14002e0, subject=0x1447740, error=0x7fff7ff36f90) at nm-manager.c:2947
#11 0x000000000048ed77 in impl_manager_activate_connection (self=0x13e8060, connection_path=0x134d590 "/org/freedesktop/NetworkManager/Settings/9", device_path=0x134d550 "/org/freedesktop/NetworkManager/Devices/1",
specific_object_path=0x0, context=0x143a9b0) at nm-manager.c:3206
#12 0x00000000004876c8 in dbus_glib_marshal_nm_manager_VOID__BOXED_BOXED_BOXED_POINTER (closure=0x7fff7ff37220, return_value=0x0, n_param_values=5, param_values=0x1448830, invocation_hint=0x0,
marshal_data=0x48e9dd <impl_manager_activate_connection>) at nm-manager-glue.h:189
#13 0x0000003284a0d6a9 in object_registration_message () from /lib64/libdbus-glib-1.so.2
#14 0x000000348ea1ce66 in _dbus_object_tree_dispatch_and_unlock () from /lib64/libdbus-1.so.3
#15 0x000000348ea0fa31 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
#16 0x0000003284a0acc5 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
#17 0x0000003282247df6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#18 0x0000003282248148 in g_main_context_iterate.isra.22 () from /lib64/libglib-2.0.so.0
#19 0x000000328224854a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#20 0x000000000042c6c0 in main (argc=1, argv=0x7fff7ff379b8) at main.c:629
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-16 15:02:38 +01:00
|
|
|
g_clear_pointer (&priv->pending_activation_id, g_free);
|
|
|
|
|
}
|
2014-01-02 14:59:46 -05:00
|
|
|
|
2013-12-03 16:49:21 +01:00
|
|
|
g_clear_object (&priv->device);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
static void
|
|
|
|
|
dispose (GObject *object)
|
|
|
|
|
{
|
2014-01-02 14:59:46 -05:00
|
|
|
NMActiveConnection *self = NM_ACTIVE_CONNECTION (object);
|
|
|
|
|
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
2012-08-22 09:38:01 -05:00
|
|
|
|
2012-09-17 10:53:41 -05:00
|
|
|
if (priv->chain) {
|
|
|
|
|
nm_auth_chain_unref (priv->chain);
|
|
|
|
|
priv->chain = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
g_free (priv->path);
|
|
|
|
|
priv->path = NULL;
|
|
|
|
|
g_free (priv->specific_object);
|
|
|
|
|
priv->specific_object = NULL;
|
|
|
|
|
|
|
|
|
|
g_clear_object (&priv->connection);
|
2013-09-27 14:40:18 -05:00
|
|
|
|
2014-01-02 14:59:46 -05:00
|
|
|
_device_cleanup (self);
|
2013-08-28 09:08:43 -05:00
|
|
|
|
|
|
|
|
if (priv->master) {
|
|
|
|
|
g_signal_handlers_disconnect_by_func (priv->master,
|
|
|
|
|
(GCallback) master_state_cb,
|
2014-01-02 14:59:46 -05:00
|
|
|
self);
|
2013-08-28 09:08:43 -05:00
|
|
|
}
|
2012-08-22 09:38:01 -05:00
|
|
|
g_clear_object (&priv->master);
|
2013-07-29 13:11:47 -05:00
|
|
|
g_clear_object (&priv->subject);
|
2012-08-22 09:38:01 -05:00
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_active_connection_parent_class)->dispose (object);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-03 14:53:09 -06:00
|
|
|
static void
|
2013-05-07 12:18:41 -04:00
|
|
|
nm_active_connection_class_init (NMActiveConnectionClass *ac_class)
|
2012-02-03 14:53:09 -06:00
|
|
|
{
|
2013-05-07 12:18:41 -04:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (ac_class);
|
2012-02-03 14:53:09 -06:00
|
|
|
|
2013-05-07 12:18:41 -04:00
|
|
|
g_type_class_add_private (ac_class, sizeof (NMActiveConnectionPrivate));
|
2012-02-03 14:53:09 -06:00
|
|
|
|
|
|
|
|
/* virtual methods */
|
|
|
|
|
object_class->get_property = get_property;
|
|
|
|
|
object_class->set_property = set_property;
|
2013-07-29 13:11:47 -05:00
|
|
|
object_class->constructed = constructed;
|
2012-02-03 14:53:09 -06:00
|
|
|
object_class->dispose = dispose;
|
|
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
/* D-Bus exported properties */
|
2014-06-09 16:17:37 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_CONNECTION,
|
|
|
|
|
g_param_spec_boxed (NM_ACTIVE_CONNECTION_CONNECTION, "", "",
|
2013-12-18 08:46:43 -05:00
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
2014-06-09 16:17:37 -04:00
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_ID,
|
|
|
|
|
g_param_spec_string (NM_ACTIVE_CONNECTION_ID, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_UUID,
|
|
|
|
|
g_param_spec_string (NM_ACTIVE_CONNECTION_UUID, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_TYPE,
|
|
|
|
|
g_param_spec_string (NM_ACTIVE_CONNECTION_TYPE, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_SPECIFIC_OBJECT,
|
|
|
|
|
g_param_spec_boxed (NM_ACTIVE_CONNECTION_SPECIFIC_OBJECT, "", "",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DEVICES,
|
|
|
|
|
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DEVICES, "", "",
|
|
|
|
|
DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_STATE,
|
|
|
|
|
g_param_spec_uint (NM_ACTIVE_CONNECTION_STATE, "", "",
|
|
|
|
|
NM_ACTIVE_CONNECTION_STATE_UNKNOWN,
|
|
|
|
|
NM_ACTIVE_CONNECTION_STATE_DEACTIVATING,
|
|
|
|
|
NM_ACTIVE_CONNECTION_STATE_UNKNOWN,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DEFAULT,
|
|
|
|
|
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_IP4_CONFIG,
|
|
|
|
|
g_param_spec_boxed (NM_ACTIVE_CONNECTION_IP4_CONFIG, "", "",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2013-12-18 08:46:43 -05:00
|
|
|
|
2014-06-09 16:17:37 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DHCP4_CONFIG,
|
|
|
|
|
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DHCP4_CONFIG, "", "",
|
2013-12-18 08:46:43 -05:00
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
2014-06-09 16:17:37 -04:00
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DEFAULT6,
|
|
|
|
|
g_param_spec_boolean (NM_ACTIVE_CONNECTION_DEFAULT6, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_IP6_CONFIG,
|
|
|
|
|
g_param_spec_boxed (NM_ACTIVE_CONNECTION_IP6_CONFIG, "", "",
|
2013-12-18 08:46:43 -05:00
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
2014-06-09 16:17:37 -04:00
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2013-12-18 08:46:43 -05:00
|
|
|
|
2014-06-09 16:17:37 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_DHCP6_CONFIG,
|
|
|
|
|
g_param_spec_boxed (NM_ACTIVE_CONNECTION_DHCP6_CONFIG, "", "",
|
|
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
|
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_VPN,
|
|
|
|
|
g_param_spec_boolean (NM_ACTIVE_CONNECTION_VPN, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_MASTER,
|
|
|
|
|
g_param_spec_boxed (NM_ACTIVE_CONNECTION_MASTER, "", "",
|
2013-12-18 08:46:43 -05:00
|
|
|
DBUS_TYPE_G_OBJECT_PATH,
|
2014-06-09 16:17:37 -04:00
|
|
|
G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2012-02-03 14:53:09 -06:00
|
|
|
|
2012-08-22 09:38:01 -05:00
|
|
|
/* Internal properties */
|
2014-06-09 16:17:37 -04:00
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_INT_CONNECTION,
|
|
|
|
|
g_param_spec_object (NM_ACTIVE_CONNECTION_INT_CONNECTION, "", "",
|
|
|
|
|
NM_TYPE_CONNECTION,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_INT_DEVICE,
|
|
|
|
|
g_param_spec_object (NM_ACTIVE_CONNECTION_INT_DEVICE, "", "",
|
|
|
|
|
NM_TYPE_DEVICE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_INT_SUBJECT,
|
|
|
|
|
g_param_spec_object (NM_ACTIVE_CONNECTION_INT_SUBJECT, "", "",
|
|
|
|
|
NM_TYPE_AUTH_SUBJECT,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_INT_MASTER,
|
|
|
|
|
g_param_spec_object (NM_ACTIVE_CONNECTION_INT_MASTER, "", "",
|
|
|
|
|
NM_TYPE_ACTIVE_CONNECTION,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
|
(object_class, PROP_INT_MASTER_READY,
|
|
|
|
|
g_param_spec_boolean (NM_ACTIVE_CONNECTION_INT_MASTER_READY, "", "",
|
|
|
|
|
FALSE, G_PARAM_READABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2013-09-27 17:13:43 -05:00
|
|
|
|
2014-10-23 17:04:49 -05:00
|
|
|
signals[DEVICE_CHANGED] =
|
|
|
|
|
g_signal_new (NM_ACTIVE_CONNECTION_DEVICE_CHANGED,
|
|
|
|
|
G_OBJECT_CLASS_TYPE (object_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (NMActiveConnectionClass, device_changed),
|
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
|
G_TYPE_NONE, 2, NM_TYPE_DEVICE, NM_TYPE_DEVICE);
|
|
|
|
|
|
2013-05-07 12:18:41 -04:00
|
|
|
nm_dbus_manager_register_exported_type (nm_dbus_manager_get (),
|
|
|
|
|
G_TYPE_FROM_CLASS (ac_class),
|
|
|
|
|
&dbus_glib_nm_active_connection_object_info);
|
2008-03-26 13:43:01 +00:00
|
|
|
}
|
|
|
|
|
|