summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-06-25 14:35:37 -0500
committerDan Williams <dcbw@redhat.com>2014-06-25 15:23:04 -0500
commit7f3222fb6796c36136d52e58df41be1b5e9d7e4b (patch)
tree110c8775880885daf127ad5fd63fdba9d34315da
parentae6ad0d524eef37e9043d883c9faf04d8d0229f3 (diff)
downloadNetworkManager-dcbw/child-interfaces.tar.gz
vpn: unmanage VPN child devices when their interface name is knowndcbw/child-interfaces
Ensure that VPN child devices are unmanaged when the VPN connection knows their interface name.
-rw-r--r--src/nm-manager.c33
-rw-r--r--src/vpn-manager/nm-vpn-connection.c12
-rw-r--r--src/vpn-manager/nm-vpn-connection.h7
3 files changed, 50 insertions, 2 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index c27f81ade7..5d2b2d4866 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -283,6 +283,9 @@ static void active_connection_state_changed (NMActiveConnection *active,
static void active_connection_default_changed (NMActiveConnection *active,
GParamSpec *pspec,
NMManager *self);
+static void vpn_connection_ip_iface_changed (NMActiveConnection *active,
+ GParamSpec *pspec,
+ NMManager *self);
/* Returns: whether to notify D-Bus of the removal or not */
static gboolean
@@ -299,6 +302,7 @@ active_connection_remove (NMManager *self, NMActiveConnection *active)
g_signal_emit (self, signals[ACTIVE_CONNECTION_REMOVED], 0, active);
g_signal_handlers_disconnect_by_func (active, active_connection_state_changed, self);
g_signal_handlers_disconnect_by_func (active, active_connection_default_changed, self);
+ g_signal_handlers_disconnect_by_func (active, vpn_connection_ip_iface_changed, self);
g_object_unref (active);
}
@@ -360,6 +364,29 @@ active_connection_default_changed (NMActiveConnection *active,
nm_manager_update_state (self);
}
+static void
+vpn_connection_ip_iface_changed (NMActiveConnection *active,
+ GParamSpec *pspec,
+ NMManager *self)
+{
+ int ifindex = nm_vpn_connection_get_ip_ifindex (NM_VPN_CONNECTION (active));
+ NMDevice *subdevice;
+
+ if (ifindex <= 0)
+ return;
+
+ /* Ensure the VPN's child devices are kept unmanaged since the VPN
+ * controls them. They are not independently managable.
+ */
+ subdevice = nm_manager_get_device_by_ifindex (self, ifindex);
+ if (subdevice) {
+ nm_device_set_unmanaged (subdevice,
+ NM_UNMANAGED_CHILD,
+ TRUE,
+ NM_DEVICE_STATE_REASON_CHILD_NOW_UNMANAGED);
+ }
+}
+
/**
* active_connection_add():
* @self: the #NMManager
@@ -389,6 +416,12 @@ active_connection_add (NMManager *self, NMActiveConnection *active)
"notify::" NM_ACTIVE_CONNECTION_DEFAULT6,
G_CALLBACK (active_connection_default_changed),
self);
+ if (NM_IS_VPN_CONNECTION (active)) {
+ g_signal_connect (active,
+ "notify::" NM_VPN_CONNECTION_INT_IP_IFINDEX,
+ G_CALLBACK (vpn_connection_ip_iface_changed),
+ self);
+ }
g_signal_emit (self, signals[ACTIVE_CONNECTION_ADDED], 0, active);
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index e42d676f84..01b272d193 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -122,6 +122,7 @@ enum {
PROP_BANNER,
PROP_IP4_CONFIG,
PROP_IP6_CONFIG,
+ PROP_IP_IFINDEX,
PROP_MASTER = 2000,
LAST_PROP
@@ -241,6 +242,7 @@ vpn_cleanup (NMVPNConnection *connection, NMDevice *parent_dev)
g_free (priv->ip_iface);
priv->ip_iface = NULL;
priv->ip_ifindex = 0;
+ g_object_notify (G_OBJECT (connection), NM_VPN_CONNECTION_INT_IP_IFINDEX);
/* Clear out connection secrets to ensure that the settings service
* gets asked for them next time the connection is activated.
@@ -962,6 +964,7 @@ process_generic_config (NMVPNConnection *connection,
nm_vpn_connection_config_maybe_complete (connection, FALSE);
return FALSE;
}
+ g_object_notify (G_OBJECT (connection), NM_VPN_CONNECTION_INT_IP_IFINDEX);
}
g_clear_pointer (&priv->banner, g_free);
@@ -1996,6 +1999,9 @@ get_property (GObject *object, guint prop_id,
else
g_value_set_boxed (value, "/");
break;
+ case PROP_IP_IFINDEX:
+ g_value_set_int (value, priv->ip_ifindex);
+ break;
case PROP_MASTER:
parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (object));
g_value_set_boxed (value, parent_dev ? nm_device_get_path (parent_dev) : "/");
@@ -2045,6 +2051,12 @@ nm_vpn_connection_class_init (NMVPNConnectionClass *connection_class)
g_object_class_override_property (object_class, PROP_IP6_CONFIG,
NM_ACTIVE_CONNECTION_IP6_CONFIG);
+ g_object_class_install_property
+ (object_class, PROP_IP_IFINDEX,
+ g_param_spec_int (NM_VPN_CONNECTION_INT_IP_IFINDEX, "", "",
+ -1, G_MAXINT, 0,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
/* signals */
signals[VPN_STATE_CHANGED] =
g_signal_new ("vpn-state-changed",
diff --git a/src/vpn-manager/nm-vpn-connection.h b/src/vpn-manager/nm-vpn-connection.h
index c9c88cda14..f5ead55197 100644
--- a/src/vpn-manager/nm-vpn-connection.h
+++ b/src/vpn-manager/nm-vpn-connection.h
@@ -36,8 +36,11 @@
#define NM_VPN_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_VPN_CONNECTION, NMVPNConnectionClass))
/* Properties */
-#define NM_VPN_CONNECTION_VPN_STATE "vpn-state"
-#define NM_VPN_CONNECTION_BANNER "banner"
+#define NM_VPN_CONNECTION_VPN_STATE "vpn-state"
+#define NM_VPN_CONNECTION_BANNER "banner"
+
+/* not exported */
+#define NM_VPN_CONNECTION_INT_IP_IFINDEX "ip-ifindex"
/* Signals */
/* not exported: includes old reason code */