[PATCH] ifupdown: post-down scripts don't get called when avahi-autoipd is used

Jeroen De Wachter jeroen.dewachter at barco.com
Tue May 4 10:13:24 UTC 2010


Denys Vlasenko wrote:
> On Thursday 22 April 2010 10:05, Jeroen De Wachter wrote:
>   
>> Denys Vlasenko wrote:
>>     
>>> On Wed, Apr 21, 2010 at 11:16 AM,  <jeroen.dewachter at barco.com> wrote:
>>>   
>>>       
>>>> From: Jeroen De Wachter <jedw at sleipner.barco.com>
>>>>
>>>> when ifdown gets called on a configuration that uses DHCP, it
>>>> kills the udhcpc client by killing the process with the id in
>>>> the udhcpc pid file (/var/run/udhcpc.%iface%.pid)
>>>>
>>>> However, when avahi-autoipd is in play, that pid file does not
>>>> exist (due to a modified /usr/share/udhcpc/default.script that
>>>> launches the avahi autoipd stuff) and killing the process
>>>> fails.
>>>>
>>>> Due to the way iface_down is written:
>>>>
>>>> static int iface_down(struct interface_defn_t *iface)
>>>> {
>>>>    if (!iface->method->down(iface,check)) return -1;
>>>>    set_environ(iface, "stop");
>>>>    if (!execute_all(iface, "down")) return 0;
>>>>    if (!iface->method->down(iface, doit)) return 0; // <-- returns prematurely
>>>>    if (!execute_all(iface, "post-down")) return 0;
>>>>    return 1;
>>>> }
>>>>
>>>> the post-down scripts are no longer executed, even though
>>>> nothing has actually gone wrong...
>>>>     
>>>>         
>>> I do not want to add more special cases to ifupdown.
>>> There is a potentially infinite number of them.
>>> Use something better than ifupdown.
>>>   
>>>       
>> How is this a special case?
>> "If the pid file does not exists, don't try to read it...", is basically 
>> my change
>>     
>
> How about this then?
>
>         result = execute(
>                 "test -f /var/run/udhcpc.%iface%.pid && "
>                 "kill `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
>                 ifd, exec);
>   
Yes, that would be fine by me, although the wait call will still be 
there, delaying execution for no reason in some cases

It might be worth mentioning that I found a way around this problem in 
the meantime.
The options that are passed to udhcpc by default (-R -n) have it return 
an error code if it can't get an IP right away.
We are now using -R -b, which means udhcpc always returns a 0 status 
(which means the ifup scripts will get called) and goes into the 
background if getting an IP fails initially.
This also means ifdown always has a pid file to read and always has a 
process to kill so ifdown scripts will be called too.

I don't know if the -R -n flags are busybox defaults or if they are just 
imposed by buildroot though, so check your configuration if you're going 
to try this.

Still, you can't expect every user to use the same options with udhcpc, 
so the change is still necessary, imo


DISCLAIMER:
Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you.


More information about the busybox mailing list