1## Status 2 3This software integrates [ifupdown-ng][ifupdown-ng github] with [netlink][netlink wikipedia] link state detection via [libmnl][libmnl web]. 4I use this software myself and I am presently not aware of any bugs with the implemented functionality. 5 6## Background 7 8[ifupdown-ng][ifupdown-ng github] is a re-implementation of the `ifup` and `ifdown` commands provided by Debian and BusyBox. 9These commands configure network interfaces according to the `/etc/network/interfaces` configuration file.10Interface configuration is split into multiple [phases][ifupdown-ng phases].11For each phase, different [executors][ifupdown-ng executor] are run.12For example, a DHCP client may be run as an executor in the `up` phase.13Unfortunately, ifupdown-ng doesn't check the interface link state before running executors of the `up` phase.14As such, executors which require the link to be up (e.g. the DHCP executor) usually retry requests in a configured interval until the requests succeed.15As it turns out, choosing an appropriate interval is [difficult][alpine #13795].16Inspired by [bncm-waitif][bncm-waitif web], this repository provides an executor which blocks until the interface state is changed to running by the Linux [netlink subsystem][netlink wikipedia].1718## Installation1920In order to build this software, install the following dependencies:2122* [libmnl][libmnl web]23* [GNU make][make web]2425Afterwards, run the following commands:2627 $ make28 # make install2930Refer to the `GNUmakefile` regarding available configuration variables.3132## Usage3334In order to use this executor, add a `use waitif` declaration to your interface configuration in `/etc/network/interfaces`.35For example:3637 iface wlan038 use waitif39 use dhcp4041In this case, the `waitif` executor will block in the `up` phase until the interface switched to the `IFF_RUNNING` state.42Afterwards, the `dhcp` executor is run and it will hopefully be able to retrieve a lease immediately.43By default, the `waitif` executor will wait for up to 30 seconds for the interface to come up.44If the interface doesn't change to `IFF_RUNNING` within this timespan, then the `waitif` executor exits with `EXIT_FAILURE`.45It is possible to configure a different timeout value using `waitif-timeout`, for example:4647 iface wlan048 waitif-timeout 1049 use waitif50 use dhcp5152The `waitif-timeout` keyword specifies a timeout in seconds, the timeout can be set to zero to wait indefinitely.5354## Caveats5556ifupdown-ng currently does not stop executing executors of a given phase if one of them fails.57As such, if the `waitif` up executor fails (e.g. due to a timeout) ifupdown-ng will still attempt to retrieve a DCHP lease.58See: [ifupdown-ng#179][ifupdown-ng #179].5960## License6162This program is free software: you can redistribute it and/or modify it63under the terms of the GNU General Public License as published by the64Free Software Foundation, either version 3 of the License, or (at your65option) any later version.6667This program is distributed in the hope that it will be useful, but68WITHOUT ANY WARRANTY; without even the implied warranty of69MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General70Public License for more details.7172You should have received a copy of the GNU General Public License along73with this program. If not, see <http://www.gnu.org/licenses/>.7475[ifupdown-ng github]: https://github.com/ifupdown-ng/ifupdown-ng76[ifupdown-ng executor]: https://github.com/ifupdown-ng/ifupdown-ng/blob/ce6954d62879c3532697a5b0cd800a506fae9da6/doc/ifupdown-executor.scd77[ifupdown-ng phases]: https://github.com/ifupdown-ng/ifupdown-ng/blob/ce6954d62879c3532697a5b0cd800a506fae9da6/doc/ifupdown-executor.scd#phases78[alpine #13795]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/1379579[bncm-waitif web]: https://skarnet.org/software/bcnm/bcnm-waitif.html80[netlink wikipedia]: https://en.wikipedia.org/wiki/Netlink81[libmnl web]: https://netfilter.org/projects/libmnl/82[make web]: https://github.com/rocky/remake83[ifupdown-ng #179]: https://github.com/ifupdown-ng/ifupdown-ng/pull/179