Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On 10/03/2020 14:25, Petr Menšík wrote: > That is a pity. Is there anything I can help to include it in 2.81? If > you have any objections to part of it or whole concept, please say so. I > would rebase the change again. > > I was added to Fedora as downstream in late summer [1], have not yet > seen any new bug related to it. It seems not broken entirely, maybe it > just works. > > Anyway, if there is anything I can do, please let me know. Feel free to > add me into CC. >> > Could you get me a rebased patch this week? Simon. ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On 3/8/20 5:02 PM, Simon Kelley wrote: > On 06/03/2020 22:10, Petr Menšík wrote: >> Hi Simon, >> >> I have been adapting this feature to earlier releases and discovered one >> error with prefixed address assignment. When it is calculating number of >> addresses from prefixlen, it rotates only 32bit int instead of 64b uint. >> Only result is assigned to 64b variable. >> >> Two examples: >> >> dhcp-host=[2000::1230:0:0/92],correct-prefix >> dhcp-host=[2000::1234:5678:0/92],incorrect-prefix >> >> If prefix length is lower than 96, the result is zero. It means >> incorrect-prefix is not refused as it should. Fix is simple, attaching >> patch with it. Just rotate 64b int. It is just minor issue, but would be >> nice to fix it before 2.81 is released. >> >> Thanks! >> >> > > Patch applied, thanks. > > > I'm well aware that there's some important work of yours to fix the > problem of interfaces changing index which is not in 2.81. That's not > forgotten, but I need you assistance with it, and planned to defer to > 2.82 (which will be much quicker than 2.81). If we can get it done now, > and you really want it in 2.81 then I'm not ruling that out. That is a pity. Is there anything I can help to include it in 2.81? If you have any objections to part of it or whole concept, please say so. I would rebase the change again. I was added to Fedora as downstream in late summer [1], have not yet seen any new bug related to it. It seems not broken entirely, maybe it just works. Anyway, if there is anything I can do, please let me know. Feel free to add me into CC. > > > Cheers, > > Simon. 1. https://bugzilla.redhat.com/show_bug.cgi?id=1728701 -- Petr Menšík Software Engineer Red Hat, http://www.redhat.com/ email: pemen...@redhat.com PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On 06/03/2020 22:10, Petr Menšík wrote: > Hi Simon, > > I have been adapting this feature to earlier releases and discovered one > error with prefixed address assignment. When it is calculating number of > addresses from prefixlen, it rotates only 32bit int instead of 64b uint. > Only result is assigned to 64b variable. > > Two examples: > > dhcp-host=[2000::1230:0:0/92],correct-prefix > dhcp-host=[2000::1234:5678:0/92],incorrect-prefix > > If prefix length is lower than 96, the result is zero. It means > incorrect-prefix is not refused as it should. Fix is simple, attaching > patch with it. Just rotate 64b int. It is just minor issue, but would be > nice to fix it before 2.81 is released. > > Thanks! > > Patch applied, thanks. I'm well aware that there's some important work of yours to fix the problem of interfaces changing index which is not in 2.81. That's not forgotten, but I need you assistance with it, and planned to defer to 2.82 (which will be much quicker than 2.81). If we can get it done now, and you really want it in 2.81 then I'm not ruling that out. Cheers, Simon. ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
Hi Simon, I have been adapting this feature to earlier releases and discovered one error with prefixed address assignment. When it is calculating number of addresses from prefixlen, it rotates only 32bit int instead of 64b uint. Only result is assigned to 64b variable. Two examples: dhcp-host=[2000::1230:0:0/92],correct-prefix dhcp-host=[2000::1234:5678:0/92],incorrect-prefix If prefix length is lower than 96, the result is zero. It means incorrect-prefix is not refused as it should. Fix is simple, attaching patch with it. Just rotate 64b int. It is just minor issue, but would be nice to fix it before 2.81 is released. Thanks! Cheers, Petr On 2/13/20 12:31 AM, Simon Kelley wrote: > On 10/02/2020 22:18, Harald Jensås wrote: >> On Mon, 2020-02-10 at 21:37 +, Simon Kelley wrote: >>> On 10/02/2020 17:56, Harald Jensås wrote: On Fri, 2020-02-07 at 21:27 +, Simon Kelley wrote: > Two commits in the repo, one adds arbitrary list of IPv6 > addresses to > dhcp-host, second adds tags. > > Please give them a whirl > Thank you for working on this Simon. I have tested the following configuration variations and there seem to be one small issue, but overall it is working nicely. The one test that fails is: * Use a prefix with wildcard address: dhcp-host=52:54:00:3f:5c:c0,[::aa08/126],host1 Test: FAIL In this configuration the first request succeeds, following requests get 'no address available'. Looks like it does'nt try the ::aa09 address when aa08 is already leased. >>> >>> Excellent. Thanks for the comprehensive testing. I just pushed the >>> fix >>> for this bug. >>> >> >> Fantastic! I can confirm the last commit fixed the bug. >> >> I also re-ran some of the other smoke tests and everything works as >> expected. >> >> Thanks! >> > > > That's great. I'm trying to catch up on all the loose ends and release > 2.81 ASAP. > > > Cheers, > > Simon. > > > ___ > Dnsmasq-discuss mailing list > Dnsmasq-discuss@lists.thekelleys.org.uk > http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss > -- Petr Menšík Software Engineer Red Hat, http://www.redhat.com/ email: pemen...@redhat.com PGP: DFCF908DB7C87E8E529925BC4931CA5B6C9FC5CB >From 6307208c806f9b968eca178931b3d77c4ed83c54 Mon Sep 17 00:00:00 2001 From: Petr Mensik Date: Fri, 6 Mar 2020 15:37:23 +0100 Subject: [PATCH] Correct range check of dhcp-host prefix It incorrectly works with 32 bit integer only when counting number of addresses in range. It works correctly only between prefixlen 96 and 128. Use 64bit shift to work with well with numbers higher than 64. Fixes commit 79aba0f10ad0157fb4f48afbbcb03f094caff97a error. --- src/option.c | 2 +- src/rfc3315.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/option.c b/src/option.c index 88cd2ab..79122df 100644 --- a/src/option.c +++ b/src/option.c @@ -3247,7 +3247,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma if (!atoi_check(pref, _addr->prefixlen) || new_addr->prefixlen > 128 || - (((1<<(128-new_addr->prefixlen))-1) & addrpart) != 0) + u64)1<<(128-new_addr->prefixlen))-1) & addrpart) != 0) { dhcp_config_free(new); ret_err(_("bad IPv6 prefix")); diff --git a/src/rfc3315.c b/src/rfc3315.c index a0067e9..f59aedc 100644 --- a/src/rfc3315.c +++ b/src/rfc3315.c @@ -1798,7 +1798,7 @@ static int config_valid(struct dhcp_config *config, struct dhcp_context *context addresses = 1; if (addr_list->flags & ADDRLIST_PREFIX) - addresses = 1<<(128-addr_list->prefixlen); + addresses = (u64)1<<(128-addr_list->prefixlen); if ((addr_list->flags & ADDRLIST_WILDCARD)) { -- 2.21.1 ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On 10/02/2020 22:18, Harald Jensås wrote: > On Mon, 2020-02-10 at 21:37 +, Simon Kelley wrote: >> On 10/02/2020 17:56, Harald Jensås wrote: >>> On Fri, 2020-02-07 at 21:27 +, Simon Kelley wrote: Two commits in the repo, one adds arbitrary list of IPv6 addresses to dhcp-host, second adds tags. Please give them a whirl >>> >>> Thank you for working on this Simon. I have tested the following >>> configuration variations and there seem to be one small issue, but >>> overall it is working nicely. >>> >>> The one test that fails is: >>> >>> * Use a prefix with wildcard address: >>> dhcp-host=52:54:00:3f:5c:c0,[::aa08/126],host1 >>> Test: FAIL >>> >>> In this configuration the first request succeeds, following >>> requests get 'no address available'. Looks like it does'nt try >>> the ::aa09 address when aa08 is already leased. >>> >> >> Excellent. Thanks for the comprehensive testing. I just pushed the >> fix >> for this bug. >> > > Fantastic! I can confirm the last commit fixed the bug. > > I also re-ran some of the other smoke tests and everything works as > expected. > > Thanks! > That's great. I'm trying to catch up on all the loose ends and release 2.81 ASAP. Cheers, Simon. ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On Mon, 2020-02-10 at 21:37 +, Simon Kelley wrote: > On 10/02/2020 17:56, Harald Jensås wrote: > > On Fri, 2020-02-07 at 21:27 +, Simon Kelley wrote: > > > Two commits in the repo, one adds arbitrary list of IPv6 > > > addresses to > > > dhcp-host, second adds tags. > > > > > > Please give them a whirl > > > > > > > Thank you for working on this Simon. I have tested the following > > configuration variations and there seem to be one small issue, but > > overall it is working nicely. > > > > The one test that fails is: > > > > * Use a prefix with wildcard address: > > dhcp-host=52:54:00:3f:5c:c0,[::aa08/126],host1 > > Test: FAIL > > > > In this configuration the first request succeeds, following > > requests get 'no address available'. Looks like it does'nt try > > the ::aa09 address when aa08 is already leased. > > > > Excellent. Thanks for the comprehensive testing. I just pushed the > fix > for this bug. > Fantastic! I can confirm the last commit fixed the bug. I also re-ran some of the other smoke tests and everything works as expected. Thanks! -- Harald ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On 10/02/2020 17:56, Harald Jensås wrote: > On Fri, 2020-02-07 at 21:27 +, Simon Kelley wrote: >> Two commits in the repo, one adds arbitrary list of IPv6 addresses to >> dhcp-host, second adds tags. >> >> Please give them a whirl >> > > Thank you for working on this Simon. I have tested the following > configuration variations and there seem to be one small issue, but > overall it is working nicely. > > The one test that fails is: > > * Use a prefix with wildcard address: > dhcp-host=52:54:00:3f:5c:c0,[::aa08/126],host1 > Test: FAIL > > In this configuration the first request succeeds, following > requests get 'no address available'. Looks like it does'nt try > the ::aa09 address when aa08 is already leased. > Excellent. Thanks for the comprehensive testing. I just pushed the fix for this bug. Cheers, Simon. ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On Fri, 2020-02-07 at 21:27 +, Simon Kelley wrote: > Two commits in the repo, one adds arbitrary list of IPv6 addresses to > dhcp-host, second adds tags. > > Please give them a whirl > Thank you for working on this Simon. I have tested the following configuration variations and there seem to be one small issue, but overall it is working nicely. The one test that fails is: * Use a prefix with wildcard address: dhcp-host=52:54:00:3f:5c:c0,[::aa08/126],host1 Test: FAIL In this configuration the first request succeeds, following requests get 'no address available'. Looks like it does'nt try the ::aa09 address when aa08 is already leased. Other tests i've run without issues: * Arbitrary lists of addresses: dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa02],[fd12:3456:789a:1::aa04],[fd12:3456:789a:1::aa06],host1 Test: PASS * Using prefix to reserve a set of addresses: dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04/126],host1 Test: PASS * Arbitrary list of wildcard addresses: dhcp-host=52:54:00:3f:5c:c0,[::aa02],[::aa04],[::aa06],host1 Test: PASS * dhcp-host tags: File: dhclient.conf --- options dhcp6.userclass code 15 = string; # len: 00:08, "dhclient" send dhcp6.userclass 00:08:64:68:63:6c:69:65:6e:74; --- # dhcpv6s for Client System Architecture Type (61) dhcp-match=set:efi6,option6:61,0007 dhcp-match=set:efi6,option6:61,0009 dhcp-match=set:efi6,option6:61,0010 dhcp-match=set:efi6,option6:61,0011 dhcp-userclass=set:ipxe6,iPXE dhcp-userclass=set:dhclient,dhclient dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa03],host1 dhcp-host=tag:efi6,tag:!ipxe6,52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04/126],host1 dhcp-host=tag:ipxe6,52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa02],host1 dhcp-host=tag:dhclient,52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa01],host1 As far as I can tell this is working great! tags: ctlplane-subnet, known, dhcpv6, eth1 nest size: 24 option: 5 iaaddr fd12:3456:789a:1::aa03 PL=600 VL=600 tags: ctlplane-subnet, known, efi6, pxe6, dhcpv6, eth1 nest size: 24 option: 5 iaaddr fd12:3456:789a:1::aa04 PL=600 VL=600 tags: ctlplane-subnet, known, efi6, ipxe6, pxe6, dhcpv6, eth1 nest size: 24 option: 5 iaaddr fd12:3456:789a:1::aa02 PL=600 VL=600 tags: ctlplane-subnet, known, dhclient, dhcpv6, eth1 nest size: 24 option: 5 iaaddr fd12:3456:789a:1::aa01 PL=600 VL=600 A simple config to use random addresses for everything except the final OS: dhcp-userclass=set:dhclient,dhclient dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04/126],host1 dhcp-host=tag:dhclient,52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa01],host1 Test: Pass Best Regards Harald ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
Two commits in the repo, one adds arbitrary list of IPv6 addresses to dhcp-host, second adds tags. Please give them a whirl Cheers, Simon. On 04/02/2020 14:24, Harald Jensås wrote: > On Tue, 2020-02-04 at 00:06 +, Simon Kelley wrote: >> I went though this carefully, and decided that replacing the address >> in >> the dhcp-host with the next free one, but otherwise treating things >> the >> same might not work well. For instance, there are places where the >> question is asked "is this address reserved in any dhcp-host?" and >> clearly that needs to be modified to answer "yes" to any of the >> addresses when there is more than one. >> > > I thought this was only the case for IPv4? I.e I did'nt see that check > for IPv6 and tought it deliberately allowed having the same IP address > in different host-entries? (Fir laptop with wired/wireless interface > get's the same ip and such use cases?) Since it's checking for an > existing lease, it does'nt lease the same address to both hosts > simultaneously. > > I can with this patch put the following configuration, and dnsmasq > starts and serves addresses to the two different hosts from the same > address set. > > dhcp-host=52:54:00:bc:c3:fd,[fd12:3456:789a:1::aa04/126],host2 > dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04/126],host1 > > With the git master; as well as older version 2.76 (the one in CentOS); > I also tested this configuration where two hosts share the same IP: > dhcp-host=52:54:00:bc:c3:fd,[fd12:3456:789a:1::aa04],host2 > dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04],host1 > > The configuration loads without error, and the first host to capture > the reservation gets the lease. The second one get "no addresses > available". > > Because of the above existing behaviour, I came to the conclusion that > implementing any check to verify each address in the arbitrary address > list wasn't necessary. I may have missed something? > >> I ended with a different implementation of the same thing, with the >> exception that I only supported a prefix range of addresses, and not >> an >> arbitrary list. That makes the internal representation much simpler. >> >> A quick test passes fine, but Harald you clearly have a better test >> harness. Please could you put this through its paces, and see if it >> does >> what you need. >> > > I ran some tests with your patch, and I did not run into any issues > with the prefix support. > > Unfortunately, for my use-case in openstack the arbitrary list is the > useful option between the two. There is currently no way in openstack > networking api to ask the ip-address management to allocate a set of > consecutive addresses. Adding support for the prefix approach is a > major change to api, object model's, database schema etc. > > Any chance we can add the arbitrary list back in? Or revert to my > initial approach allowing multiple host-entries with different > addresses? With the tag filtering support added for dhcp-hosts the > issue of ordering of entries in configuration file is somewhat relaxed, > as in; it's possible to control via tag's and filters. > > > > Cheers > Harald > > > ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On 04/02/2020 14:24, Harald Jensås wrote: > On Tue, 2020-02-04 at 00:06 +, Simon Kelley wrote: >> I went though this carefully, and decided that replacing the address >> in >> the dhcp-host with the next free one, but otherwise treating things >> the >> same might not work well. For instance, there are places where the >> question is asked "is this address reserved in any dhcp-host?" and >> clearly that needs to be modified to answer "yes" to any of the >> addresses when there is more than one. >> > > I thought this was only the case for IPv4? I.e I did'nt see that check > for IPv6 and tought it deliberately allowed having the same IP address > in different host-entries? (Fir laptop with wired/wireless interface > get's the same ip and such use cases?) Since it's checking for an > existing lease, it does'nt lease the same address to both hosts > simultaneously. > > I can with this patch put the following configuration, and dnsmasq > starts and serves addresses to the two different hosts from the same > address set. > > dhcp-host=52:54:00:bc:c3:fd,[fd12:3456:789a:1::aa04/126],host2 > dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04/126],host1 > > With the git master; as well as older version 2.76 (the one in CentOS); > I also tested this configuration where two hosts share the same IP: > dhcp-host=52:54:00:bc:c3:fd,[fd12:3456:789a:1::aa04],host2 > dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04],host1 > > The configuration loads without error, and the first host to capture > the reservation gets the lease. The second one get "no addresses > available". > > Because of the above existing behaviour, I came to the conclusion that > implementing any check to verify each address in the arbitrary address > list wasn't necessary. I may have missed something? > There are a couple of cases, which are covered by calls to config_implies() in the patch. 1) A host asks for an address which is static-only, either because the network is declared for static addresses, or the address is outside the range declared for dynamicic allocation. The semantics change to allowing the address in --dhcp-host to any of the addresses in --dhcp-host. 2) Something like dhcp-host=, is valid, and has to override the default lease length for the whole set of addresses now. >> I ended with a different implementation of the same thing, with the >> exception that I only supported a prefix range of addresses, and not >> an >> arbitrary list. That makes the internal representation much simpler. >> >> A quick test passes fine, but Harald you clearly have a better test >> harness. Please could you put this through its paces, and see if it >> does >> what you need. >> > > I ran some tests with your patch, and I did not run into any issues > with the prefix support. > > Unfortunately, for my use-case in openstack the arbitrary list is the > useful option between the two. There is currently no way in openstack > networking api to ask the ip-address management to allocate a set of > consecutive addresses. Adding support for the prefix approach is a > major change to api, object model's, database schema etc. > > Any chance we can add the arbitrary list back in? Yes, no problem doing that. I didn't appreciate it was necessary. New commit soon, and I'll also look at the tagging one. Cheers, Simon. Or revert to my > initial approach allowing multiple host-entries with different > addresses? With the tag filtering support added for dhcp-hosts the > issue of ordering of entries in configuration file is somewhat relaxed, > as in; it's possible to control via tag's and filters. > > > > Cheers > Harald > > > ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On Tue, 2020-02-04 at 00:06 +, Simon Kelley wrote: > I went though this carefully, and decided that replacing the address > in > the dhcp-host with the next free one, but otherwise treating things > the > same might not work well. For instance, there are places where the > question is asked "is this address reserved in any dhcp-host?" and > clearly that needs to be modified to answer "yes" to any of the > addresses when there is more than one. > I thought this was only the case for IPv4? I.e I did'nt see that check for IPv6 and tought it deliberately allowed having the same IP address in different host-entries? (Fir laptop with wired/wireless interface get's the same ip and such use cases?) Since it's checking for an existing lease, it does'nt lease the same address to both hosts simultaneously. I can with this patch put the following configuration, and dnsmasq starts and serves addresses to the two different hosts from the same address set. dhcp-host=52:54:00:bc:c3:fd,[fd12:3456:789a:1::aa04/126],host2 dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04/126],host1 With the git master; as well as older version 2.76 (the one in CentOS); I also tested this configuration where two hosts share the same IP: dhcp-host=52:54:00:bc:c3:fd,[fd12:3456:789a:1::aa04],host2 dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04],host1 The configuration loads without error, and the first host to capture the reservation gets the lease. The second one get "no addresses available". Because of the above existing behaviour, I came to the conclusion that implementing any check to verify each address in the arbitrary address list wasn't necessary. I may have missed something? > I ended with a different implementation of the same thing, with the > exception that I only supported a prefix range of addresses, and not > an > arbitrary list. That makes the internal representation much simpler. > > A quick test passes fine, but Harald you clearly have a better test > harness. Please could you put this through its paces, and see if it > does > what you need. > I ran some tests with your patch, and I did not run into any issues with the prefix support. Unfortunately, for my use-case in openstack the arbitrary list is the useful option between the two. There is currently no way in openstack networking api to ask the ip-address management to allocate a set of consecutive addresses. Adding support for the prefix approach is a major change to api, object model's, database schema etc. Any chance we can add the arbitrary list back in? Or revert to my initial approach allowing multiple host-entries with different addresses? With the tag filtering support added for dhcp-hosts the issue of ordering of entries in configuration file is somewhat relaxed, as in; it's possible to control via tag's and filters. Cheers Harald ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
I went though this carefully, and decided that replacing the address in the dhcp-host with the next free one, but otherwise treating things the same might not work well. For instance, there are places where the question is asked "is this address reserved in any dhcp-host?" and clearly that needs to be modified to answer "yes" to any of the addresses when there is more than one. I ended with a different implementation of the same thing, with the exception that I only supported a prefix range of addresses, and not an arbitrary list. That makes the internal representation much simpler. A quick test passes fine, but Harald you clearly have a better test harness. Please could you put this through its paces, and see if it does what you need. Cheers, Simon. http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=79aba0f10ad0157fb4f48afbbcb03f094caff97a On 27/01/2020 08:14, Harald Jensås wrote: > On Sun, 2020-01-26 at 18:34 +, Simon Kelley wrote: >> /62 is crazy, I don't know why I even said that. Harald, if you could >> tweak your patch work with 128-based prefixes, I think we have >> reached a >> successful conclusion. > > Sure, since 128-bit int's might not be available on many platforms > where dnsmasq run I opted to support a max prefix of /64. So a prefix > between /64 - /128 are valid in config. If the user tries to use a > prefix < /64 an error is raised. > > Updated patch below: > > > > ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On Sun, 2020-01-26 at 18:34 +, Simon Kelley wrote: > /62 is crazy, I don't know why I even said that. Harald, if you could > tweak your patch work with 128-based prefixes, I think we have > reached a > successful conclusion. Sure, since 128-bit int's might not be available on many platforms where dnsmasq run I opted to support a max prefix of /64. So a prefix between /64 - /128 are valid in config. If the user tries to use a prefix < /64 an error is raised. Updated patch below: From 0c3aeb799d185007d7c9feeb10c84a582b769a72 Mon Sep 17 00:00:00 2001 From: Harald Jensås Date: Mon, 13 Jan 2020 19:44:43 +0100 Subject: [PATCH] DHCPv6 - List and Range reservation for single host Add the possibility to provide list's of individual addresses as well as prefixed ranges of ipv6 addresses for a dhcp-host reservation. When a request matching the clid or mac address is recieved the server will iterate over all candidate addresses until it find's one that is not already leased to a different clid/iaid and advertise this address. Using multiple reservations for a single host makes it possible to maintain a static leases only configuration which support network booting systems with UEFI firmware that request a new address (a new SOLICIT with a new IA_NA option using a new IAID) for different boot modes, for instance 'PXE over IPv6', and 'HTTP-Boot over IPv6'. Open Virtual Machine Firmware (OVMF) and most UEFI firmware build on the EDK2 code base exhibit this behaviour. --- man/dnsmasq.8 | 16 +++ src/dnsmasq.h | 15 +-- src/option.c | 75 --- src/rfc3315.c | 66 + 4 files changed, 155 insertions(+), 17 deletions(-) diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 index cb5cc73..46daf98 100644 --- a/man/dnsmasq.8 +++ b/man/dnsmasq.8 @@ -1079,6 +1079,22 @@ work reliably if only one of the hardware addresses is active at any time and there is no way for dnsmasq to enforce this. It is, for instance, useful to allocate a stable IP address to a laptop which has both wired and wireless interfaces. + +For DHCPv6 it is possible to provide multiple IPv6 addresses for a single +dhcp-host. It is also possible to use a prefix in the configuration to +set up a range of addresses. For example: +\fB--dhcp-host=52:54:00:3f:5c:c0,[fd12:3456::aa02][fd12:3456::aa04],host1\fP +will make the two addresses \fBfd12:3456::aa02\fP and \fBfd12:3456::aa04\fP +available to the host with hardware address 52:54:00:3f:5c:c0. +\fB--dhcp-host=52:54:00:3f:5c:c0,[fd12:3456::aa00/126],host1\fP +will make the range of 4 addresses between the base address (fd12:3456::aa00) +and the end address (fd12:3456::aa03) available to the host with hardware +address 52:54:00:3f:5c:c0. Multiple non-prefixed, prefixed or prefixed +wildcard addresses with only the host-identifier part can be mixed, eg: +\fB--dhcp-host=52:54:00:3f:5c:c0,[::aa03][::aa04/127][::aa08/126],host1\fP. +Providing multiple addresses is useful for network booting where individual +boot stages will request addresses with different IAID's. + .TP .B --dhcp-hostsfile= Read DHCP host information from the specified file. If a directory diff --git a/src/dnsmasq.h b/src/dnsmasq.h index 7fb440c..5c771b6 100644 --- a/src/dnsmasq.h +++ b/src/dnsmasq.h @@ -759,14 +759,24 @@ struct hwaddr_config { struct hwaddr_config *next; }; +#ifdef HAVE_DHCP6 +struct in6_addr_list { + struct in6_addr addr6; + int prefix; + unsigned long flags; + struct in6_addr_list *next; +}; +#endif + struct dhcp_config { - unsigned int flags; + unsigned long flags; int clid_len; /* length of client identifier */ unsigned char *clid; /* clientid */ char *hostname, *domain; struct dhcp_netid_list *netid; #ifdef HAVE_DHCP6 - struct in6_addr addr6; + struct in6_addr addr6; /* internal only, user opts in addr6_list */ + struct in6_addr_list *addr6_list; #endif struct in_addr addr; time_t decline_time; @@ -790,6 +800,7 @@ struct dhcp_config { #define CONFIG_ADDR6 4096 #define CONFIG_WILDCARD 8192 #define CONFIG_ADDR6_HOSTS 16384/* address added by from /etc/hosts */ +#define CONFIG_ADDR6_CAND32768/* IPv6 address candidate(s) available */ struct dhcp_opt { int opt, len, flags; diff --git a/src/option.c b/src/option.c index f110b75..9f19ca8 100644 --- a/src/option.c +++ b/src/option.c @@ -1015,6 +1015,16 @@ static void dhcp_netid_list_free(struct dhcp_netid_list *netid) } } +static void dhcp_addr6_list_free(struct in6_addr_list *addr6_list) +{ + while (addr6_list) +{ + struct in6_addr_list *tmp = addr6_list; + addr6_list = addr6_list->next; + free(tmp); +} +} + static void dhcp_config_free(struct dhcp_config *config) { if (config) @@ -1027,6 +1037,9 @@ static void dhcp_config_free(struct dhcp_config *config) free(tmp); } dhcp_netid_list_free(config->netid); +#ifdef HAVE_DHCP6 +
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On 21/01/2020 23:31, Harald Jensås wrote: > On Tue, 2020-01-21 at 23:38 +0100, Tore Anderson wrote: >> * Simon Kelley >> >>> I have an alternative suggestion for the syntax of dhcp-host. >>> It's less flexible, but simpler and easier to understand and to >>> explain, >>> and uses existing semantics rather than adding new keywords. >>> >>> The idea is just to add a prefix-length to the address. That allows >>> you >>> to define (eg) 1,2,4,8, or 16 addresses for use by a host simply >>> and >>> easily in a way which makes it difficult to accidentally overlap >>> address >>> ranges, and is fairly obvious to anyone who has done done any IPv6 >>> network configuration. >>> >>> for instance to reserve four addresses for each host we cold do: >>> >>> dhcp-host=00:11:22:33:44:55,[fd12:3456::aa00/62] >>> dhcp-host=00:11:22:33:44:56,[fd12:3456::aa04/62] >>> dhcp-host=00:11:22:33:44:57,[fd12:3456::aa08/62] >>> >>> As a sanity check, if the "host part" of the address isn't zero, >>> >>> ie [fd12:3456::aa01/62] >>> >>> that could be rejected with an error. >> > > I like the idea of using a prefix. I have a new revision of the patch > with this implemented at the bottom of this e-mail. It's far better and > more flexible than the keywords approach I came up with initially, as > it's now possible to mix individual addreses, prefixed ranges and > prefixed wildcard addresses etc. > > # A list of addressses > dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa02][fd12:3456:789a:1::aa04][fd12:3456:789a:1::aa06],host1 > > # Mixing a prefix and a single address > dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04/62][fd12:3456:789a:1::aa00],host1 > > # Prefixed wildcard > dhcp-host=52:54:00:3f:5c:c0,[::aa04/62],host1 > > >> I have done quite a bit of IPv6 networking, but the use of /62 here >> is anything but «fairly obvious» to me. >> >> It would have been much more intuitive to use /126, in my opinion. >> >> Tore >> > > I too found it a bit curios with /62 at first, as I understand it the > interface identifier is always the 64 least significant bit's in IPv6 > ref[1]. > > I think changing the patch to use the full 128 bit's as a mask is > trivial. We may also support both by subtracting 64 from any prefix > larger than 64 in the code? So /126 and /62 yield the same result. > > What does other people think? > /62 is crazy, I don't know why I even said that. Harald, if you could tweak your patch work with 128-based prefixes, I think we have reached a successful conclusion. Simon. ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On 21/01/2020 22:38, Tore Anderson wrote: > * Simon Kelley > >> I have an alternative suggestion for the syntax of dhcp-host. >> It's less flexible, but simpler and easier to understand and to explain, >> and uses existing semantics rather than adding new keywords. >> >> The idea is just to add a prefix-length to the address. That allows you >> to define (eg) 1,2,4,8, or 16 addresses for use by a host simply and >> easily in a way which makes it difficult to accidentally overlap address >> ranges, and is fairly obvious to anyone who has done done any IPv6 >> network configuration. >> >> for instance to reserve four addresses for each host we cold do: >> >> dhcp-host=00:11:22:33:44:55,[fd12:3456::aa00/62] >> dhcp-host=00:11:22:33:44:56,[fd12:3456::aa04/62] >> dhcp-host=00:11:22:33:44:57,[fd12:3456::aa08/62] >> >> As a sanity check, if the "host part" of the address isn't zero, >> >> ie [fd12:3456::aa01/62] >> >> that could be rejected with an error. > > I have done quite a bit of IPv6 networking, but the use of /62 here is > anything but «fairly obvious» to me. > > It would have been much more intuitive to use /126, in my opinion. > > Tore > /62 was a late-night-long-day brain fade. Of Course, I meant /126 :) Simon. ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On Wed, Jan 22, 2020 at 12:31:16AM +0100, Harald Jensås wrote: > On Tue, 2020-01-21 at 23:38 +0100, Tore Anderson wrote: > > * Simon Kelley > > > > > I have an alternative suggestion for the syntax of dhcp-host. > > > It's less flexible, but simpler and easier to understand and to > > > explain, > > > and uses existing semantics rather than adding new keywords. > > > > > > The idea is just to add a prefix-length to the address. That allows > > > you > > > to define (eg) 1,2,4,8, or 16 addresses for use by a host simply > > > and > > > easily in a way which makes it difficult to accidentally overlap > > > address > > > ranges, and is fairly obvious to anyone who has done done any IPv6 > > > network configuration. > > > > > > for instance to reserve four addresses for each host we cold do: > > > > > > dhcp-host=00:11:22:33:44:55,[fd12:3456::aa00/62] > > > dhcp-host=00:11:22:33:44:56,[fd12:3456::aa04/62] > > > dhcp-host=00:11:22:33:44:57,[fd12:3456::aa08/62] > > > > > > As a sanity check, if the "host part" of the address isn't zero, > > > > > > ie [fd12:3456::aa01/62] > > > > > > that could be rejected with an error. > > I like the idea of using a prefix. I have a new revision of the patch > with this implemented at the bottom of this e-mail. It's far better and > more flexible than the keywords approach I came up with initially, as > it's now possible to mix individual addreses, prefixed ranges and > prefixed wildcard addresses etc. > > # A list of addressses > dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa02][fd12:3456:789a:1::aa04][fd12:3456:789a:1::aa06],host1 > > # Mixing a prefix and a single address > dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04/62][fd12:3456:789a:1::aa00],host1 > > # Prefixed wildcard > dhcp-host=52:54:00:3f:5c:c0,[::aa04/62],host1 > > > > I have done quite a bit of IPv6 networking, but the use of /62 here > > is anything but «fairly obvious» to me. > > > > It would have been much more intuitive to use /126, in my opinion. +1 > > > > Tore > > > > I too found it a bit curios with /62 at first, :-) > as I understand it the interface identifier is always the 64 least > significant bit's in IPv6 ref[1]. Comparing apples and oranges. An IPv6 address with it's prefix is not the same as some syntax that describes several IPv6 addresses. > I think changing the patch to use the full 128 bit's as a mask is > trivial. We may also support both by subtracting 64 from any prefix > larger than 64 in the code? What with prefixes smaller as 64 e.g. 48? > So /126 and /62 yield the same result. Please, pretty please, keep ambiguity away from computers. > What does other people think? } What do other people think? > > [1] > https://en.wikipedia.org/wiki/IPv6_address#Unicast_and_anycast_address_format > > > > > From a69c6400454cdf036808a0a40ac033688387f20d Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Harald=20Jens=C3=A5s?= > Date: Mon, 13 Jan 2020 19:44:43 +0100 > Subject: [PATCH] DHCPv6 - List and Range reservation for single host > [ ... commit message, git statistics ... ] > > diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 > index cb5cc73..57003d7 100644 > --- a/man/dnsmasq.8 > +++ b/man/dnsmasq.8 > @@ -1079,6 +1079,22 @@ work reliably if only one of the hardware addresses is > active at any > time and there is no way for dnsmasq to enforce this. It is, for instance, > useful to allocate a stable IP address to a laptop which > has both wired and wireless interfaces. > + > +For DHCPv6 it is possible to provide multiple IPv6 addresses for a single > +dhcp-host. It is also possible to use a prefix in the configuration to > +set up a range of addresses. For example: > +\fB--dhcp-host=52:54:00:3f:5c:c0,[fd12:3456::aa02][fd12:3456::aa04],host1\fP > +will make the two addresses \fBfd12:3456::aa02\fP and \fBfd12:3456::aa04\fP > +available to the host with hardware address 52:54:00:3f:5c:c0. > +\fB--dhcp-host=52:54:00:3f:5c:c0,[fd12:3456::aa00/62],host1\fP +\fB--dhcp-host=52:54:00:3f:5c:c0,[fd12:3456::aa00/126],host1\fP > +will make the range of 4 addresses between the base address (fd12:3456::aa00) > +and the end address (fd12:3456::aa03) available to the host with hardware > +address 52:54:00:3f:5c:c0. Multiple non-prefixed, prefixed or prefixed > +wildcard addresses with only the host-identifier part can be mixed, eg: > +\fB--dhcp-host=52:54:00:3f:5c:c0,[::aa03][::aa04/63][::aa08/62],host1\fP. +\fB--dhcp-host=52:54:00:3f:5c:c0,[::aa03][::aa04/127][::aa08/126],host1\fP. > +Providing multiple addresses is useful for network booting where individual > +boot stages will request addresses with different IAID's. > + > .TP > .B --dhcp-hostsfile= > Read DHCP host information from the specified file. If a directory Groeten Geert Stappers -- Leven en laten leven signature.asc Description: PGP signature ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On Tue, 2020-01-21 at 23:38 +0100, Tore Anderson wrote: > * Simon Kelley > > > I have an alternative suggestion for the syntax of dhcp-host. > > It's less flexible, but simpler and easier to understand and to > > explain, > > and uses existing semantics rather than adding new keywords. > > > > The idea is just to add a prefix-length to the address. That allows > > you > > to define (eg) 1,2,4,8, or 16 addresses for use by a host simply > > and > > easily in a way which makes it difficult to accidentally overlap > > address > > ranges, and is fairly obvious to anyone who has done done any IPv6 > > network configuration. > > > > for instance to reserve four addresses for each host we cold do: > > > > dhcp-host=00:11:22:33:44:55,[fd12:3456::aa00/62] > > dhcp-host=00:11:22:33:44:56,[fd12:3456::aa04/62] > > dhcp-host=00:11:22:33:44:57,[fd12:3456::aa08/62] > > > > As a sanity check, if the "host part" of the address isn't zero, > > > > ie [fd12:3456::aa01/62] > > > > that could be rejected with an error. > I like the idea of using a prefix. I have a new revision of the patch with this implemented at the bottom of this e-mail. It's far better and more flexible than the keywords approach I came up with initially, as it's now possible to mix individual addreses, prefixed ranges and prefixed wildcard addresses etc. # A list of addressses dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa02][fd12:3456:789a:1::aa04][fd12:3456:789a:1::aa06],host1 # Mixing a prefix and a single address dhcp-host=52:54:00:3f:5c:c0,[fd12:3456:789a:1::aa04/62][fd12:3456:789a:1::aa00],host1 # Prefixed wildcard dhcp-host=52:54:00:3f:5c:c0,[::aa04/62],host1 > I have done quite a bit of IPv6 networking, but the use of /62 here > is anything but «fairly obvious» to me. > > It would have been much more intuitive to use /126, in my opinion. > > Tore > I too found it a bit curios with /62 at first, as I understand it the interface identifier is always the 64 least significant bit's in IPv6 ref[1]. I think changing the patch to use the full 128 bit's as a mask is trivial. We may also support both by subtracting 64 from any prefix larger than 64 in the code? So /126 and /62 yield the same result. What does other people think? [1] https://en.wikipedia.org/wiki/IPv6_address#Unicast_and_anycast_address_format From a69c6400454cdf036808a0a40ac033688387f20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Mon, 13 Jan 2020 19:44:43 +0100 Subject: [PATCH] DHCPv6 - List and Range reservation for single host Add the possibility to provide list's of individual addresses as well as prefixed ranges of ipv6 addresses for a dhcp-host reservation. When a request matching the clid or mac address is recieved the server will iterate over all candidate addresses until it find's one that is not already leased to a different clid/iaid and advertise this address. Using multiple reservations for a single host makes it possible to maintain a static leases only configuration which support network booting systems with UEFI firmware that request a new address (a new SOLICIT with a new IA_NA option using a new IAID) for different boot modes, for instance 'PXE over IPv6', and 'HTTP-Boot over IPv6'. Open Virtual Machine Firmware (OVMF) and most UEFI firmware build on the EDK2 code base exhibit this behaviour. --- man/dnsmasq.8 | 16 src/dnsmasq.h | 15 ++-- src/option.c | 68 +++ src/rfc3315.c | 66 + 4 files changed, 147 insertions(+), 18 deletions(-) diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 index cb5cc73..57003d7 100644 --- a/man/dnsmasq.8 +++ b/man/dnsmasq.8 @@ -1079,6 +1079,22 @@ work reliably if only one of the hardware addresses is active at any time and there is no way for dnsmasq to enforce this. It is, for instance, useful to allocate a stable IP address to a laptop which has both wired and wireless interfaces. + +For DHCPv6 it is possible to provide multiple IPv6 addresses for a single +dhcp-host. It is also possible to use a prefix in the configuration to +set up a range of addresses. For example: +\fB--dhcp-host=52:54:00:3f:5c:c0,[fd12:3456::aa02][fd12:3456::aa04],host1\fP +will make the two addresses \fBfd12:3456::aa02\fP and \fBfd12:3456::aa04\fP +available to the host with hardware address 52:54:00:3f:5c:c0. +\fB--dhcp-host=52:54:00:3f:5c:c0,[fd12:3456::aa00/62],host1\fP +will make the range of 4 addresses between the base address (fd12:3456::aa00) +and the end address (fd12:3456::aa03) available to the host with hardware +address 52:54:00:3f:5c:c0. Multiple non-prefixed, prefixed or prefixed +wildcard addresses with only the host-identifier part can be mixed, eg: +\fB--dhcp-host=52:54:00:3f:5c:c0,[::aa03][::aa04/63][::aa08/62],host1\fP. +Providing multiple addresses is useful for network booting where individual +boot stages will request addresses with different IAID's. + .TP .B
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
* Simon Kelley > I have an alternative suggestion for the syntax of dhcp-host. > It's less flexible, but simpler and easier to understand and to explain, > and uses existing semantics rather than adding new keywords. > > The idea is just to add a prefix-length to the address. That allows you > to define (eg) 1,2,4,8, or 16 addresses for use by a host simply and > easily in a way which makes it difficult to accidentally overlap address > ranges, and is fairly obvious to anyone who has done done any IPv6 > network configuration. > > for instance to reserve four addresses for each host we cold do: > > dhcp-host=00:11:22:33:44:55,[fd12:3456::aa00/62] > dhcp-host=00:11:22:33:44:56,[fd12:3456::aa04/62] > dhcp-host=00:11:22:33:44:57,[fd12:3456::aa08/62] > > As a sanity check, if the "host part" of the address isn't zero, > > ie [fd12:3456::aa01/62] > > that could be rejected with an error. I have done quite a bit of IPv6 networking, but the use of /62 here is anything but «fairly obvious» to me. It would have been much more intuitive to use /126, in my opinion. Tore ___ Dnsmasq-discuss mailing list Dnsmasq-discuss@lists.thekelleys.org.uk http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
On 16/01/2020 18:09, Harald Jensås wrote: > Hi, > > Changing the topic and dropping the history as this is a full re-write > of the patch based on the previous feedback and discussion. Instead of > multiple dhcp-host entries, a single dhcp-host entry can be defined > with either a list: or range: of addresses, this should eliminate the > issue with ordering of entries in the configuration file. > > I have an alternative suggestion for the syntax of dhcp-host. It's less flexible, but simpler and easier to understand and to explain, and uses existing semantics rather than adding new keywords. The idea is just to add a prefix-length to the address. That allows you to define (eg) 1,2,4,8, or 16 addresses for use by a host simply and easily in a way which makes it difficult to accidentally overlap address ranges, and is fairly obvious to anyone who has done done any IPv6 network configuration. for instance to reserve four addresses for each host we cold do: dhcp-host=00:11:22:33:44:55,[fd12:3456::aa00/62] dhcp-host=00:11:22:33:44:56,[fd12:3456::aa04/62] dhcp-host=00:11:22:33:44:57,[fd12:3456::aa08/62] As a sanity check, if the "host part" of the address isn't zero, ie [fd12:3456::aa01/62] that could be rejected with an error. Happy to be shot down in flames, but that seems to be a simple to implement and to explain way of doing what you want to achieve. Cheers, Simon. > > -- > Harald > > > >>From cfd8881d57ba9e0e26c183318f0118a5ca65c705 Mon Sep 17 00:00:00 2001 > From: Harald Jensås > Date: Mon, 13 Jan 2020 19:44:43 +0100 > Subject: [PATCH] DHCPv6 - List or Range reservation for single host > > Add the possibility to provide either a list or a range > of ipv6 addresses for a dhcp-host reservation. When a > request matching the clid or mac address is recieved the > server will iterate over the available addresses until it > find's one that is not already leased to a different > clid/iaid and advertise this address. > > Using multiple reservations for a single host makes it > possible to maintain a static leases only configuration > which support network booting systems with UEFI firmware > that request a new address (a new SOLICIT with a new IA_NA > option using a new IAID) for different boot modes, for > instance 'PXE over IPv6', and 'HTTP-Boot over IPv6'. Open > Virtual Machine Firmware (OVMF) and most UEFI firmware > build on the EDK2 code base exhibit this behaviour. > --- > man/dnsmasq.8 | 11 + > src/dnsmasq.h | 13 +- > src/option.c | 67 ++- > src/rfc3315.c | 60 + > 4 files changed, 149 insertions(+), 2 deletions(-) > > diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 > index cb5cc73..454fca3 100644 > --- a/man/dnsmasq.8 > +++ b/man/dnsmasq.8 > @@ -1079,6 +1079,17 @@ work reliably if only one of the hardware addresses is > active at any > time and there is no way for dnsmasq to enforce this. It is, for instance, > useful to allocate a stable IP address to a laptop which > has both wired and wireless interfaces. > + > +For DHCPv6 it is possible to provide a list or a range of IPv6 addresses. > +\fB--dhcp-host=52:54:00:3f:5c:c0,list:[fd12:3456::aa02][fd12:3456::aa04],host1\fP > +will make the two addresses \fBfd12:3456::aa02\fP and \fBfd12:3456::aa04\fP > +available to the host with hardware address 52:54:00:3f:5c:c0. > +\fB--dhcp-host=52:54:00:3f:5c:c0,range:fd12:3456::aa01-fd12:3456::aa63,host1\fP > +will make the range of addresses between the start address (fd12:3456::aa01) > and > +the end address (fd12:3456::aa63) available to the host with hardware address > +52:54:00:3f:5c:c0. Providing a range or list of addresses is useful for > network > +booting where individual boot stages will request addresses with different > IAID's. > + > .TP > .B --dhcp-hostsfile= > Read DHCP host information from the specified file. If a directory > diff --git a/src/dnsmasq.h b/src/dnsmasq.h > index 7fb440c..a77955b 100644 > --- a/src/dnsmasq.h > +++ b/src/dnsmasq.h > @@ -759,14 +759,23 @@ struct hwaddr_config { >struct hwaddr_config *next; > }; > > +#ifdef HAVE_DHCP6 > +struct in6_addr_list { > + struct in6_addr addr6; > + struct in6_addr_list *next; > +}; > +#endif > + > struct dhcp_config { > - unsigned int flags; > + unsigned long flags; >int clid_len; /* length of client identifier */ >unsigned char *clid; /* clientid */ >char *hostname, *domain; >struct dhcp_netid_list *netid; > #ifdef HAVE_DHCP6 >struct in6_addr addr6; > + struct in6_addr start6, end6; /* range of addresses */ > + struct in6_addr_list *addr6_list; > #endif >struct in_addr addr; >time_t decline_time; > @@ -790,6 +799,8 @@ struct dhcp_config { > #define CONFIG_ADDR6 4096 > #define CONFIG_WILDCARD 8192 > #define CONFIG_ADDR6_HOSTS 16384/* address added by from /etc/hosts */ > +#define CONFIG_ADDR6_RANGE 32768 > +#define
Re: [Dnsmasq-discuss] [PATCH] DHCPv6 - List or Range reservation for single host
Hi, Changing the topic and dropping the history as this is a full re-write of the patch based on the previous feedback and discussion. Instead of multiple dhcp-host entries, a single dhcp-host entry can be defined with either a list: or range: of addresses, this should eliminate the issue with ordering of entries in the configuration file. -- Harald From cfd8881d57ba9e0e26c183318f0118a5ca65c705 Mon Sep 17 00:00:00 2001 From: Harald Jensås Date: Mon, 13 Jan 2020 19:44:43 +0100 Subject: [PATCH] DHCPv6 - List or Range reservation for single host Add the possibility to provide either a list or a range of ipv6 addresses for a dhcp-host reservation. When a request matching the clid or mac address is recieved the server will iterate over the available addresses until it find's one that is not already leased to a different clid/iaid and advertise this address. Using multiple reservations for a single host makes it possible to maintain a static leases only configuration which support network booting systems with UEFI firmware that request a new address (a new SOLICIT with a new IA_NA option using a new IAID) for different boot modes, for instance 'PXE over IPv6', and 'HTTP-Boot over IPv6'. Open Virtual Machine Firmware (OVMF) and most UEFI firmware build on the EDK2 code base exhibit this behaviour. --- man/dnsmasq.8 | 11 + src/dnsmasq.h | 13 +- src/option.c | 67 ++- src/rfc3315.c | 60 + 4 files changed, 149 insertions(+), 2 deletions(-) diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 index cb5cc73..454fca3 100644 --- a/man/dnsmasq.8 +++ b/man/dnsmasq.8 @@ -1079,6 +1079,17 @@ work reliably if only one of the hardware addresses is active at any time and there is no way for dnsmasq to enforce this. It is, for instance, useful to allocate a stable IP address to a laptop which has both wired and wireless interfaces. + +For DHCPv6 it is possible to provide a list or a range of IPv6 addresses. +\fB--dhcp-host=52:54:00:3f:5c:c0,list:[fd12:3456::aa02][fd12:3456::aa04],host1\fP +will make the two addresses \fBfd12:3456::aa02\fP and \fBfd12:3456::aa04\fP +available to the host with hardware address 52:54:00:3f:5c:c0. +\fB--dhcp-host=52:54:00:3f:5c:c0,range:fd12:3456::aa01-fd12:3456::aa63,host1\fP +will make the range of addresses between the start address (fd12:3456::aa01) and +the end address (fd12:3456::aa63) available to the host with hardware address +52:54:00:3f:5c:c0. Providing a range or list of addresses is useful for network +booting where individual boot stages will request addresses with different IAID's. + .TP .B --dhcp-hostsfile= Read DHCP host information from the specified file. If a directory diff --git a/src/dnsmasq.h b/src/dnsmasq.h index 7fb440c..a77955b 100644 --- a/src/dnsmasq.h +++ b/src/dnsmasq.h @@ -759,14 +759,23 @@ struct hwaddr_config { struct hwaddr_config *next; }; +#ifdef HAVE_DHCP6 +struct in6_addr_list { + struct in6_addr addr6; + struct in6_addr_list *next; +}; +#endif + struct dhcp_config { - unsigned int flags; + unsigned long flags; int clid_len; /* length of client identifier */ unsigned char *clid; /* clientid */ char *hostname, *domain; struct dhcp_netid_list *netid; #ifdef HAVE_DHCP6 struct in6_addr addr6; + struct in6_addr start6, end6; /* range of addresses */ + struct in6_addr_list *addr6_list; #endif struct in_addr addr; time_t decline_time; @@ -790,6 +799,8 @@ struct dhcp_config { #define CONFIG_ADDR6 4096 #define CONFIG_WILDCARD 8192 #define CONFIG_ADDR6_HOSTS 16384/* address added by from /etc/hosts */ +#define CONFIG_ADDR6_RANGE 32768 +#define CONFIG_ADDR6_LIST65536 struct dhcp_opt { int opt, len, flags; diff --git a/src/option.c b/src/option.c index f110b75..2a4a9e2 100644 --- a/src/option.c +++ b/src/option.c @@ -1015,6 +1015,16 @@ static void dhcp_netid_list_free(struct dhcp_netid_list *netid) } } +static void dhcp_addr6_list_free(struct in6_addr_list *addr6_list) +{ + while (addr6_list) +{ + struct in6_addr_list *tmp = addr6_list; + addr6_list = addr6_list->next; + free(tmp); +} +} + static void dhcp_config_free(struct dhcp_config *config) { if (config) @@ -1027,6 +1037,7 @@ static void dhcp_config_free(struct dhcp_config *config) free(tmp); } dhcp_netid_list_free(config->netid); + dhcp_addr6_list_free(config->addr6_list); if (config->flags & CONFIG_CLID) free(config->clid); free(config); @@ -3262,8 +3273,62 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma ret_err(_("cannot match tags in --dhcp-host")); } #ifdef HAVE_DHCP6 - else if (arg[0] == '[' && arg[strlen(arg)-1] == ']') + /* dhcp-host have a range of addresses */ + else if (strstr(arg, "range:") == arg)