aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth David Schoen <schoen@loyalty.org>2021-02-03 16:19:18 -0800
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-03 20:30:13 +0200
commit5a3d3b8055f684539f05e00c38fdc5cefb94c883 (patch)
treed731f3ff2c74adc23121350dbcfc21522a665586
parentb1a2762ecfe3d0f7c953abe4c48eb0582303c197 (diff)
downloadbusybox-w32-5a3d3b8055f684539f05e00c38fdc5cefb94c883.tar.gz
busybox-w32-5a3d3b8055f684539f05e00c38fdc5cefb94c883.tar.bz2
busybox-w32-5a3d3b8055f684539f05e00c38fdc5cefb94c883.zip
udhcpd: don't hardcode treating .0 and .255 specially
Even following current Internet standards, it can be perfectly legitimate to issue IPv4 addresses that end in .0 or .255 via DHCP -- this can happen whenever the network is larger than /8. For example, 10.3.4.0 and 10.3.4.255 are legitimate host addresses in 10/8 or 10.3/16. (We also want to be able to issue .0 addresses in smaller networks following our proposed kernel patch and standards changes.) This behavior is already fully controllable by the user, simply by setting start_ip and end_ip correctly. Users who don't want to issue .0 or .255 should set start_ip greater than .0 or end_ip less than .255 and udhcpd will already respect these bounds. (This is also the case for other DHCP servers -- the recommended example configurations will default to a lower bound starting with .1 or some other value, which is typically appropriate, but the user is still allowed to change this to .0 -- or to a range that overlaps a .0 or .255 address -- if so desired.) Signed-off-by: Seth David Schoen <schoen@loyalty.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/udhcp/dhcpd.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 260130507..91f70970a 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -295,12 +295,11 @@ static uint32_t find_free_or_expired_nip(const uint8_t *safe_mac, unsigned arppi
295 uint32_t nip; 295 uint32_t nip;
296 struct dyn_lease *lease; 296 struct dyn_lease *lease;
297 297
298 /* ie, 192.168.55.0 */ 298 /* (Addresses ending in .0 or .255 can legitimately be allocated
299 if ((addr & 0xff) == 0) 299 * in various situations, so _don't_ skip these. The user needs
300 goto next_addr; 300 * to choose start_ip and end_ip correctly for a particular
301 /* ie, 192.168.55.255 */ 301 * network environment.) */
302 if ((addr & 0xff) == 0xff) 302
303 goto next_addr;
304 nip = htonl(addr); 303 nip = htonl(addr);
305 /* skip our own address */ 304 /* skip our own address */
306 if (nip == server_data.server_nip) 305 if (nip == server_data.server_nip)