<div dir="ltr">Hello Nicolas <br><div><div><div><div><div><div><div><br></div><div>I missed this point.....Thanks.<br>>
dhcp-option=option:netmask,255<wbr>.255.0.0 anyway.<br></div><div><br></div><div>But
 as you already mentioned, still I have to specify at least 2 dhcp-range
 with /1 to cover all subnets since dnsmasq doesn't consider netmask 0 
we intentionally specified.<br>your patch seems good to me. I hope your patch will be in upstream before long.<br></div><br><div>Yuki Nishiwaki</div></div></div></div></div></div></div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 March 2018 at 18:26, Nicolas Cavallari <span dir="ltr"><<a href="mailto:nicolas.cavallari@green-communications.fr" target="_blank">nicolas.cavallari@green-communications.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When using a DHCP relay, the netmask in dhcp-range is matched against<br>
giaddr (or the link selection suboption) to determine on which range the<br>
address should be allocated.<br>
<br>
However, in some cases, you want to ignore this mechanism, because your<br>
relay, clients and your DHCP server are not in the same subnet, the<br>
relay do not have addresses on their client interfaces and/or you have<br>
more complicated matching in place (e.g.  other relay agent information<br>
suboptions).<br>
<br>
The link selection suboption would be a good candidate but this requires<br>
a duplicate policy/configuration in every relay that matches what the<br>
DHCP server would select.<br>
<br>
Specifying 0.0.0.0 as a netmask is accepted by the parser but is<br>
rejected by a condition in rfc2131.c, that only checks if<br>
netmask.s_addr = 0, which can happen if the guessing failed, but can<br>
also happen if 0.0.0.0 was explicitly specified.<br>
<br>
This fixes the condition so that netmask.s_addr = 0 is acceptable<br>
if it was specified in the configuration.  i.e.  if the<br>
dhcp context (the considered dhcp range) has the CONTEXT_NETMASK<br>
flag.<br>
<br>
The netmask to be sent to the client can be set with<br>
dhcp-option=option:netmask,<wbr>255.255.0.0 anyway.<br>
---<br>
Yuki Nisiwaki's message reminded me of this patch that I use but forgot<br>
about.<br>
<br>
 src/rfc2131.c | 2 +-<br>
 1 file changed, 1 insertion(+), 1 deletion(-)<br>
<br>
diff --git a/src/rfc2131.c b/src/rfc2131.c<br>
index c08a8ab..6b2df35 100644<br>
--- a/src/rfc2131.c<br>
+++ b/src/rfc2131.c<br>
@@ -319,7 +319,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,<br>
<br>
            /* This section fills in context mainly when a client which is on a remote (relayed)<br>
               network renews a lease without using the relay, after dnsmasq has restarted. */<br>
-           if (netmask.s_addr != 0  &&<br>
+           if ((netmask.s_addr != 0 || context_tmp->flags & CONTEXT_NETMASK) &&<br>
                is_same_net(addr, context_tmp->start, netmask) &&<br>
                is_same_net(addr, context_tmp->end, netmask))<br>
              {<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.16.2<br>
<br>
<br>
______________________________<wbr>_________________<br>
Dnsmasq-discuss mailing list<br>
<a href="mailto:Dnsmasq-discuss@lists.thekelleys.org.uk">Dnsmasq-discuss@lists.<wbr>thekelleys.org.uk</a><br>
<a href="http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss" rel="noreferrer" target="_blank">http://lists.thekelleys.org.<wbr>uk/mailman/listinfo/dnsmasq-<wbr>discuss</a><br>
</font></span></blockquote></div><br></div>