<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">We recently encountered a scenario where 2 different client machines sent discover packets at the exact same time and ended up getting offer responses for the same IP address.   I confirmed that the algorithm in dhcp.c::address_allocate()
 would use the same start value for both of these MAC addresses so it would appear as though we got unlucky and had a collision on the MAC address for these two specific clients.  
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This is the config entry:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-indent:.5in"><span style="font-size:9.0pt;font-family:"Courier New"">dhcp-range=set:xyz,192.168.29.2,192.168.29.254,255.255.255.0,1d<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">These are the logs (first 4 bytes of MAC addresses obfuscated to 02:11:22:33 from their actual values):<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:55:57.000 localhost dnsmasq-dhcp[12225]: info DHCPDISCOVER(eth0) 02:11:22:33:1c:83<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:55:57.000 localhost dnsmasq-dhcp[12225]: info DHCPOFFER(eth0) 192.168.29.40 02:11:22:33:1c:83<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:55:57.000 localhost dnsmasq-dhcp[12225]: info DHCPDISCOVER(eth0) 02:11:22:33:1b:cc<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:55:57.000 localhost dnsmasq-dhcp[12225]: info DHCPOFFER(eth0) 192.168.29.40 02:11:22:33:1b:cc<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:55:57.000 localhost dnsmasq-dhcp[12225]: info DHCPDISCOVER(eth0) 02:11:22:33:1c:83<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:55:57.000 localhost dnsmasq-dhcp[12225]: info DHCPOFFER(eth0) 192.168.29.40 02:11:22:33:1c:83<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:55:58.000 localhost dnsmasq-dhcp[12225]: info DHCPREQUEST(eth0) 192.168.29.40 02:11:22:33:1b:cc<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:55:58.000 localhost dnsmasq-dhcp[12225]: info DHCPACK(eth0) 192.168.29.40 02:11:22:33:1b:cc<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:55:59.000 localhost dnsmasq-dhcp[12225]: info DHCPREQUEST(eth0) 192.168.29.40 02:11:22:33:1c:83<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:55:59.000 localhost dnsmasq-dhcp[12225]: info DHCPNAK(eth0) 192.168.29.40 02:11:22:33:1c:83 address in use<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:56:03.000 localhost dnsmasq-dhcp[12225]: info DHCPREQUEST(eth0) 192.168.29.40 02:11:22:33:1c:83<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:56:03.000 localhost dnsmasq-dhcp[12225]: info DHCPNAK(eth0) 192.168.29.40 02:11:22:33:1c:83 address in use<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:56:07.000 localhost dnsmasq-dhcp[12225]: info DHCPDISCOVER(eth0) 02:11:22:33:1c:83<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:56:07.000 localhost dnsmasq-dhcp[12225]: info DHCPOFFER(eth0) 192.168.29.41 02:11:22:33:1c:83<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span lang="FR-CA" style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:56:11.000 localhost dnsmasq-dhcp[12225]: info DHCPREQUEST(eth0) 192.168.29.41 02:11:22:33:1c:83<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:9.0pt;font-family:"Courier New"">daemon.log:2016-02-16T13:56:11.000 localhost dnsmasq-dhcp[12225]: info DHCPACK(eth0) 192.168.29.41 02:11:22:33:1c:83<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">From a DHCP point of view things seem to have resolved themselves automatically at both the client and server.  There were ensuing tftp issues on the client which got the NAK and subsequently got a second IP address but I don’t believe
 this to be related to dnsmasq.  <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">My question is about why the duplicate IP address was even offered to the second client.  Looking at the dhcp.c::address_allocate() code it seems that this scenario is avoided only if OPT_CONSEC_ADDR is set (which we do not set).   Unless
 I am missing something it seems that any time the address matches and (r->hash != j) the loop should be terminated and a new address should be allocated.   Can you comment on whether this is intentional because of RFC requirements or whether this should be
 changed?  <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">                    if (r->addr.s_addr == addr.s_addr)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">                     {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">                       /* consec-ip mode: we offered this address for another client<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">                          (different hash) recently, don't offer it to this one. */<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">                       if (option_bool(OPT_CONSEC_ADDR) && r->hash != j)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">                         break;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">                      
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">                       return 1;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New"">                     }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Allain<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#333333">Allain Legacy</span></b><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#333333">, Software Developer</span><br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#333333">direct 613.270.2279  fax
</span><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#333333">613.492.7870 skype allain.legacy</span><br>
 <br>
<a href="http://www.windriver.com/" title=""Innovators Start Here" "><span style="font-family:"Arial","sans-serif";color:#CC0000;text-decoration:none"><img border="0" width="160" height="92" id="Picture_x0020_1" src="cid:image001.png@01D16BB1.1450FB50" alt="WIND"></span></a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>