about summary refs log tree commit diff
path: root/src/vpn-manager
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpn-manager')
-rw-r--r--src/vpn-manager/Makefile.in6
-rw-r--r--src/vpn-manager/nm-vpn-connection.c34
-rw-r--r--src/vpn-manager/nm-vpn-connection.h1
-rw-r--r--src/vpn-manager/nm-vpn-manager.c21
-rw-r--r--src/vpn-manager/nm-vpn-manager.h7
5 files changed, 54 insertions, 15 deletions
diff --git a/src/vpn-manager/Makefile.in b/src/vpn-manager/Makefile.in
index 3785667e..02335d88 100644
--- a/src/vpn-manager/Makefile.in
+++ b/src/vpn-manager/Makefile.in
@@ -190,6 +190,12 @@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
 LIBICONV = @LIBICONV@
 LIBINTL = @LIBINTL@
 LIBM = @LIBM@
+LIBNL1_CFLAGS = @LIBNL1_CFLAGS@
+LIBNL1_LIBS = @LIBNL1_LIBS@
+LIBNL2_CFLAGS = @LIBNL2_CFLAGS@
+LIBNL2_LIBS = @LIBNL2_LIBS@
+LIBNL3_CFLAGS = @LIBNL3_CFLAGS@
+LIBNL3_LIBS = @LIBNL3_LIBS@
 LIBNL_CFLAGS = @LIBNL_CFLAGS@
 LIBNL_LIBS = @LIBNL_LIBS@
 LIBOBJS = @LIBOBJS@
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index 067b2dce..75ba6451 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -46,6 +46,7 @@
 #include "NetworkManagerUtils.h"
 #include "nm-dns-manager.h"
 #include "nm-netlink-monitor.h"
+#include "nm-netlink-utils.h"
 #include "nm-glib-compat.h"
 #include "settings/nm-settings-connection.h"
 
@@ -86,6 +87,7 @@ typedef struct {
 	NMIP4Config *ip4_config;
 	guint32 ip4_internal_gw;
 	char *ip_iface;
+	int ip_ifindex;
 	char *banner;
 
 	struct rtnl_route *gw_route;
@@ -424,6 +426,13 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
 		goto error;
 	}
 
+	/* Grab the interface index for address/routing operations */
+	priv->ip_ifindex = nm_netlink_iface_to_index (priv->ip_iface);
+	if (!priv->ip_ifindex) {
+		nm_log_err (LOGD_VPN, "(%s): failed to look up VPN interface index", priv->ip_iface);
+		goto error;
+	}
+
 	addr = nm_ip4_address_new ();
 	nm_ip4_address_set_prefix (addr, 24); /* default to class C */
 
@@ -529,9 +538,9 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
 	s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_IP4_CONFIG));
 	nm_utils_merge_ip4_config (config, s_ip4);
 
-	nm_system_device_set_up_down_with_iface (priv->ip_iface, TRUE, NULL);
+	nm_system_iface_set_up (priv->ip_ifindex, TRUE, NULL);
 
