ifupdown-ng-waitif

An ifupdown-ng executor which blocks until the interface is actually running

git clone https://git.8pit.net/ifupdown-ng-waitif.git

 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].
17
18## Installation
19
20In order to build this software, install the following dependencies:
21
22* [libmnl][libmnl web]
23* [GNU make][make web]
24
25Afterwards, run the following commands:
26
27	$ make
28	# make install
29
30Refer to the `GNUmakefile` regarding available configuration variables.
31
32## Usage
33
34In order to use this executor, add a `use waitif` declaration to your interface configuration in `/etc/network/interfaces`.
35For example:
36
37	iface wlan0
38		use waitif
39		use dhcp
40
41In 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:
46
47	iface wlan0
48		waitif-timeout 10
49		use waitif
50		use dhcp
51
52The `waitif-timeout` keyword specifies a timeout in seconds, the timeout can be set to zero to wait indefinitely.
53
54## Caveats
55
56ifupdown-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].
59
60## License
61
62This program is free software: you can redistribute it and/or modify it
63under the terms of the GNU General Public License as published by the
64Free Software Foundation, either version 3 of the License, or (at your
65option) any later version.
66
67This program is distributed in the hope that it will be useful, but
68WITHOUT ANY WARRANTY; without even the implied warranty of
69MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
70Public License for more details.
71
72You should have received a copy of the GNU General Public License along
73with this program. If not, see <http://www.gnu.org/licenses/>.
74
75[ifupdown-ng github]: https://github.com/ifupdown-ng/ifupdown-ng
76[ifupdown-ng executor]: https://github.com/ifupdown-ng/ifupdown-ng/blob/ce6954d62879c3532697a5b0cd800a506fae9da6/doc/ifupdown-executor.scd
77[ifupdown-ng phases]: https://github.com/ifupdown-ng/ifupdown-ng/blob/ce6954d62879c3532697a5b0cd800a506fae9da6/doc/ifupdown-executor.scd#phases
78[alpine #13795]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13795
79[bncm-waitif web]: https://skarnet.org/software/bcnm/bcnm-waitif.html
80[netlink wikipedia]: https://en.wikipedia.org/wiki/Netlink
81[libmnl web]: https://netfilter.org/projects/libmnl/
82[make web]: https://github.com/rocky/remake
83[ifupdown-ng #179]: https://github.com/ifupdown-ng/ifupdown-ng/pull/179