PATCH: udhcpc -- don't request set of options by default

Denys Vlasenko vda.linux at googlemail.com
Tue Apr 1 16:11:02 PDT 2008


On Wednesday 02 April 2008 00:37, L. Gabriel Somlo wrote:
> I agree with your no_ifup blurb in principle. However, this is not
> about ifupdown at all (adding a way to pass no-default-options to
> udhcpc from ifupdown was an afterthought since I happen to use
> ifupdown, but totally unrelated to the udhcpc sample script).
> 
> The real question is, who "wins" w.r.t. /etc/resolv.conf when multiple
> dhcp-configured interfaces are up simultaneously ? This is already a
> fun problem for laptops that connect both on wireless and on wired
> ethernet, and it's a trainwreck, ifupdown or not...

I though I explained it on that page...


my DHCP client's script basically just dumps obtained into in a file
in this form:

/var/run/service/fw/dhcp_if.ipconf
==============
let cfg=cfg+1
if[$cfg]='if'
ip[$cfg]='89.102.207.196'
ipmask[$cfg]='89.102.207.196/24'
gw[$cfg]='89.102.207.1'
dns[$cfg]='213.46.172.36 213.46.172.37'
net[$cfg]='0/0'

and then executes "sv u /var/service/fw"
(sv is a busybox applet, works in concert with runsv).

/var/service/fw is a runsv-controlled service
with service script which starts as:

/var/service/fw/run:
===================
#!/bin/sh
# Make ourself one-shot
sv o . <================ CRUCIAL
...

I will omit the details. Important things are:

*  /var/service/fw/run is ran _anytime_ network config is changed,
   and it sees _entire_ config state. For example, it can go through
   /var/run/service/fw/*.ipconf
   files and find out ALL INTERFACES' addresses; this does not cover
   only dhcp, but pppd, openvpn, you name it (and of course static ones).

*  this script cat decide _globally_ what to write to /etc/resolv.conf
   [and there is no need to save it], what will be set as default route,
   how to configure DNS, NTP, firewall, trafic shaping, etc....

*  Execution of /var/service/fw/run is _serialized_ (by nature how
   "sv u" + "sv o" interact). If many dhcpc's, openvpn's, pppd's
   etc are racing to run it, it can be executed several times,
   but NEVER IN PARALLEL.
   (basically, if e.g. openvpn does "sv u /var/service/fw" while
   it still runs because of earlier dhcp config, it will rerun again...
   ...and set itself to "one shot, do not rerun until 'sv upped' again"
   mode with that "sv o ." cmd).

Yes, the script can get complex, but it does not need to worry about races,
and therefore conceptually it is simple:

* Lets take a look at the state of ALL links and decide what to do.
* Deconfigure everything:
  ip a f dev $EVERY_IF
  ip r f dev $EVERY_IF root 0/0
  iptables           --flush
  iptables           --delete-chain
  iptables -t nat    --flush
  iptables -t nat    --delete-chain
  iptables -t mangle --flush
  iptables -t mangle --delete-chain
  ...
* Configure everything back.

You can try and play with "if changes are small, dont deconf everything"
but I don't find it useful - script gets more complex.
--
vda


More information about the busybox mailing list