From 1465c1d3260712fbe2fd0c78c7a1fcf0fb8ce753 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 10 Jul 2015 18:56:41 +0200 Subject: [PATCH] vpn: fix overwriting gateway of parent device for non-tunnel based VPNs For non-tunnel based VPNs (openswan, libreswan), we must clear the gateway setting. The default route is managed by NMDefaultRouteManager, and we must not overwrite the gateway of the parent device. This fixes a bug if the VPN connection specifies a gateway, it would have overwritten the gateway of the underlying device. --- src/vpn-manager/nm-vpn-connection.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index f3ff541c9c..47879f2a6f 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -891,10 +891,17 @@ apply_parent_device_config (NMVpnConnection *connection) * be done on the parent interface instead. */ - if (vpn4_parent_config) + /* Also clear the gateway. We don't configure the gateway as part of the + * vpn-config. Instead we tell NMDefaultRouteManager directly about the + * default route. */ + if (vpn4_parent_config) { nm_ip4_config_merge (vpn4_parent_config, priv->ip4_config); - if (vpn6_parent_config) + nm_ip4_config_set_gateway (vpn4_parent_config, 0); + } + if (vpn6_parent_config) { nm_ip6_config_merge (vpn6_parent_config, priv->ip6_config); + nm_ip6_config_set_gateway (vpn6_parent_config, NULL); + } } if (vpn4_parent_config) {