aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpc.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/dhcpc.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/dhcpc.c')
-rw-r--r--networking/udhcp/dhcpc.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index e468b7bbb..35e7c2070 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -54,7 +54,7 @@ static const char udhcpc_longopts[] ALIGN1 =
54 "foreground\0" No_argument "f" 54 "foreground\0" No_argument "f"
55 "background\0" No_argument "b" 55 "background\0" No_argument "b"
56 "broadcast\0" No_argument "B" 56 "broadcast\0" No_argument "B"
57 IF_FEATURE_UDHCPC_ARPING("arping\0" No_argument "a") 57 IF_FEATURE_UDHCPC_ARPING("arping\0" Optional_argument "a")
58 IF_FEATURE_UDHCP_PORT("client-port\0" Required_argument "P") 58 IF_FEATURE_UDHCP_PORT("client-port\0" Required_argument "P")
59 ; 59 ;
60#endif 60#endif
@@ -1150,7 +1150,7 @@ static void client_background(void)
1150//usage:# define IF_UDHCP_VERBOSE(...) 1150//usage:# define IF_UDHCP_VERBOSE(...)
1151//usage:#endif 1151//usage:#endif
1152//usage:#define udhcpc_trivial_usage 1152//usage:#define udhcpc_trivial_usage
1153//usage: "[-fbq"IF_UDHCP_VERBOSE("v")IF_FEATURE_UDHCPC_ARPING("a")"RB] [-t N] [-T SEC] [-A SEC/-n]\n" 1153//usage: "[-fbq"IF_UDHCP_VERBOSE("v")"RB]"IF_FEATURE_UDHCPC_ARPING(" [-a[MSEC]]")" [-t N] [-T SEC] [-A SEC/-n]\n"
1154//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-s PROG] [-p PIDFILE]\n" 1154//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-s PROG] [-p PIDFILE]\n"
1155//usage: " [-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]..." 1155//usage: " [-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]..."
1156//usage:#define udhcpc_full_usage "\n" 1156//usage:#define udhcpc_full_usage "\n"
@@ -1174,7 +1174,7 @@ static void client_background(void)
1174//usage: ) 1174//usage: )
1175//usage: "\n -S,--syslog Log to syslog too" 1175//usage: "\n -S,--syslog Log to syslog too"
1176//usage: IF_FEATURE_UDHCPC_ARPING( 1176//usage: IF_FEATURE_UDHCPC_ARPING(
1177//usage: "\n -a,--arping Use arping to validate offered address" 1177//usage: "\n -a[MSEC],--arping[=MSEC] Validate offered address with ARP ping"
1178//usage: ) 1178//usage: )
1179//usage: "\n -r,--request IP Request this IP address" 1179//usage: "\n -r,--request IP Request this IP address"
1180//usage: "\n -o,--no-default-options Don't request any options (unless -O is given)" 1180//usage: "\n -o,--no-default-options Don't request any options (unless -O is given)"
@@ -1211,7 +1211,7 @@ static void client_background(void)
1211//usage: ) 1211//usage: )
1212//usage: "\n -S Log to syslog too" 1212//usage: "\n -S Log to syslog too"
1213//usage: IF_FEATURE_UDHCPC_ARPING( 1213//usage: IF_FEATURE_UDHCPC_ARPING(
1214//usage: "\n -a Use arping to validate offered address" 1214//usage: "\n -a[MSEC] Validate offered address with ARP ping"
1215//usage: ) 1215//usage: )
1216//usage: "\n -r IP Request this IP address" 1216//usage: "\n -r IP Request this IP address"
1217//usage: "\n -o Don't request any options (unless -O is given)" 1217//usage: "\n -o Don't request any options (unless -O is given)"
@@ -1238,6 +1238,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1238{ 1238{
1239 uint8_t *message; 1239 uint8_t *message;
1240 const char *str_V, *str_h, *str_F, *str_r; 1240 const char *str_V, *str_h, *str_F, *str_r;
1241 IF_FEATURE_UDHCPC_ARPING(const char *str_a = "2000";)
1241 IF_FEATURE_UDHCP_PORT(char *str_P;) 1242 IF_FEATURE_UDHCP_PORT(char *str_P;)
1242 void *clientid_mac_ptr; 1243 void *clientid_mac_ptr;
1243 llist_t *list_O = NULL; 1244 llist_t *list_O = NULL;
@@ -1252,6 +1253,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1252 int timeout; /* must be signed */ 1253 int timeout; /* must be signed */
1253 unsigned already_waited_sec; 1254 unsigned already_waited_sec;
1254 unsigned opt; 1255 unsigned opt;
1256 IF_FEATURE_UDHCPC_ARPING(unsigned arpping_ms;)
1255 int max_fd; 1257 int max_fd;
1256 int retval; 1258 int retval;
1257 fd_set rfds; 1259 fd_set rfds;
@@ -1269,7 +1271,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1269 IF_LONG_OPTS(applet_long_options = udhcpc_longopts;) 1271 IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
1270 opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB" 1272 opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB"
1271 USE_FOR_MMU("b") 1273 USE_FOR_MMU("b")
1272 IF_FEATURE_UDHCPC_ARPING("a") 1274 IF_FEATURE_UDHCPC_ARPING("a::")
1273 IF_FEATURE_UDHCP_PORT("P:") 1275 IF_FEATURE_UDHCP_PORT("P:")
1274 "v" 1276 "v"
1275 , &str_V, &str_h, &str_h, &str_F 1277 , &str_V, &str_h, &str_h, &str_F
@@ -1278,6 +1280,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1278 , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */ 1280 , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */
1279 , &list_O 1281 , &list_O
1280 , &list_x 1282 , &list_x
1283 IF_FEATURE_UDHCPC_ARPING(, &str_a)
1281 IF_FEATURE_UDHCP_PORT(, &str_P) 1284 IF_FEATURE_UDHCP_PORT(, &str_P)
1282 IF_UDHCP_VERBOSE(, &dhcp_verbose) 1285 IF_UDHCP_VERBOSE(, &dhcp_verbose)
1283 ); 1286 );
@@ -1309,6 +1312,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1309 SERVER_PORT = CLIENT_PORT - 1; 1312 SERVER_PORT = CLIENT_PORT - 1;
1310 } 1313 }
1311#endif 1314#endif
1315 IF_FEATURE_UDHCPC_ARPING(arpping_ms = xatou(str_a);)
1312 while (list_O) { 1316 while (list_O) {
1313 char *optstr = llist_pop(&list_O); 1317 char *optstr = llist_pop(&list_O);
1314 unsigned n = bb_strtou(optstr, NULL, 0); 1318 unsigned n = bb_strtou(optstr, NULL, 0);
@@ -1726,7 +1730,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1726 NULL, 1730 NULL,
1727 (uint32_t) 0, 1731 (uint32_t) 0,
1728 client_config.client_mac, 1732 client_config.client_mac,
1729 client_config.interface) 1733 client_config.interface,
1734 arpping_ms)
1730 ) { 1735 ) {
1731 bb_info_msg("Offered address is in use " 1736 bb_info_msg("Offered address is in use "
1732 "(got ARP reply), declining"); 1737 "(got ARP reply), declining");