summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-04-27 20:29:13 +0200
committerThomas Haller <thaller@redhat.com>2020-04-27 22:04:20 +0200
commit61da7b683c55c2202b91f353933ca9e0b1b7de5c (patch)
tree54f26675ca7653216a84f3fe27058267d68e3549
parente63ed9fd8d429f474d9f2d54644f9b43e1fc40d2 (diff)
downloadNetworkManager-th/vpn-ipv6-addr-fix-assert.tar.gz
vpn: cleanup loop in nm_vpn_connection_ip6_config_get()th/vpn-ipv6-addr-fix-assert
I find it simpler to follow the pattern of checking conditions and "erroring out", by going to the next entry. The entire loop already behaves like that.
-rw-r--r--src/vpn/nm-vpn-connection.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/src/vpn/nm-vpn-connection.c b/src/vpn/nm-vpn-connection.c
index 6be8d9bac6..6d995dc489 100644
--- a/src/vpn/nm-vpn-connection.c
+++ b/src/vpn/nm-vpn-connection.c
@@ -1595,13 +1595,18 @@ nm_vpn_connection_ip4_config_get (NMVpnConnection *self, GVariant *dict)
route.plen = plen;
route.network = nm_utils_ip4_address_clear_host_address (route.network, plen);
- /* Ignore host routes to the VPN gateway since NM adds one itself
- * below. Since NM knows more about the routing situation than
- * the VPN server, we want to use the NM created route instead of
- * whatever the server provides.
- */
- if (!(priv->ip4_external_gw && route.network == priv->ip4_external_gw && route.plen == 32))
- nm_ip4_config_add_route (config, &route, NULL);
+ if ( priv->ip4_external_gw
+ && route.network == priv->ip4_external_gw
+ && route.plen == 32) {
+ /* Ignore host routes to the VPN gateway since NM adds one itself
+ * below. Since NM knows more about the routing situation than
+ * the VPN server, we want to use the NM created route instead of
+ * whatever the server provides.
+ */
+ break;
+ }
+
+ nm_ip4_config_add_route (config, &route, NULL);
break;
default:
break;
@@ -1792,13 +1797,18 @@ nm_vpn_connection_ip6_config_get (NMVpnConnection *self, GVariant *dict)
nm_utils_ip6_address_clear_host_address (&route.network, &route.network, route.plen);
- /* Ignore host routes to the VPN gateway since NM adds one itself.
- * Since NM knows more about the routing situation than the VPN
- * server, we want to use the NM created route instead of whatever
- * the server provides.
- */
- if (!(priv->ip6_external_gw && IN6_ARE_ADDR_EQUAL (&route.network, priv->ip6_external_gw) && route.plen == 128))
- nm_ip6_config_add_route (config, &route, NULL);
+ if ( priv->ip6_external_gw
+ && IN6_ARE_ADDR_EQUAL (&route.network, priv->ip6_external_gw)
+ && route.plen == 128) {
+ /* Ignore host routes to the VPN gateway since NM adds one itself.
+ * Since NM knows more about the routing situation than the VPN
+ * server, we want to use the NM created route instead of whatever
+ * the server provides.
+ */
+ goto next;
+ }
+
+ nm_ip6_config_add_route (config, &route, NULL);
next:
g_variant_unref (dest);