]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
netifd: expose udhcpc timeout/retry/tryagain UCI options in dhcp.sh
authorJohn Crispin <john@phrozen.org>
Thu, 16 Apr 2026 12:26:11 +0000 (14:26 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 24 Jun 2026 09:21:28 +0000 (11:21 +0200)
proto/dhcp.sh hardcoded `-t 0` (infinite retries) with no way
for UCI / operator to tune per-retry interval (udhcpc -T),
retry count (udhcpc -t) or failure retry-loop wait (udhcpc -A).
Add three new proto config ints (timeout, retry, tryagain)
and thread them into the udhcpc command line. Unset options
preserve existing behaviour: retry defaults to 0, timeout and
tryagain are omitted so udhcpc uses its own RFC defaults.

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/config/netifd/files/lib/netifd/proto/dhcp.sh

index 5d8e0dda5e3898fb1ea4c0f2c210cb2a3035bdd1..5765efffaa042c2cb1d56bc1093cc06c6fa18484 100755 (executable)
@@ -28,6 +28,9 @@ proto_dhcp_init_config() {
        proto_config_add_string mtu6rd
        proto_config_add_string customroutes
        proto_config_add_boolean classlessroute
+       proto_config_add_int timeout
+       proto_config_add_int retry
+       proto_config_add_int tryagain
 }
 
 proto_dhcp_add_sendopts() {
@@ -55,8 +58,8 @@ proto_dhcp_setup() {
        local config="$1"
        local iface="$2"
 
-       local ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
-       json_get_vars ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute
+       local ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute timeout retry tryagain
+       json_get_vars ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute timeout retry tryagain
 
        local opt dhcpopts
        for opt in $reqopts; do
@@ -102,7 +105,9 @@ proto_dhcp_setup() {
        proto_run_command "$config" udhcpc \
                -p /var/run/udhcpc-$iface.pid \
                -s /lib/netifd/dhcp.script \
-               -f -t 0 -i "$iface" \
+               -f -t "${retry:-0}" -i "$iface" \
+               ${timeout:+-T "$timeout"} \
+               ${tryagain:+-A "$tryagain"} \
                ${ipaddr:+-r ${ipaddr/\/*/}} \
                ${hostname:+-x "hostname:$hostname"} \
                ${emptyvendorid:+-V ""} \