diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2019-02-18 14:11:12 +0100 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2019-02-18 14:11:12 +0100 |
commit | 67b3a141da8bbfd9fc506d043f1e7e1a92e2c7f9 (patch) | |
tree | f70a3485cfb99ef3a07ffaea9f375626eb5d8c46 /src | |
parent | ca8ba91c757b1559bc6391707547d54477c8315a (diff) |
dhcpv4: fix assignment of requested IP address
Fix assignment of requested IP address by a client in case the
assignment list is empty.
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/dhcpv4.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index da2c051..252003b 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -920,9 +920,15 @@ static bool dhcpv4_assign(struct interface *iface, struct dhcp_assignment *a, /* try to assign the IP the client asked for */ if (start <= ntohl(raddr) && ntohl(raddr) <= end && !config_find_lease_by_ipaddr(raddr)) { + if (list_empty(&iface->dhcpv4_assignments)) { + list_add(&a->head, &iface->dhcpv4_assignments); + goto raddr_out; + } + list_for_each_entry(c, &iface->dhcpv4_assignments, head) { if (ntohl(c->addr) > ntohl(raddr)) { list_add_tail(&a->head, &c->head); +raddr_out: a->addr = raddr; syslog(LOG_INFO, "Assigning the IP the client asked for: %u.%u.%u.%u", |