diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-03-27 10:59:58 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-04-05 14:30:31 +0300 |
commit | 677ca4175b710f572a9bc2fb11468521b398c572 (patch) | |
tree | 248b6a3ec576d0e939d0d7897590adee44042483 /src/connection.c | |
parent | 56e8d7b861c9e281ba1d4c6ea693a6651e43a97e (diff) | |
download | connman-677ca4175b710f572a9bc2fb11468521b398c572.tar.gz connman-677ca4175b710f572a9bc2fb11468521b398c572.tar.bz2 connman-677ca4175b710f572a9bc2fb11468521b398c572.zip |
connection: Set additional point-to-point route
This is useful if P-t-P link does not have a default route.
Fixes BMC#25027
Diffstat (limited to 'src/connection.c')
-rw-r--r-- | src/connection.c | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/src/connection.c b/src/connection.c index 11e42c9b..a0183853 100644 --- a/src/connection.c +++ b/src/connection.c @@ -725,6 +725,44 @@ 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) +{ + switch (family) { + case AF_INET: + if (g_strcmp0(gateway, "0.0.0.0") != 0) + 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 + * network (although those P-t-P links have limited + * usage if default route is not directed to them) + */ + char *dest; + if (connman_inet_get_dest_addr(index, &dest) == 0) { + connman_inet_add_host_route(index, dest, NULL); + g_free(dest); + } + } + break; + + case AF_INET6: + if (g_strcmp0(gateway, "::") != 0) + 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, + &dest) == 0) { + connman_inet_add_ipv6_host_route(index, dest, + NULL); + g_free(dest); + } + } + break; + } +} + int __connman_connection_gateway_add(struct connman_service *service, const char *gateway, enum connman_ipconfig_type type, @@ -761,24 +799,9 @@ int __connman_connection_gateway_add(struct connman_service *service, DBG("active %p index %d new %p", active_gateway, active_gateway ? active_gateway->index : -1, new_gateway); - if (type == CONNMAN_IPCONFIG_TYPE_IPV6 && - new_gateway->ipv6_gateway != NULL && - g_strcmp0(new_gateway->ipv6_gateway->gateway, - "::") != 0) - connman_inet_add_ipv6_host_route(index, - new_gateway->ipv6_gateway->gateway, - NULL); - - if (type == CONNMAN_IPCONFIG_TYPE_IPV4 && - new_gateway->ipv4_gateway != NULL && - g_strcmp0(new_gateway->ipv4_gateway->gateway, - "0.0.0.0") != 0) - connman_inet_add_host_route(index, - new_gateway->ipv4_gateway->gateway, - NULL); - if (type == CONNMAN_IPCONFIG_TYPE_IPV4 && new_gateway->ipv4_gateway != NULL) { + add_host_route(AF_INET, index, gateway); __connman_service_nameserver_add_routes(service, new_gateway->ipv4_gateway->gateway); type4 = CONNMAN_IPCONFIG_TYPE_IPV4; @@ -786,6 +809,7 @@ 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); __connman_service_nameserver_add_routes(service, new_gateway->ipv6_gateway->gateway); type6 = CONNMAN_IPCONFIG_TYPE_IPV6; |