[Dnsmasq-discuss] [PATCH] RADV: Send same RDNSS address as in DHCPv6

Pali Rohár pali.rohar at gmail.com
Thu Dec 24 13:39:43 GMT 2015


Before this patch when both RADV and DHCPv6 is running and DNS server
address was not configured then RADV were sending link-local address and
DHCPv6 global address.

This patch change behaviour of RADV and when both RADV and DHCPv6 is
running without configured DNS server then in RADV RDNSS will be same
global address as in DHCPv6 instead link-local address.
---
 man/dnsmasq.8 |    4 ++--
 src/radv.c    |   22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/man/dnsmasq.8 b/man/dnsmasq.8
index 6a121fe..bb588d3 100644
--- a/man/dnsmasq.8
+++ b/man/dnsmasq.8
@@ -1695,8 +1695,8 @@ the machine running dnsmasq. By default, the "managed address" bits are set, and
 the "use SLAAC" bit is reset. This can be changed for individual
 subnets with the mode keywords described in
 .B --dhcp-range.
-RFC6106 DNS parameters are included in the advertisements. By default,
-the relevant link-local address of the machine running dnsmasq is sent
+RFC6106 DNS parameters are included in the advertisements. By default
+the relevant DHCPv6 address (or link-local when using SLAAC) of the machine running dnsmasq is sent
 as recursive DNS server. If provided, the DHCPv6 options dns-server and
 domain-search are used for the DNS server (RDNSS) and the domain serach list (DNSSL).
 .TP
diff --git a/src/radv.c b/src/radv.c
index 39f1e92..15e116c 100644
--- a/src/radv.c
+++ b/src/radv.c
@@ -482,6 +482,28 @@ static void send_ra_alias(time_t now, int iface, char *iface_name, struct in6_ad
 	}
     }
 	
+  if (daemon->port == NAMESERVER_PORT && !done_dns && parm.link_pref_time != 0 && parm.other)
+    for (context = daemon->dhcp6; context; context = context->next)
+      if (context->if_index == iface && !IN6_IS_ADDR_UNSPECIFIED(&context->local6))
+	{
+	  /* squash duplicates */
+	  struct dhcp_context *c;
+	  for (c = context->current; c; c = c->current)
+	    if ((c->flags & CONTEXT_USED) &&
+		IN6_ARE_ADDR_EQUAL(&context->local6, &c->local6))
+	      break;
+
+	  if (!c)
+	    {
+	      done_dns = 1;
+	      put_opt6_char(ICMP6_OPT_RDNSS);
+	      put_opt6_char(3);
+	      put_opt6_short(0);
+	      put_opt6_long(min_pref_time);
+	      put_opt6(&context->local6, IN6ADDRSZ);
+	    }
+	}
+
   if (daemon->port == NAMESERVER_PORT && !done_dns && parm.link_pref_time != 0)
     {
       /* default == us, as long as we are supplying DNS service. */
-- 
1.7.9.5




More information about the Dnsmasq-discuss mailing list