diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-04-03 14:04:45 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-04-05 15:37:35 +0300 |
commit | 631fa9778980a444811d2554b75a2a35dfcb0e28 (patch) | |
tree | 40c244ddb3f20a2001faf90ecede764619e0b065 | |
parent | 1e1a6525ad5241f384eadcaa3670dd9836571be5 (diff) | |
download | connman-631fa9778980a444811d2554b75a2a35dfcb0e28.tar.gz connman-631fa9778980a444811d2554b75a2a35dfcb0e28.tar.bz2 connman-631fa9778980a444811d2554b75a2a35dfcb0e28.zip |
connection: Remove wrong VPN route
Before this patch the system created following routes for VPN
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.10.9 0.0.0.0 UG 0 0 0 vpn0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
192.168.2.1 0.0.0.0 255.255.255.255 UH 0 0 0 vpn0
192.168.2.1 0.0.0.0 255.255.255.255 UH 0 0 0 wlan0
192.168.10.1 192.168.10.9 255.255.255.255 UGH 0 0 0 vpn0
192.168.10.9 0.0.0.0 255.255.255.255 UH 0 0 0 vpn0
Here the route to gateway in wlan0 192.168.2.1 via vpn0 is not
correct and it will prevent connections to 192.168.2.1
The correct routes should be:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.10.9 0.0.0.0 UG 0 0 0 vpn0
192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
192.168.2.1 0.0.0.0 255.255.255.255 UH 0 0 0 wlan0
192.168.10.1 192.168.10.9 255.255.255.255 UGH 0 0 0 vpn0
192.168.10.9 0.0.0.0 255.255.255.255 UH 0 0 0 vpn0
Fixes MBC#25035
-rw-r--r-- | src/connection.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/connection.c b/src/connection.c index a0183853..a2acc515 100644 --- a/src/connection.c +++ b/src/connection.c @@ -725,13 +725,21 @@ void __connman_connection_gateway_activate(struct connman_service *service, data->ipv6_gateway->active = TRUE; } -static void add_host_route(int family, int index, const char *gateway) +static void add_host_route(int family, int index, const char *gateway, + enum connman_service_type service_type) { switch (family) { case AF_INET: - if (g_strcmp0(gateway, "0.0.0.0") != 0) - connman_inet_add_host_route(index, gateway, NULL); - else { + if (g_strcmp0(gateway, "0.0.0.0") != 0) { + /* + * We must not set route to the phy dev gateway in + * VPN link. The packets to VPN link might be routed + * back to itself and not routed into phy link gateway. + */ + if (service_type != CONNMAN_SERVICE_TYPE_VPN) + connman_inet_add_host_route(index, gateway, + NULL); + } else { /* * Add host route to P-t-P link so that services can * be moved around and we can have some link to P-t-P @@ -747,9 +755,11 @@ static void add_host_route(int family, int index, const char *gateway) break; case AF_INET6: - if (g_strcmp0(gateway, "::") != 0) - connman_inet_add_ipv6_host_route(index, gateway, NULL); - else { + if (g_strcmp0(gateway, "::") != 0) { + if (service_type != CONNMAN_SERVICE_TYPE_VPN) + connman_inet_add_ipv6_host_route(index, + gateway, NULL); + } else { /* P-t-P link, add route to destination */ char *dest; if (connman_inet_ipv6_get_dest_addr(index, @@ -772,6 +782,8 @@ int __connman_connection_gateway_add(struct connman_service *service, struct gateway_data *new_gateway = NULL; enum connman_ipconfig_type type4 = CONNMAN_IPCONFIG_TYPE_UNKNOWN, type6 = CONNMAN_IPCONFIG_TYPE_UNKNOWN; + enum connman_service_type service_type = + connman_service_get_type(service); int index; index = __connman_service_get_index(service); @@ -801,7 +813,7 @@ int __connman_connection_gateway_add(struct connman_service *service, if (type == CONNMAN_IPCONFIG_TYPE_IPV4 && new_gateway->ipv4_gateway != NULL) { - add_host_route(AF_INET, index, gateway); + add_host_route(AF_INET, index, gateway, service_type); __connman_service_nameserver_add_routes(service, new_gateway->ipv4_gateway->gateway); type4 = CONNMAN_IPCONFIG_TYPE_IPV4; @@ -809,13 +821,13 @@ int __connman_connection_gateway_add(struct connman_service *service, if (type == CONNMAN_IPCONFIG_TYPE_IPV6 && new_gateway->ipv6_gateway != NULL) { - add_host_route(AF_INET6, index, gateway); + add_host_route(AF_INET6, index, gateway, service_type); __connman_service_nameserver_add_routes(service, new_gateway->ipv6_gateway->gateway); type6 = CONNMAN_IPCONFIG_TYPE_IPV6; } - if (connman_service_get_type(service) == CONNMAN_SERVICE_TYPE_VPN) { + if (service_type == CONNMAN_SERVICE_TYPE_VPN) { if (type == CONNMAN_IPCONFIG_TYPE_IPV4 && new_gateway->ipv4_gateway != NULL) set_vpn_routes(new_gateway->ipv4_gateway, |