aboutsummaryrefslogtreecommitdiffstats
bcnm: the bcnm-waitif program

bcnm
Software
skarnet.org

The bcnm-waitif program

bcnm-waitif waits until a set of network interfaces are in the desired state, or a timeout occurs. Then it exits. It is typically used to avoid race conditions in a service startup sequence.

Interface

     bcnm-waitif [ -u | -d ] [ -t timeout ] [ -k kbufsize ] mask interface...
  • bcnm-waitif reads the state of all the interfaces specified by name as the interface... arguments.
  • If all the listed interfaces match the state defined in mask, it exits 0.
  • Else, it waits for network interface state changes, and performs the check again.
  • It loops until all the listed interfaces are in the desired state, or a timeout (if defined) occurs.

mask meaning

mask is an unsigned integer representing a bitmask for the flags to be tested. If several bits are given, the wanted state is the conjunction of these flags: the condition will be true if all those checks pass.

  • 1: the interface exists (the kernel knows about it)
  • 2: the interface is UP (the administrator has activated it)
  • 4: the interface is RUNNING (functional, not unplugged)

Options

  • -u : up. bcnm-waitif will wait until all the states defined in mask are reached by all the interfaces in interface.... This is the default.
  • -d : down. bcnm-waitif will wait until none of the states defined in mask is true.
  • -t timeout : if the desired state still has not been reached after timeout milliseconds, bcnm-waitif will exit 99 with an error message. The default is 0, meaning there is no timeout and the program can wait forever.
  • -k kbufsize : use kbufsize bytes for the netlink socket buffer. Too small a buffer risks losing state change events and reporting incorrect results. Too large a buffer wastes memory. Default is 131072, which is probably on the large side.

Exit codes

  • 0: success
  • 99: timed out
  • 100: wrong usage
  • 111: system call failed