udhcpd wait for interface has an ip

Roberto A. Foglietta roberto.foglietta at gmail.com
Wed Aug 9 21:42:38 UTC 2023


Hi all,

 I am dealing with busybox udhcpd and I discovered that there is not
an option that makes this daemon - especially in combination with -f
option - wait until the interface receives an IP. Something like -w,
for example.

 At the moment, I solved in this way:

ExecStartPre=/bin/sh -c "while ! /usr/sbin/ip -4 a | /bin/grep -q
rndis0:; do /bin/sleep 1; done"

 However, this implies to use --no-block with systemctl re/start and
it is a potentially critical shortcoming because this option is not
the default.

udhcpd: is interface rndis0 up and configured?: Cannot assign requested address

 I am puzzled because I think that it is not an uncommon issue waiting
for an interface that will come up soon or later. Moreover, at first
glance, it would not a pain to add that option in
networking/udhcp/dhcpd.c:958

== untested and uncompiled code, just for example ==

again:
    if (udhcp_read_interface(server_data.interface,
            &server_data.ifindex,
            (server_data.server_nip == 0 ? &server_data.server_nip : NULL),
            server_data.server_mac)
    ) {
        if(wait_for_interface) {
            sleep(1);
            goto again;
        }
        retval = 1;
        goto ret;
    }

Possibly, I have overlooked something. Otherwise, I can implement this
feature. Just let me know.


More information about the busybox mailing list