[OpenWrt-Devel] [PATCH] busybox: add option for tweaking arpping to udhcpd
Michel Stam
m.stam at fugro.nl
Thu Oct 2 09:39:07 EDT 2014
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.
Signed-off-by: Michel Stam <m.stam at fugro.nl>
---
package/utils/busybox/Config-defaults.in | 6 ++
.../busybox/config/networking/udhcp/Config.in | 20 ++++++
.../utils/busybox/patches/245-udhcp_arpping.patch | 73 ++++++++++++++++++++++
3 files changed, 99 insertions(+)
create mode 100644 package/utils/busybox/patches/245-udhcp_arpping.patch
diff --git a/package/utils/busybox/Config-defaults.in b/package/utils/busybox/Config-defaults.in
index 5f5bdd0..dfed895 100644
--- a/package/utils/busybox/Config-defaults.in
+++ b/package/utils/busybox/Config-defaults.in
@@ -2221,6 +2221,9 @@ config BUSYBOX_DEFAULT_FEATURE_UDHCPD_WRITE_LEASES_EARLY
config BUSYBOX_DEFAULT_FEATURE_UDHCPD_BASE_IP_ON_MAC
bool
default n
+config BUSYBOX_DEFAULT_FEATURE_UDHCPD_ARPPING
+ bool
+ default y
config BUSYBOX_DEFAULT_DHCPD_LEASES_FILE
string
default ""
@@ -2236,6 +2239,9 @@ config BUSYBOX_DEFAULT_FEATURE_UDHCP_PORT
config BUSYBOX_DEFAULT_UDHCP_DEBUG
int
default 0
+config BUSYBOX_DEFAULT_UDHCP_ARPPING_TIMEOUT
+ int
+ default 2000
config BUSYBOX_DEFAULT_FEATURE_UDHCP_RFC3397
bool
default y
diff --git a/package/utils/busybox/config/networking/udhcp/Config.in b/package/utils/busybox/config/networking/udhcp/Config.in
index 576a01a..b6f84d1 100644
--- a/package/utils/busybox/config/networking/udhcp/Config.in
+++ b/package/utils/busybox/config/networking/udhcp/Config.in
@@ -61,6 +61,16 @@ config BUSYBOX_CONFIG_FEATURE_UDHCPD_BASE_IP_ON_MAC
for the same client to (almost always) contain the same
IP address.
+config BUSYBOX_CONFIG_FEATURE_UDHCPD_ARPPING
+ bool "arpping addresses before offering"
+ default BUSYBOX_DEFAULT_FEATURE_UDHCPD_ARPPING
+ depends on BUSYBOX_CONFIG_UDHCPD
+ help
+ If selected, udhcpd will perform an arpping before offering an
+ address for a lease.
+
+ This increases server response time.
+
config BUSYBOX_CONFIG_DHCPD_LEASES_FILE
string "Absolute path to lease file"
default BUSYBOX_DEFAULT_DHCPD_LEASES_FILE
@@ -110,6 +120,16 @@ config BUSYBOX_CONFIG_UDHCP_DEBUG
Bigger values result in bigger code. Levels above 1
are very verbose and useful for debugging only.
+config BUSYBOX_CONFIG_UDHCP_ARPPING_TIMEOUT
+ int "Timeout in msec for arppings sent"
+ default BUSYBOX_DEFAULT_UDHCP_ARPPING_TIMEOUT
+ depends on BUSYBOX_CONFIG_FEATURE_UDHCPC_ARPING || BUSYBOX_CONFIG_FEATURE_UDHCPD_ARPPING
+ help
+ Set the number of milliseconds to wait for arppings
+ to timeout.
+
+ Bigger values result in an increase in response time.
+
config BUSYBOX_CONFIG_FEATURE_UDHCP_RFC3397
bool "Support for RFC3397 domain search (experimental)"
default BUSYBOX_DEFAULT_FEATURE_UDHCP_RFC3397
diff --git a/package/utils/busybox/patches/245-udhcp_arpping.patch b/package/utils/busybox/patches/245-udhcp_arpping.patch
new file mode 100644
index 0000000..91f86ee
--- /dev/null
+++ b/package/utils/busybox/patches/245-udhcp_arpping.patch
@@ -0,0 +1,73 @@
+diff -r -U 3 -p busybox-1.19.4/networking/udhcp/Config.src busybox-1.19.4/networking/udhcp/Config.src
+--- busybox-1.19.4/networking/udhcp/Config.src 2012-02-04 20:24:55.000000000 +0100
++++ busybox-1.19.4/networking/udhcp/Config.src 2014-05-02 14:22:49.389127249 +0200
+@@ -55,6 +55,16 @@ config FEATURE_UDHCPD_BASE_IP_ON_MAC
+ for the same client to (almost always) contain the same
+ IP address.
+
++config FEATURE_UDHCPD_ARPPING
++ bool "arpping addresses before offering"
++ default y
++ depends on UDHCPD
++ help
++ If selected, udhcpd will perform an arpping before offering an
++ address for a lease.
++
++ This increases server response time.
++
+ config DHCPD_LEASES_FILE
+ string "Absolute path to lease file"
+ default "/var/lib/misc/udhcpd.leases"
+@@ -104,6 +114,16 @@ config UDHCP_DEBUG
+ Bigger values result in bigger code. Levels above 1
+ are very verbose and useful for debugging only.
+
++config UDHCP_ARPPING_TIMEOUT
++ int "Timeout in msec for arppings sent"
++ default 2000
++ depends on FEATURE_UDHCPC_ARPPING || FEATURE_UDHCPD_ARPPING
++ help
++ Set the number of milliseconds to wait for arppings
++ to timeout.
++
++ Bigger values result in an increase in response time.
++
+ config FEATURE_UDHCP_RFC3397
+ bool "Support for RFC3397 domain search (experimental)"
+ default y
+diff -r -U 3 -p busybox-1.19.4/networking/udhcp/arpping.c busybox-1.19.4/networking/udhcp/arpping.c
+--- busybox-1.19.4/networking/udhcp/arpping.c 2012-02-04 20:24:55.000000000 +0100
++++ busybox-1.19.4/networking/udhcp/arpping.c 2014-05-02 14:22:49.389127249 +0200
+@@ -83,7 +83,7 @@ int FAST_FUNC arpping(uint32_t test_nip,
+ }
+
+ /* wait for arp reply, and check it */
+- timeout_ms = 2000;
++ timeout_ms = CONFIG_UDHCP_ARPPING_TIMEOUT;
+ do {
+ typedef uint32_t aliased_uint32_t FIX_ALIASING;
+ int r;
+diff -r -U 3 -p busybox-1.19.4/networking/udhcp/leases.c busybox-1.19.4/networking/udhcp/leases.c
+--- busybox-1.19.4/networking/udhcp/leases.c 2012-02-04 20:24:55.000000000 +0100
++++ busybox-1.19.4/networking/udhcp/leases.c 2014-05-02 14:23:51.000957796 +0200
+@@ -112,8 +112,9 @@ struct dyn_lease* FAST_FUNC find_lease_b
+ }
+
+ /* Check if the IP is taken; if it is, add it to the lease table */
+-static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac)
++static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac UNUSED_PARAM)
+ {
++#if ENABLE_FEATURE_UDHCPD_ARPPING
+ struct in_addr temp;
+ int r;
+
+@@ -129,6 +130,9 @@ static int nobody_responds_to_arp(uint32
+ inet_ntoa(temp), (unsigned)server_config.conflict_time);
+ add_lease(NULL, nip, server_config.conflict_time, NULL, 0);
+ return 0;
++#else
++ return 1;
++#endif
+ }
+
+ /* Find a new usable (we think) address */
--
1.7.12.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list