+ if (do_ipv4 == TRUE && data->ipv4_gateway != NULL)
+ set_default4 = data->ipv4_gateway->vpn;
+
+ if (do_ipv6 == TRUE && data->ipv6_gateway != NULL)
+ set_default6 = data->ipv6_gateway->vpn;
+
+ DBG("ipv4 gateway %s ipv6 gateway %s vpn %d/%d",
+ data->ipv4_gateway ? data->ipv4_gateway->gateway : "<null>",
+ data->ipv6_gateway ? data->ipv6_gateway->gateway : "<null>",
+ set_default4, set_default6);
+
+ if (do_ipv4 == TRUE && data->ipv4_gateway != NULL &&
+ data->ipv4_gateway->vpn == TRUE && data->index >= 0)
+ connman_inet_del_host_route(data->index,
+ data->ipv4_gateway->gateway);
+
+ if (do_ipv6 == TRUE && data->ipv6_gateway != NULL &&
+ data->ipv6_gateway->vpn == TRUE && data->index >= 0)
+ connman_inet_del_ipv6_host_route(data->index,
+ data->ipv6_gateway->gateway);
+
+ err = disable_gateway(data, type);
+
+ /*
+ * We remove the service from the hash only if all the gateway
+ * settings are to be removed.
+ */
+ if (do_ipv4 == do_ipv6 ||
+ (data->ipv4_gateway != NULL && data->ipv6_gateway == NULL
+ && do_ipv4 == TRUE) ||
+ (data->ipv6_gateway != NULL && data->ipv4_gateway == NULL
+ && do_ipv6 == TRUE)
+ ) {
+ connman_service_unref(service);
+ g_hash_table_remove(gateway_hash, service);
+ } else
+ DBG("Not yet removing gw ipv4 %p/%d ipv6 %p/%d",
+ data->ipv4_gateway, do_ipv4,
+ data->ipv6_gateway, do_ipv6);
+
+ /* with vpn this will be called after the network was deleted,
+ * we need to call set_default here because we will not recieve any
+ * gateway delete notification.
+ * We hit the same issue if remove_gateway() fails.
+ */
+ if (set_default4 || set_default6 || err < 0) {
+ data = find_default_gateway();
+ if (data != NULL)
+ set_default_gateway(data, type);
+ }
+}