1 From e7bfd556c079c8b5e7425aed44abc35925b24043 Mon Sep 17 00:00:00 2001
2 From: Simon Kelley <simon@thekelleys.org.uk>
3 Date: Mon, 31 Dec 2018 20:51:15 +0000
4 Subject: [PATCH 17/30] Alter DHCP address selection after DECLINE in
5 consec-addr mode. Avoid offering the same address after a recieving a DECLINE
6 message to stop an infinite protocol loop. This has long been done in default
7 address allocation mode: this adds similar behaviour when allocaing addresses
10 Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
12 src/dhcp.c | 13 +++++++++++++
13 src/dhcp6.c | 11 +++++++++--
14 2 files changed, 22 insertions(+), 2 deletions(-)
18 @@ -754,6 +754,19 @@ int address_allocate(struct dhcp_context
19 if (addr.s_addr == d->router.s_addr)
22 + /* in consec-ip mode, skip addresses equal to
23 + the number of addresses rejected by clients. This
24 + should avoid the same client being offered the same
25 + address after it has rjected it. */
26 + if (option_bool(OPT_CONSEC_ADDR))
31 + d = context; /* d non-NULL skips the address. */
35 /* Addresses which end in .255 and .0 are broken in Windows even when using
36 supernetting. ie dhcp-range=192.168.0.1,192.168.1.254,255,255,254.0
37 then 192.168.0.255 is a valid IP address, but not for Windows as it's
40 @@ -431,8 +431,15 @@ struct dhcp_context *address6_allocate(s
43 if (!temp_addr && option_bool(OPT_CONSEC_ADDR))
44 - /* seed is largest extant lease addr in this context */
45 - start = lease_find_max_addr6(c) + serial;
47 + /* seed is largest extant lease addr in this context,
48 + skip addresses equal to the number of addresses rejected
49 + by clients. This should avoid the same client being offered the same
50 + address after it has rjected it. */
51 + start = lease_find_max_addr6(c) + serial + c->addr_epoch;
57 u64 range = 1 + addr6part(&c->end6) - addr6part(&c->start6);