[Dnsmasq-discuss] [PATCH] Nack requests for unknown leases.

Alin Nastac alin.nastac at gmail.com
Thu Apr 20 10:34:56 BST 2017


Hosts that migrate from one network to another could request their
old IP address which might be already in use by another statically
configured host. Currently non-authoritative dnsmasq servers will
ignore such requests, but ISC DHCP client will send discovery packets
next carrying the same requested IP address and dnsmasq will end up
allocating a new lease for it without checking first if is already
used by another host.
---
 src/rfc2131.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/rfc2131.c b/src/rfc2131.c
index 6a8f0db..9987745 100644
--- a/src/rfc2131.c
+++ b/src/rfc2131.c
@@ -1141,10 +1141,12 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
 	  else
 	    {
 	      /* INIT-REBOOT */
-	      if (!lease && !option_bool(OPT_AUTHORITATIVE))
-		return 0;
-	      
-	      if (lease && lease->addr.s_addr != mess->yiaddr.s_addr)
+	      if (!lease)
+		{
+		  if (!option_bool(OPT_AUTHORITATIVE))
+		    message = _("lease not found");
+		}
+	      else if (lease->addr.s_addr != mess->yiaddr.s_addr)
 		message = _("wrong address");
 	    }
 	}
-- 
2.7.4




More information about the Dnsmasq-discuss mailing list