Message ID | 1446047943-24641-3-git-send-email-jezz@sysmic.org |
---|---|
State | Superseded |
Headers | show |
Jérôme, All, On 2015-10-28 16:59 +0100, Jérôme Pouiller spake thusly: > This patch has same purpose than 49964858f45d2243c513e6d362e992ad89ec7a45: > > On some machines, the network interface is slow to appear. For example, > on the Raspberry Pi, the network interface eth0 is an ethernet-over-USB, > and our standard boot process is too fast, so our network startup script > is called before the USB bus is compeltely enumerated, thus it can't > configure eth0. > > Closes #8116. > > However, it use an optionnal ifupdown hook instead of an initscript. > > Signed-off-by: Jérôme Pouiller <jezz@sysmic.org> > --- > system/skeleton/etc/network/if-pre-up.d/wait_iface | 28 ++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > create mode 100755 system/skeleton/etc/network/if-pre-up.d/wait_iface > > diff --git a/system/skeleton/etc/network/if-pre-up.d/wait_iface b/system/skeleton/etc/network/if-pre-up.d/wait_iface > new file mode 100755 > index 0000000..4f0866b > --- /dev/null > +++ b/system/skeleton/etc/network/if-pre-up.d/wait_iface > @@ -0,0 +1,28 @@ > +#!/bin/sh > + > +# In case we have a slow-to-appear interface (e.g. eth-over-USB), > +# and we need to configure it, wait until it appears, but not too > +# long either. IF_WAIT_DELAY is in seconds. > + > +if [ "${IF_WAIT_DELAY}" ]; then > + Please drop the empty lines. Also, I would have preferred patches 2 & 3 to be folded into a single patch. I don't really understand how it all works: - does the busybox ifup-down and full-fledged ifup-down support wait-delay? - I looked at man 5 interfaces, and there is no mention of wait-delay, - I don't see how 'wait-delay' translates to 'wait_iface' - I guess 'wait-delay' is made an environment variable IF_WAIT_DELAY before the script is run, but I'd have preferred explanations rather than having to guess. Care to shed some light, please? Otherwise, the idea looks fine to me. Thanks! :-) Regards, Yann E. MORIN. > + printf "Waiting for interface %s to appear" "${IFACE}" > + while [ ${IF_WAIT_DELAY} -gt 0 ]; do > + > + if [ -e "/sys/class/net/${IFACE}" ]; then > + > + printf " yes\n" > + exit 0 > + > + fi > + sleep 1 > + printf "." > + > + : $((IF_WAIT_DELAY -= 1)) > + > + done > + printf " no.\n" > + exit 1 > + > +fi > + > -- > 2.1.4 >
Hello Yann, On Wednesday 28 October 2015 18:46:53 Yann E. MORIN wrote: > Jérôme, All, > > On 2015-10-28 16:59 +0100, Jérôme Pouiller spake thusly: [...] > Please drop the empty lines. There were empty lines in original patch ;-). > Also, I would have preferred patches 2 & 3 to be folded into a single > patch. ok. > I don't really understand how it all works: > > - does the busybox ifup-down and full-fledged ifup-down support > wait-delay? Yes, both. > - I looked at man 5 interfaces, and there is no mention of > wait-delay, I have found documentation related to if-*.d scripts in section called "IFACE OPTIONS" of interfaces(5) of my debian. > - I don't see how 'wait-delay' translates to 'wait_iface' From interfaces(5): "Additionally, all options given in an interface definition stanza are exported to the environment in upper case with "IF_" prepended and with hyphens converted to underscores and non-alphanumeric characters discarded." > - I guess 'wait-delay' is made an environment variable IF_WAIT_DELAY > before the script is run, but I'd have preferred explanations rather > than having to guess. > > Care to shed some light, please? Regards,
Jérôme, All, On 2015-10-28 21:21 +0100, Jérôme Pouiller spake thusly: > On Wednesday 28 October 2015 18:46:53 Yann E. MORIN wrote: > > On 2015-10-28 16:59 +0100, Jérôme Pouiller spake thusly: > [...] > > Please drop the empty lines. > There were empty lines in original patch ;-). OK, I see. ;-) Still, please drop them next time, please. [--SNIP--] > > - I looked at man 5 interfaces, and there is no mention of > > wait-delay, > > I have found documentation related to if-*.d scripts in section called > "IFACE OPTIONS" of interfaces(5) of my debian. > > > - I don't see how 'wait-delay' translates to 'wait_iface' > > From interfaces(5): > > "Additionally, all options given in an interface definition stanza are > exported to the environment in upper case with "IF_" prepended and > with hyphens converted to underscores and non-alphanumeric characters > discarded." OK, thanks for the explanations. So there is no relation between the 'stanza' name and the script name, right? Also, I read this in man 5 interfaces; When ifupdown is being called with the --all option, before doing anything to interfaces, if [sic] calls all the hook scripts (pre-up or down) with IFACE set to "--all", LOGICAL set to the current value of --allow parameter (or "auto" if it's not set), ADDRFAM="meta" and METHOD="none". After all the interfaces have been brought up or taken down, the appropriate scripts (up or post-down) are executed. Since S40network calls 'ifup -a' and you added a pre-up script, I guess it should filter out the '--all' interface and exit early in that case. Regards, Yann E. MORIN.
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes: Hi, > Also, I read this in man 5 interfaces; > When ifupdown is being called with the --all option, before doing > anything to interfaces, if [sic] calls all the hook scripts (pre-up > or down) with IFACE set to "--all", LOGICAL set to the current value > of --allow parameter (or "auto" if it's not set), ADDRFAM="meta" > and METHOD="none". After all the interfaces have been brought up or > taken down, the appropriate scripts (up or post-down) are executed. > Since S40network calls 'ifup -a' and you added a pre-up script, I guess > it should filter out the '--all' interface and exit early in that case. As far as I can see from the busybox implementation atleast, -a (all) only causes it to run ifup/ifdown (with IFACE set to the interface name) for each interface listed as auto, so it doesn't do the "--all" thing, but the Debian variant does.
Peter, All, On 2015-10-28 22:51 +0100, Peter Korsgaard spake thusly: > >>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes: > > Also, I read this in man 5 interfaces; > > > When ifupdown is being called with the --all option, before doing > > anything to interfaces, if [sic] calls all the hook scripts (pre-up > > or down) with IFACE set to "--all", LOGICAL set to the current value > > of --allow parameter (or "auto" if it's not set), ADDRFAM="meta" > > and METHOD="none". After all the interfaces have been brought up or > > taken down, the appropriate scripts (up or post-down) are executed. > > > Since S40network calls 'ifup -a' and you added a pre-up script, I guess > > it should filter out the '--all' interface and exit early in that case. > > As far as I can see from the busybox implementation atleast, -a (all) > only causes it to run ifup/ifdown (with IFACE set to the interface name) for > each interface listed as auto, so it doesn't do the "--all" thing, but > the Debian variant does. Since we already have the option to use the full-fledged ifup-down, we should support the case where IFACE=--all in the script. Regards, Yann E. MORIN.
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes: Hi, >> As far as I can see from the busybox implementation atleast, -a (all) >> only causes it to run ifup/ifdown (with IFACE set to the interface name) for >> each interface listed as auto, so it doesn't do the "--all" thing, but >> the Debian variant does. > Since we already have the option to use the full-fledged ifup-down, we > should support the case where IFACE=--all in the script. Yes, agreed - My comment was for information only.
On 28/10/2015 22:37, Yann E. MORIN wrote: > OK, thanks for the explanations. So there is no relation between the > 'stanza' name and the script name, right? None at all. ifupdown just run-parts /etc/if-$PHASE.d/ and the scripts are responsible for not doing anything when they shouldn't. > Also, I read this in man 5 interfaces; > > When ifupdown is being called with the --all option, before doing > anything to interfaces, if [sic] calls all the hook scripts (pre-up > or down) with IFACE set to "--all", LOGICAL set to the current value > of --allow parameter (or "auto" if it's not set), ADDRFAM="meta" > and METHOD="none". After all the interfaces have been brought up or > taken down, the appropriate scripts (up or post-down) are executed. > > Since S40network calls 'ifup -a' and you added a pre-up script, I guess > it should filter out the '--all' interface and exit early in that case. When run in this case, it will have no IF_WAIT_DELAY variable, so the script will not do anything.
On 28/10/2015 16:59, Jérôme Pouiller wrote: > This patch has same purpose than 49964858f45d2243c513e6d362e992ad89ec7a45: > > On some machines, the network interface is slow to appear. For example, > on the Raspberry Pi, the network interface eth0 is an ethernet-over-USB, > and our standard boot process is too fast, so our network startup script > is called before the USB bus is compeltely enumerated, thus it can't > configure eth0. > > Closes #8116. > > However, it use an optionnal ifupdown hook instead of an initscript. > > Signed-off-by: Jérôme Pouiller <jezz@sysmic.org> > --- > system/skeleton/etc/network/if-pre-up.d/wait_iface | 28 ++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > create mode 100755 system/skeleton/etc/network/if-pre-up.d/wait_iface > > diff --git a/system/skeleton/etc/network/if-pre-up.d/wait_iface b/system/skeleton/etc/network/if-pre-up.d/wait_iface > new file mode 100755 > index 0000000..4f0866b > --- /dev/null > +++ b/system/skeleton/etc/network/if-pre-up.d/wait_iface > @@ -0,0 +1,28 @@ > +#!/bin/sh > + > +# In case we have a slow-to-appear interface (e.g. eth-over-USB), > +# and we need to configure it, wait until it appears, but not too > +# long either. IF_WAIT_DELAY is in seconds. > + > +if [ "${IF_WAIT_DELAY}" ]; then > + > + printf "Waiting for interface %s to appear" "${IFACE}" I think we shouldn't print this scary message when the interface already exist in the first place... I was suggesting to only do it if VERBOSITY=1 but busybox does not support that. > + while [ ${IF_WAIT_DELAY} -gt 0 ]; do > + > + if [ -e "/sys/class/net/${IFACE}" ]; then > + > + printf " yes\n" So this prints: "Waiting for interface dummy0 to appear..... yes" or "Waiting for interface dummy0 to appear............... no" We should maybe just print a new line on success and an explicit error message on failure. > + exit 0 > + > + fi > + sleep 1 > + printf "." > + > + : $((IF_WAIT_DELAY -= 1)) > + > + done > + printf " no.\n" > + exit 1 > + > +fi > + >
diff --git a/system/skeleton/etc/network/if-pre-up.d/wait_iface b/system/skeleton/etc/network/if-pre-up.d/wait_iface new file mode 100755 index 0000000..4f0866b --- /dev/null +++ b/system/skeleton/etc/network/if-pre-up.d/wait_iface @@ -0,0 +1,28 @@ +#!/bin/sh + +# In case we have a slow-to-appear interface (e.g. eth-over-USB), +# and we need to configure it, wait until it appears, but not too +# long either. IF_WAIT_DELAY is in seconds. + +if [ "${IF_WAIT_DELAY}" ]; then + + printf "Waiting for interface %s to appear" "${IFACE}" + while [ ${IF_WAIT_DELAY} -gt 0 ]; do + + if [ -e "/sys/class/net/${IFACE}" ]; then + + printf " yes\n" + exit 0 + + fi + sleep 1 + printf "." + + : $((IF_WAIT_DELAY -= 1)) + + done + printf " no.\n" + exit 1 + +fi +
This patch has same purpose than 49964858f45d2243c513e6d362e992ad89ec7a45: On some machines, the network interface is slow to appear. For example, on the Raspberry Pi, the network interface eth0 is an ethernet-over-USB, and our standard boot process is too fast, so our network startup script is called before the USB bus is compeltely enumerated, thus it can't configure eth0. Closes #8116. However, it use an optionnal ifupdown hook instead of an initscript. Signed-off-by: Jérôme Pouiller <jezz@sysmic.org> --- system/skeleton/etc/network/if-pre-up.d/wait_iface | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 system/skeleton/etc/network/if-pre-up.d/wait_iface