From 235a02424c3ab1b59308895c4f00395dacf2557c Mon Sep 17 00:00:00 2001 From: Ulrich Weber Date: Wed, 23 Apr 2014 12:33:04 +0000 Subject: [PATCH] netifd: fix IPv6 Link-local DNS server interface name must be added to Link-local IPv6 DNS servers, otherwise they are unusable. Signed-off-by: Ulrich Weber --- interface-ip.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/interface-ip.c b/interface-ip.c index d5a3832..6f42015 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -18,6 +18,7 @@ #include #include +#include #include "netifd.h" #include "device.h" @@ -1027,7 +1028,7 @@ interface_add_dns_search_list(struct interface_ip_settings *ip, struct blob_attr } static void -write_resolv_conf_entries(FILE *f, struct interface_ip_settings *ip) +write_resolv_conf_entries(FILE *f, struct interface_ip_settings *ip, const char *dev) { struct dns_server *s; struct dns_search_domain *d; @@ -1039,7 +1040,10 @@ write_resolv_conf_entries(FILE *f, struct interface_ip_settings *ip) if (!str) continue; - fprintf(f, "nameserver %s\n", str); + if (s->af == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&s->addr)) + fprintf(f, "nameserver %s%%%s\n", str, dev); + else + fprintf(f, "nameserver %s\n", str); } vlist_simple_for_each_element(&ip->dns_search, d, node) { @@ -1074,9 +1078,9 @@ interface_write_resolv_conf(void) continue; fprintf(f, "# Interface %s\n", iface->name); - write_resolv_conf_entries(f, &iface->config_ip); + write_resolv_conf_entries(f, &iface->config_ip, iface->ifname); if (!iface->proto_ip.no_dns) - write_resolv_conf_entries(f, &iface->proto_ip); + write_resolv_conf_entries(f, &iface->proto_ip, iface->ifname); } fflush(f); rewind(f); -- 2.25.1