summaryrefslogtreecommitdiff
path: root/src/vpn-manager/nm-vpn-connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpn-manager/nm-vpn-connection.c')
-rw-r--r--src/vpn-manager/nm-vpn-connection.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index dfe213b021..b17e249257 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -460,6 +460,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32
NMIP4Config *parent_config;
guint32 parent_gw;
NMPlatformIP4Route route;
+ guint32 route_metric;
g_return_if_fail (NM_IS_IP4_CONFIG (config));
g_return_if_fail (NM_IS_DEVICE (parent_device));
@@ -475,6 +476,8 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32
if (!parent_gw)
return;
+ route_metric = nm_device_get_ip4_route_metric (parent_device);
+
memset (&route, 0, sizeof (route));
route.network = vpn_gw;
route.plen = 32;
@@ -488,7 +491,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32
route.gateway = 0;
route.source = NM_IP_CONFIG_SOURCE_VPN;
- route.metric = nm_device_get_priority (parent_device);
+ route.metric = route_metric;
nm_ip4_config_add_route (config, &route);
/* Ensure there's a route to the parent device's gateway through the
@@ -500,7 +503,7 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32
route.network = parent_gw;
route.plen = 32;
route.source = NM_IP_CONFIG_SOURCE_VPN;
- route.metric = nm_device_get_priority (parent_device);
+ route.metric = route_metric;
nm_ip4_config_add_route (config, &route);
}
@@ -513,6 +516,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
NMIP6Config *parent_config;
const struct in6_addr *parent_gw;
NMPlatformIP6Route route;
+ guint32 route_metric;
g_return_if_fail (NM_IS_IP6_CONFIG (config));
g_return_if_fail (NM_IS_DEVICE (parent_device));
@@ -524,6 +528,8 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
if (!parent_gw)
return;
+ route_metric = nm_device_get_ip6_route_metric (parent_device);
+
memset (&route, 0, sizeof (route));
route.network = *vpn_gw;
route.plen = 128;
@@ -537,7 +543,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
route.gateway = in6addr_any;
route.source = NM_IP_CONFIG_SOURCE_VPN;
- route.metric = nm_device_get_priority (parent_device);
+ route.metric = route_metric;
nm_ip6_config_add_route (config, &route);
/* Ensure there's a route to the parent device's gateway through the
@@ -549,7 +555,7 @@ add_ip6_vpn_gateway_route (NMIP6Config *config,
route.network = *parent_gw;
route.plen = 128;
route.source = NM_IP_CONFIG_SOURCE_VPN;
- route.metric = nm_device_get_priority (parent_device);
+ route.metric = route_metric;
nm_ip6_config_add_route (config, &route);
}
@@ -1048,7 +1054,21 @@ nm_vpn_connection_config_get (DBusGProxy *proxy,
}
static guint32
-vpn_routing_metric (NMVpnConnection *connection)
+get_vpn_ip4_route_metric (NMVpnConnection *connection)
+{
+ NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
+
+ if (priv->ip_ifindex)
+ return NM_PLATFORM_ROUTE_METRIC_DEFAULT;
+ else {
+ NMDevice *parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (connection));
+
+ return nm_device_get_ip4_route_metric (parent_dev);
+ }
+}
+
+static guint32
+get_vpn_ip6_route_metric (NMVpnConnection *connection)
{
NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection);
@@ -1057,7 +1077,7 @@ vpn_routing_metric (NMVpnConnection *connection)
else {
NMDevice *parent_dev = nm_active_connection_get_device (NM_ACTIVE_CONNECTION (connection));
- return nm_device_get_priority (parent_dev);
+ return nm_device_get_ip6_route_metric (parent_dev);
}
}
@@ -1072,6 +1092,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
NMIP4Config *config;
GValue *val;
int i;
+ guint32 route_metric;
if (priv->vpn_state == STATE_CONNECT)
_set_vpn_state (connection, STATE_IP_CONFIG_GET, NM_VPN_CONNECTION_STATE_REASON_NONE, FALSE);
@@ -1169,6 +1190,8 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
nm_ip4_config_add_domain (config, *domain);
}
+ route_metric = get_vpn_ip4_route_metric (connection);
+
val = (GValue *) g_hash_table_lookup (config_hash, NM_VPN_PLUGIN_IP4_CONFIG_ROUTES);
if (val) {
GSList *routes;
@@ -1184,7 +1207,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
route.plen = nm_ip4_route_get_prefix (item);
route.gateway = nm_ip4_route_get_next_hop (item);
route.source = NM_IP_CONFIG_SOURCE_VPN;
- route.metric = vpn_routing_metric (connection);
+ route.metric = route_metric;
/* Ignore host routes to the VPN gateway since NM adds one itself
* below. Since NM knows more about the routing situation than
@@ -1208,7 +1231,7 @@ nm_vpn_connection_ip4_config_get (DBusGProxy *proxy,
/* Merge in user overrides from the NMConnection's IPv4 setting */
nm_ip4_config_merge_setting (config,
nm_connection_get_setting_ip4_config (priv->connection),
- vpn_routing_metric (connection));
+ route_metric);
priv->ip4_config = config;
nm_ip4_config_export (config);
@@ -1227,6 +1250,7 @@ nm_vpn_connection_ip6_config_get (DBusGProxy *proxy,
NMIP6Config *config;
GValue *val;
int i;
+ guint32 route_metric;
nm_log_info (LOGD_VPN, "VPN connection '%s' (IP6 Config Get) reply received.",
nm_connection_get_id (priv->connection));
@@ -1315,6 +1339,8 @@ nm_vpn_connection_ip6_config_get (DBusGProxy *proxy,
nm_ip6_config_add_domain (config, *domain);
}
+ route_metric = get_vpn_ip6_route_metric (connection);
+
val = (GValue *) g_hash_table_lookup (config_hash, NM_VPN_PLUGIN_IP6_CONFIG_ROUTES);
if (val) {
GSList *routes;
@@ -1330,7 +1356,7 @@ nm_vpn_connection_ip6_config_get (DBusGProxy *proxy,
route.plen = nm_ip6_route_get_prefix (item);
route.gateway = *nm_ip6_route_get_next_hop (item);
route.source = NM_IP_CONFIG_SOURCE_VPN;
- route.metric = vpn_routing_metric (connection);
+ route.metric = route_metric;
/* Ignore host routes to the VPN gateway since NM adds one itself
* below. Since NM knows more about the routing situation than
@@ -1354,7 +1380,7 @@ nm_vpn_connection_ip6_config_get (DBusGProxy *proxy,
/* Merge in user overrides from the NMConnection's IPv6 setting */
nm_ip6_config_merge_setting (config,
nm_connection_get_setting_ip6_config (priv->connection),
- vpn_routing_metric (connection));
+ route_metric);
priv->ip6_config = config;
nm_ip6_config_export (config);