Change default lease time for DHCPv6 to one day.

Also remove floor on valid and preffered times in RA when
no time is specified.
diff --git a/CHANGELOG b/CHANGELOG
index b76c75e..4b4e5b3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,14 @@
 	Fix crash under heavy TCP connection load introdcued in 2.81.
 	Thanks to Frank for good work chasing this down.
 
+	Change default lease time for DHCPv6 to one day.
+
+	Alter calculation of preffered and valid times in router
+	advertisements, so that these do not have a floor applied
+	of the lease time in the dhcp-range if this is not explicitly
+	specified and is merely the default.
+	Thanks to Martin-Éric Racine for suggestions on this.
+
 	
 version 2.81
 	Improve cache behaviour for TCP connections. For ease of
diff --git a/man/dnsmasq.8 b/man/dnsmasq.8
index e004cfd..7b0e106 100644
--- a/man/dnsmasq.8
+++ b/man/dnsmasq.8
@@ -861,7 +861,7 @@
 options. If the lease time is given, then leases
 will be given for that length of time. The lease time is in seconds,
 or minutes (eg 45m) or hours (eg 1h) or "infinite". If not given,
-the default lease time is one hour. The
+the default lease time is one hour for IPv4 and one day for IPv6. The
 minimum lease time is two minutes. For IPv6 ranges, the lease time
 maybe "deprecated"; this sets the preferred lifetime sent in a DHCP
 lease or router advertisement to zero, which causes clients to use
diff --git a/src/config.h b/src/config.h
index f3a9fe7..7187ffa 100644
--- a/src/config.h
+++ b/src/config.h
@@ -43,7 +43,8 @@
 #define DNSSEC_MIN_TTL 60 /* DNSKEY and DS records in cache last at least this long */
 #define HOSTSFILE "/etc/hosts"
 #define ETHERSFILE "/etc/ethers"
-#define DEFLEASE 3600 /* default lease time, 1 hour */
+#define DEFLEASE 3600 /* default DHCPv4 lease time, one hour */
+#define DEFLEASE6 (3600*24) /* default lease time for DHCPv6. One day. */
 #define CHUSER "nobody"
 #define CHGRP "dip"
 #define TFTP_MAX_CONNECTIONS 50 /* max simultaneous connections */
diff --git a/src/dnsmasq.h b/src/dnsmasq.h
index 18c381e..4220798 100644
--- a/src/dnsmasq.h
+++ b/src/dnsmasq.h
@@ -942,6 +942,7 @@
 #define CONTEXT_OLD            (1u<<16)
 #define CONTEXT_V6             (1u<<17)
 #define CONTEXT_RA_OFF_LINK    (1u<<18)
+#define CONTEXT_SETLEASE       (1u<<19)
 
 struct ping_result {
   struct in_addr addr;
diff --git a/src/option.c b/src/option.c
index fed17a9..dbe5f90 100644
--- a/src/option.c
+++ b/src/option.c
@@ -2991,7 +2991,6 @@
 	struct dhcp_context *new = opt_malloc(sizeof(struct dhcp_context));
 	
 	memset (new, 0, sizeof(*new));
-	new->lease_time = DEFLEASE;
 	
 	while(1)
 	  {
@@ -3041,6 +3040,7 @@
 	if (inet_pton(AF_INET, a[0], &new->start))
 	  {
 	    new->next = daemon->dhcp;
+	    new->lease_time = DEFLEASE;
 	    daemon->dhcp = new;
 	    new->end = new->start;
 	    if (strcmp(a[1], "static") == 0)
@@ -3088,6 +3088,7 @@
 	    new->flags |= CONTEXT_V6; 
 	    new->prefix = 64; /* default */
 	    new->end6 = new->start6;
+	    new->lease_time = DEFLEASE6;
 	    new->next = daemon->dhcp6;
 	    daemon->dhcp6 = new;
 
@@ -3187,7 +3188,10 @@
 	      }
 	    
 	    if (strcmp(a[leasepos], "infinite") == 0)
-	      new->lease_time = 0xffffffff;
+	      {
+		new->lease_time = 0xffffffff;
+		new->flags |= CONTEXT_SETLEASE;
+	      }
 	    else if (strcmp(a[leasepos], "deprecated") == 0)
 	      new->flags |= CONTEXT_DEPRECATE;
 	    else
@@ -3226,6 +3230,7 @@
 		      ret_err_free(_("bad dhcp-range"), new);
 		    
 		    new->lease_time = atoi(a[leasepos]) * fac;
+		    new->flags |= CONTEXT_SETLEASE;
 		    /* Leases of a minute or less confuse
 		       some clients, notably Apple's */
 		    if (new->lease_time < 120)
@@ -3233,6 +3238,7 @@
 		  }
 	      }
 	  }
+
 	break;
       }
 
diff --git a/src/radv.c b/src/radv.c
index 7ec8cd0..41df852 100644
--- a/src/radv.c
+++ b/src/radv.c
@@ -626,8 +626,11 @@
 		    real_prefix = context->prefix;
 		  }
 
-		/* find floor time, don't reduce below 3 * RA interval. */
-		if (time > context->lease_time)
+		/* find floor time, don't reduce below 3 * RA interval.
+		   If the lease time has been left as default, don't
+		   use that as a floor. */
+		if ((context->flags & CONTEXT_SETLEASE) &&
+		    time > context->lease_time)
 		  {
 		    time = context->lease_time;
 		    if (time < ((unsigned int)(3 * param->adv_interval)))