summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-05-27 12:27:59 +0200
committerThomas Haller <thaller@redhat.com>2016-05-27 12:27:59 +0200
commit5357b1874e6e0deb33f08f2c880552d377202850 (patch)
tree5a6746b2f405acd6a715e4c453ca2a06ab9bad82
parent0c80e38f640c3d838806b537864c1702583cd9e4 (diff)
downloadNetworkManager-5357b1874e6e0deb33f08f2c880552d377202850.tar.gz
vpn-connection: ensure ip_iface and ip_ifindex are set together
ip_iface and ip_ifindex come as a pair. They must be either set both, or not at all. Ensure that whenever setting one, the other is set too (or cleared).
-rw-r--r--src/vpn-manager/nm-vpn-connection.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index 410256027f..663bd1b8c4 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -195,14 +195,14 @@ __LOG_create_prefix (char *buf, NMVpnConnection *self)
"%s%s" /*con-uuid*/
"%s%s%s%s" /*con-id*/
",%d" /*ifindex*/
- "%s%s%s%s" /*iface*/
+ "%s%s%s" /*iface*/
"]",
_NMLOG_PREFIX_NAME,
self,
con ? "," : "--", con ? (nm_connection_get_uuid (con) ?: "??") : "",
con ? "," : "", NM_PRINT_FMT_QUOTED (id, "\"", id, "\"", con ? "??" : ""),
priv->ip_ifindex,
- priv->ip_iface ? ":" : "", NM_PRINT_FMT_QUOTED (priv->ip_iface, "(", priv->ip_iface, ")", "")
+ NM_PRINT_FMT_QUOTED (priv->ip_iface, ":(", priv->ip_iface, ")", "")
);
return buf;
@@ -912,7 +912,7 @@ print_vpn_config (NMVpnConnection *self)
nm_utils_inet6_ntop (priv->ip6_external_gw, NULL));
}
- _LOGI ("Data: Tunnel Device: %s", priv->ip_iface ? priv->ip_iface : "(none)");
+ _LOGI ("Data: Tunnel Device: %s%s%s", NM_PRINT_FMT_QUOTE_STRING (priv->ip_iface));
if (priv->ip4_config) {
_LOGI ("Data: IPv4 configuration:");
@@ -1221,6 +1221,8 @@ process_generic_config (NMVpnConnection *self, GVariant *dict)
}
g_clear_pointer (&priv->ip_iface, g_free);
+ priv->ip_ifindex = 0;
+
if (g_variant_lookup (dict, NM_VPN_PLUGIN_CONFIG_TUNDEV, "&s", &str)) {
/* Backwards compat with NM-openswan */
if (g_strcmp0 (str, "_none_") != 0)
@@ -1231,7 +1233,13 @@ process_generic_config (NMVpnConnection *self, GVariant *dict)
/* Grab the interface index for address/routing operations */
priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface);
if (priv->ip_ifindex <= 0) {
+ nm_platform_process_events (NM_PLATFORM_GET);
+ priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface);
+ }
+ if (priv->ip_ifindex <= 0) {
_LOGE ("failed to look up VPN interface index for \"%s\"", priv->ip_iface);
+ g_clear_pointer (&priv->ip_iface, g_free);
+ priv->ip_ifindex = 0;
nm_vpn_connection_config_maybe_complete (self, FALSE);
return FALSE;
}