mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-11 00:10:33 +01:00
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).
This commit is contained in:
parent
0c80e38f64
commit
5357b1874e
1 changed files with 11 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
@ -1230,8 +1232,14 @@ process_generic_config (NMVpnConnection *self, GVariant *dict)
|
|||
if (priv->ip_iface) {
|
||||
/* 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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue