[Dnsmasq-discuss] [PATCH] Reimplement rev-server to support arbitrary IPv4 prefix lengths

Dominik dl6er at dl6er.de
Wed Apr 15 19:28:07 BST 2020


Hey (again) Simon and the other list members,

I received some private user's requests (mostly Pi-hole users,
apparently) which do seem to ultimately need arbitrary prefix-lengths
also for IPv6 addresses. As the majority of code now already existed for
IPv4, I changed my mind and added arbitrary prefix-lengths now as well
for IPv6 (patch 4). I was going back and forth about the choice of a
more simple or a more compact algorithm. As this is code is absolutely
not performance-critical, I chose the former as this eases accessibility
of the code and, thereby, possible maintenance in the future.

The result is a new set of three patches meant to come on top of my
patches from yesterday (this also makes patch 3 mandatory). I also found
it useful to make the prefix-length an optional field while I was at it
(patch 5).

> ./dnsmasq --rev-server=fe80::3aea:a711:fea1:2101,10.0.0.1
> dnsmasq[9870]: rev-server fe80::3aea:a711:fea1:2101[/128]:
> address-to-name queries for fe80::3aea:a711:fea1:2101 are sent to 10.0.0.1
The last patch improves the output of the explanations provided for
rev-server in case no server is specified (patch 6).

Best regards,
Dominik

On 14.04.20 20:26, Dominik wrote:
> Hey Simon,
>
> I recently noticed that the "--rev-server" option is limited to 8, 16,
> 24, and 32 bit prefixes for IPv4 addresses. Since I needed support for
> 22 bit subnets in the network I'm currently setting up, I decided to
> extend dnsmasq to support arbitrary IPv4 prefix-lengths. This mail has
> three patches attached that contain my changes. I hope this is helpful
> and can be merged into upstream dnsmasq.
>
> Patch 1 implements support for arbitrary IPv4 prefixes by largely
> rewriting option.c:add_rev4() and option.c:add_rev6()
>
> Patch 2 adds error checking for IPv6 prefix-lengths as the current
> algorithm only makes sense in 4 bit steps. As 4 bit steps in 128 bit
> wide addresses seems sufficient to me, I didn't change the nice and
> short algorithm used here.
>
> Patch 3 adds logging for the inner details of what rev-server is doing.
> It is an entirely optional patch. However, I would still recommend
> adding it as it facilitates understanding of what the rev-server option
> actually does (and if it does what the user is thinking it should be doing).
>
> Exemplary log outputs:
>
>> ./dnsmasq --rev-server=10.0.3.10/22,10.0.0.1
>> dnsmasq[29637]: rev-server 10.0.3.10/22: address-to-name queries for 10.0.0.0 to 10.0.3.255 are sent to 10.0.0.1
>
>> ./dnsmasq --rev-server=10.0.3.10/17,10.0.0.1#5353
>> dnsmasq[29662]: rev-server 10.0.3.10/17: address-to-name queries for 10.0.0.0 to 10.0.127.255 are sent to 10.0.0.1#5353
>
>> ./dnsmasq --rev-server=fe80::3aea:a711:fea1:2101/64,10.0.0.1
>> dnsmasq[29667]: rev-server fe80::3aea:a711:fea1:2101/64: address-to-name queries for fe80::3a00:0:0:0 to fe80::3aff:ffff:ffff:ffff are sent to 10.0.0.1
>
>
> (the displayed IPv6 addresses try to be as short as possible)
>
> Best regards,
> Dominik
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Add-support-for-arbitrary-IPv6-prefix-lengths-in-rev.patch
Type: text/x-patch
Size: 5884 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20200415/60a93843/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Make-prefix-length-optional-in-rev-server.patch
Type: text/x-patch
Size: 3244 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20200415/60a93843/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-Correctly-handle-optinal-forwarding-target.patch
Type: text/x-patch
Size: 2432 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20200415/60a93843/attachment-0005.bin>


More information about the Dnsmasq-discuss mailing list