-	if (nm_system_apply_ip4_config (priv->ip_iface, config, 0, NM_IP4_COMPARE_FLAG_ALL)) {
+	if (nm_system_apply_ip4_config (priv->ip_ifindex, config, 0, NM_IP4_COMPARE_FLAG_ALL)) {
 		NMDnsManager *dns_mgr;
 
 		/* Add any explicit route to the VPN gateway through the parent device */
@@ -765,6 +774,14 @@ nm_vpn_connection_get_ip_iface (NMVPNConnection *connection)
 	return NM_VPN_CONNECTION_GET_PRIVATE (connection)->ip_iface;
 }
 
+int
+nm_vpn_connection_get_ip_ifindex (NMVPNConnection *connection)
+{
+	g_return_val_if_fail (NM_IS_VPN_CONNECTION (connection), -1);
+
+	return NM_VPN_CONNECTION_GET_PRIVATE (connection)->ip_ifindex;
+}
+
 NMDevice *
 nm_vpn_connection_get_parent_device (NMVPNConnection *connection)
 {
@@ -940,11 +957,11 @@ vpn_cleanup (NMVPNConnection *connection)
 {
 	NMVPNConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
 
-	if (priv->ip_iface) {
-		nm_system_device_set_up_down_with_iface (priv->ip_iface, FALSE, NULL);
+	if (priv->ip_ifindex) {
+		nm_system_iface_set_up (priv->ip_ifindex, FALSE, NULL);
 		/* FIXME: use AF_UNSPEC here when we have IPv6 support */
-		nm_system_device_flush_routes_with_iface (priv->ip_iface, AF_INET);
-		nm_system_device_flush_addresses_with_iface (priv->ip_iface);
+		nm_system_iface_flush_routes (priv->ip_ifindex, AF_INET);
+		nm_system_iface_flush_addresses (priv->ip_ifindex, AF_UNSPEC);
 	}
 
 	if (priv->ip4_config) {
@@ -958,12 +975,12 @@ vpn_cleanup (NMVPNConnection *connection)
 
 		/* Remove any previously added VPN gateway host route */
 		if (priv->gw_route)
-			rtnl_route_del (nm_netlink_get_default_handle (), priv->gw_route, 0);
+			nm_netlink_route_delete (priv->gw_route);
 
 		/* Reset routes and addresses of the currently active device */
 		parent_config = nm_device_get_ip4_config (priv->parent_dev);
 		if (parent_config) {
-			if (!nm_system_apply_ip4_config (nm_device_get_ip_iface (priv->parent_dev),
+			if (!nm_system_apply_ip4_config (nm_device_get_ip_ifindex (priv->parent_dev),
 			                                 nm_device_get_ip4_config (priv->parent_dev),
 			                                 nm_device_get_priority (priv->parent_dev),
 			                                 NM_IP4_COMPARE_FLAG_ADDRESSES | NM_IP4_COMPARE_FLAG_ROUTES)) {
@@ -982,6 +999,7 @@ vpn_cleanup (NMVPNConnection *connection)
 
 	g_free (priv->ip_iface);
 	priv->ip_iface = NULL;
+	priv->ip_ifindex = 0;
 
 	/* Clear out connection secrets to ensure that the settings service
 	 * gets asked for them next time the connection is activated.
diff --git a/src/vpn-manager/nm-vpn-connection.h b/src/vpn-manager/nm-vpn-connection.h
index ee8eb5b6..daf9483c 100644
--- a/src/vpn-manager/nm-vpn-connection.h
+++ b/src/vpn-manager/nm-vpn-connection.h
@@ -72,6 +72,7 @@ void                 nm_vpn_connection_disconnect      (NMVPNConnection *connect
                                                         NMVPNConnectionStateReason reason);
 NMIP4Config *        nm_vpn_connection_get_ip4_config  (NMVPNConnection *connection);
 const char *         nm_vpn_connection_get_ip_iface    (NMVPNConnection *connection);
+int                  nm_vpn_connection_get_ip_ifindex  (NMVPNConnection *connection);
 NMDevice *           nm_vpn_connection_get_parent_device (NMVPNConnection *connection);
 guint32              nm_vpn_connection_get_ip4_internal_gateway (NMVPNConnection *connection);
 
diff --git a/src/vpn-manager/nm-vpn-manager.c b/src/vpn-manager/nm-vpn-manager.c
index 6772bb18..da2cf25f 100644
--- a/src/vpn-manager/nm-vpn-manager.c
+++ b/src/vpn-manager/nm-vpn-manager.c
@@ -15,7 +15,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Copyright (C) 2005 - 2010 Red Hat, Inc.
+ * Copyright (C) 2005 - 2011 Red Hat, Inc.
  * Copyright (C) 2006 - 2008 Novell, Inc.
  */
 
@@ -306,9 +306,9 @@ nm_vpn_manager_get_active_connections (NMVPNManager *self)
 	return list;
 }
 
-NMConnection *
-nm_vpn_manager_get_connection_for_active (NMVPNManager *manager,
-                                          const char *active_path)
+NMVPNConnection *
+nm_vpn_manager_get_vpn_connection_for_active (NMVPNManager *manager,
+                                              const char *active_path)
 {
 	NMVPNManagerPrivate *priv;
 	GHashTableIter iter;
@@ -327,13 +327,24 @@ nm_vpn_manager_get_connection_for_active (NMVPNManager *manager,
 
 			ac_path = nm_vpn_connection_get_active_connection_path (vpn);
 			if (ac_path && !strcmp (ac_path, active_path))
-				return nm_vpn_connection_get_connection (vpn);
+				return vpn;
 		}
 	}
 
 	return NULL;
 }
 
+NMConnection *
+nm_vpn_manager_get_connection_for_active (NMVPNManager *manager,
+                                          const char *active_path)
+{
+	NMVPNConnection *vpn_con;
+
+	vpn_con = nm_vpn_manager_get_vpn_connection_for_active (manager, active_path);
+
+	return vpn_con ? nm_vpn_connection_get_connection (vpn_con) : NULL;
+}
+
 static char *
 service_name_from_file (const char *path)
 {
diff --git a/src/vpn-manager/nm-vpn-manager.h b/src/vpn-manager/nm-vpn-manager.h
index a899122c..41010323 100644
--- a/src/vpn-manager/nm-vpn-manager.h
+++ b/src/vpn-manager/nm-vpn-manager.h
@@ -15,7 +15,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Copyright (C) 2005 - 2008 Red Hat, Inc.
+ * Copyright (C) 2005 - 2011 Red Hat, Inc.
  * Copyright (C) 2006 - 2008 Novell, Inc.
  */
 
@@ -83,7 +83,10 @@ void nm_vpn_manager_add_active_connections (NMVPNManager *manager,
 
 GSList *nm_vpn_manager_get_active_connections (NMVPNManager *manager);
 
+NMVPNConnection *nm_vpn_manager_get_vpn_connection_for_active (NMVPNManager *manager,
+                                                               const char *active_path);
+
 NMConnection *nm_vpn_manager_get_connection_for_active (NMVPNManager *manager,
                                                         const char *active_path);
 
-#endif /* NM_VPN_VPN_MANAGER_H */
+#endif /* NM_VPN_MANAGER_H */