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 +0000, Simon Kelley wrote: >>> On 10/02/2020 17:56, Harald Jensås wrote: >>>> On Fri, 2020-02-07 at 21:27 +0000, 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 <pemen...@redhat.com> 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, &new_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