aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/arpping.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/arpping.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 'networking/udhcp/arpping.c')
-rw-r--r--networking/udhcp/arpping.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index b43e52e96..fad2283c3 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -39,7 +39,8 @@ int FAST_FUNC arpping(uint32_t test_nip,
39 const uint8_t *safe_mac, 39 const uint8_t *safe_mac,
40 uint32_t from_ip, 40 uint32_t from_ip,
41 uint8_t *from_mac, 41 uint8_t *from_mac,
42 const char *interface) 42 const char *interface,
43 unsigned timeo)
43{ 44{
44 int timeout_ms; 45 int timeout_ms;
45 struct pollfd pfd[1]; 46 struct pollfd pfd[1];
@@ -48,6 +49,9 @@ int FAST_FUNC arpping(uint32_t test_nip,
48 struct sockaddr addr; /* for interface name */ 49 struct sockaddr addr; /* for interface name */
49 struct arpMsg arp; 50 struct arpMsg arp;
50 51
52 if (!timeo)
53 return 1;
54
51 s = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP)); 55 s = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP));
52 if (s == -1) { 56 if (s == -1) {
53 bb_perror_msg(bb_msg_can_not_create_raw_socket); 57 bb_perror_msg(bb_msg_can_not_create_raw_socket);
@@ -83,7 +87,7 @@ int FAST_FUNC arpping(uint32_t test_nip,
83 } 87 }
84 88
85 /* wait for arp reply, and check it */ 89 /* wait for arp reply, and check it */
86 timeout_ms = 2000; 90 timeout_ms = (int)timeo;
87 do { 91 do {
88 typedef uint32_t aliased_uint32_t FIX_ALIASING; 92 typedef uint32_t aliased_uint32_t FIX_ALIASING;
89 int r; 93 int r;
@@ -124,7 +128,7 @@ int FAST_FUNC arpping(uint32_t test_nip,
124 * this is more under/overflow-resistant 128 * this is more under/overflow-resistant
125 * (people did see overflows here when system time jumps): 129 * (people did see overflows here when system time jumps):
126 */ 130 */
127 } while ((unsigned)timeout_ms <= 2000); 131 } while ((unsigned)timeout_ms <= timeo);
128 132
129 ret: 133 ret:
130 close(s); 134 close(s);