From: Pasi Sjöholm <[email protected]>

Routes should not be tried to be set with nameserver
and gw being different family, as this will lead into
having link-local routes for hosts which are not on
the link (add_nameserver_route() will add link-local route
if adding host route fails).
---
 src/service.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/service.c b/src/service.c
index a3105fa..dadac50 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1227,14 +1227,18 @@ static void add_nameserver_route(int family, int index, 
char *nameserver,
 static void nameserver_add_routes(int index, char **nameservers,
                                        const char *gw)
 {
-       int i, family;
+       int i, ns_family, gw_family;
+
+       gw_family = connman_inet_check_ipaddress(gw);
+       if (gw_family < 0)
+               return;
 
        for (i = 0; nameservers[i]; i++) {
-               family = connman_inet_check_ipaddress(nameservers[i]);
-               if (family < 0)
+               ns_family = connman_inet_check_ipaddress(nameservers[i]);
+               if (ns_family < 0 || ns_family != gw_family)
                        continue;
 
-               add_nameserver_route(family, index, nameservers[i], gw);
+               add_nameserver_route(ns_family, index, nameservers[i], gw);
        }
 }
 
-- 
2.1.0

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

Reply via email to