This is needed if P-t-P link does not have a default route.

Fixes BMC#25027
---
 src/connection.c |   40 ++++++++++++++++++++++++++++++++--------
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index daaea42..9436c23 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -762,20 +762,44 @@ int __connman_connection_gateway_add(struct 
connman_service *service,
                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 != NULL) {
+               if (g_strcmp0(new_gateway->ipv6_gateway->gateway, "::") != 0) {
+                       connman_inet_add_ipv6_host_route(index,
                                        new_gateway->ipv6_gateway->gateway,
                                        NULL);
+               } else if (g_strcmp0(gateway, "::") == 0) {
+                       /* P-t-P link */
+                       char *dest;
+                       if (connman_inet_ipv6_get_dest_addr(index,
+                                                               &dest) == 0) {
+                               connman_inet_add_ipv6_host_route(index, dest,
+                                                               NULL);
+                               g_free(dest);
+                       }
+               }
+       }
 
        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 != NULL) {
+               if (g_strcmp0(new_gateway->ipv4_gateway->gateway,
+                               "0.0.0.0") != 0) {
+                       connman_inet_add_host_route(index,
                                        new_gateway->ipv4_gateway->gateway,
                                        NULL);
+               } else if (g_strcmp0(gateway, "0.0.0.0") == 0) {
+                       /*
+                        * 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 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);
+                       }
+               }
+       }
 
        if (type == CONNMAN_IPCONFIG_TYPE_IPV4 &&
                                new_gateway->ipv4_gateway != NULL) {
-- 
1.7.5.4

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to