From 3b145a33b748935b17a83c85e451406698e6cec3 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 29 Oct 2015 09:12:52 +0100 Subject: vpn-connections: allow the plugin to specify route preferred src Tunnelled VPNs can need that so that correct source address is used for tunnel routes. --- src/vpn-manager/nm-vpn-connection.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index cdda03452c..22d54dc9cf 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -1451,10 +1451,13 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict) if (g_variant_lookup (dict, NM_VPN_PLUGIN_IP4_CONFIG_ROUTES, "aau", &iter)) { while (g_variant_iter_next (iter, "@au", &v)) { - NMPlatformIP4Route route; + NMPlatformIP4Route route = { 0, }; - if (g_variant_n_children (v) == 4) { - memset (&route, 0, sizeof (route)); + switch (g_variant_n_children (v)) { + case 5: + g_variant_get_child (v, 4, "u", &route.pref_src); + /* fallthrough */ + case 4: g_variant_get_child (v, 0, "u", &route.network); g_variant_get_child (v, 1, "u", &route.plen); g_variant_get_child (v, 2, "u", &route.gateway); @@ -1469,6 +1472,8 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict) */ if (!(priv->ip4_external_gw && route.network == priv->ip4_external_gw && route.plen == 32)) nm_ip4_config_add_route (config, &route); + default: + _LOGW ("VPN connection: received invalid IPv4 route"); } g_variant_unref (v); } -- cgit v1.2.1