From: Ulrich Weber Date: Wed, 23 Apr 2014 12:33:04 +0000 (+0000) Subject: netifd: fix IPv6 Link-local DNS server X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=235a02424c3ab1b59308895c4f00395dacf2557c;p=oweals%2Fnetifd.git 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 --- 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);