aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/leases.c
diff options
context:
space:
mode:
authorMichel Stam <m.stam@fugro.nl>2014-10-30 11:59:04 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2014-10-30 11:59:04 +0100
commit9f41271f3ce82e0f7196c2442614ef4e9d360928 (patch)
tree98dd2becad3478ada376dff4e7a02af50e84e78a /networking/udhcp/leases.c
parent760d035699c4a878f9109544c1d35ea0d5f6b76c (diff)
downloadbusybox-w32-9f41271f3ce82e0f7196c2442614ef4e9d360928.tar.gz
busybox-w32-9f41271f3ce82e0f7196c2442614ef4e9d360928.tar.bz2
busybox-w32-9f41271f3ce82e0f7196c2442614ef4e9d360928.zip
udhcpd: add option for tweaking arpping
Some clients have a very short timeout for sending the DHCP DISCOVER, shorter than the arpping timeout of 2000 milliseconds that udhcpd uses by default. This patch allows tweaking the timeout, or disabling of arpping altogether, at the risk of handing out addresses which are already in use. function old new delta udhcpd_main 1460 1501 +41 udhcpc_main 2814 2851 +37 packed_usage 29957 29974 +17 arpping 477 493 +16 find_free_or_expired_nip 161 174 +13 send_offer 285 292 +7 nobody_responds_to_arp 85 89 +4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 7/0 up/down: 135/0) Total: 135 bytes Signed-off-by: Michel Stam <m.stam@fugro.nl> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r--networking/udhcp/leases.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c
index c5b60b108..745340ad3 100644
--- a/networking/udhcp/leases.c
+++ b/networking/udhcp/leases.c
@@ -112,7 +112,7 @@ struct dyn_lease* FAST_FUNC find_lease_by_nip(uint32_t nip)
112} 112}
113 113
114/* Check if the IP is taken; if it is, add it to the lease table */ 114/* Check if the IP is taken; if it is, add it to the lease table */
115static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac) 115static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac, unsigned arpping_ms)
116{ 116{
117 struct in_addr temp; 117 struct in_addr temp;
118 int r; 118 int r;
@@ -120,7 +120,8 @@ static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac)
120 r = arpping(nip, safe_mac, 120 r = arpping(nip, safe_mac,
121 server_config.server_nip, 121 server_config.server_nip,
122 server_config.server_mac, 122 server_config.server_mac,
123 server_config.interface); 123 server_config.interface,
124 arpping_ms);
124 if (r) 125 if (r)
125 return r; 126 return r;
126 127
@@ -132,7 +133,7 @@ static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac)
132} 133}
133 134
134/* Find a new usable (we think) address */ 135/* Find a new usable (we think) address */
135uint32_t FAST_FUNC find_free_or_expired_nip(const uint8_t *safe_mac) 136uint32_t FAST_FUNC find_free_or_expired_nip(const uint8_t *safe_mac, unsigned arpping_ms)
136{ 137{
137 uint32_t addr; 138 uint32_t addr;
138 struct dyn_lease *oldest_lease = NULL; 139 struct dyn_lease *oldest_lease = NULL;
@@ -177,7 +178,7 @@ uint32_t FAST_FUNC find_free_or_expired_nip(const uint8_t *safe_mac)
177 lease = find_lease_by_nip(nip); 178 lease = find_lease_by_nip(nip);
178 if (!lease) { 179 if (!lease) {
179//TODO: DHCP servers do not always sit on the same subnet as clients: should *ping*, not arp-ping! 180//TODO: DHCP servers do not always sit on the same subnet as clients: should *ping*, not arp-ping!
180 if (nobody_responds_to_arp(nip, safe_mac)) 181 if (nobody_responds_to_arp(nip, safe_mac, arpping_ms))
181 return nip; 182 return nip;
182 } else { 183 } else {
183 if (!oldest_lease || lease->expires < oldest_lease->expires) 184 if (!oldest_lease || lease->expires < oldest_lease->expires)
@@ -194,7 +195,7 @@ uint32_t FAST_FUNC find_free_or_expired_nip(const uint8_t *safe_mac)
194 195
195 if (oldest_lease 196 if (oldest_lease
196 && is_expired_lease(oldest_lease) 197 && is_expired_lease(oldest_lease)
197 && nobody_responds_to_arp(oldest_lease->lease_nip, safe_mac) 198 && nobody_responds_to_arp(oldest_lease->lease_nip, safe_mac, arpping_ms)
198 ) { 199 ) {
199 return oldest_lease->lease_nip; 200 return oldest_lease->lease_nip;
200 } 201 }