On Fri, Aug 19, 2016 at 4:00 PM, Guus Sliepen <g...@debian.org> wrote: > Hm, that's interesting. Normally, if allow-hotplug is set, the interface > is still brought up using the ifup command, so any if-pre-up.d script > should still be executed before the link is brought up. It should also > never be brought up twice, because ifupdown keeps track of that.
To be specific: "ip link sec <dev> up" is done before ifup is run, which breaks my setup. As far as I can tell, ifup is only executed once. I had another look what goes on with "allow-hotplug" interfaces. They seem to be handled twice during boot: 1. By udev/systemd using net.agent through 80-networking.rules when a new interface is detected. This starts "ifup@.service", which waits for "lo" interface and then calls "ifup --allow=hotplug" for the given interface. Simple enough, and this one brings up my interface. 2. The other one is "/etc/init.d/networking". This scripts brings up all "auto" interfaces. In addition, it sets all hotplug-interfaces to up (using ip link set <dev> up) and checks if there is a link (operstate in sysfs). If there is no link, it does nothing, e.g. ifup is not executed for this interface. This is the code I'm talking about for (2) (from /etc/init.d/networking) ifup_hotplug () { if [ -d /sys/class/net ] then ifaces=$(for iface in $(ifquery --list --allow=hotplug) do link=${iface##:*} link=${link##.*} if [ -e "/sys/class/net/$link" ] then # link detection does not work unless we up the link ip link set "$iface" up || true if [ "$(cat /sys/class/net/$link/operstate)" = up ] then echo "$iface" fi fi done) if [ -n "$ifaces" ] then ifup $ifaces "$@" || true fi fi } IMO the behaviour of (2) is questionable: - How can this link detection ever be true? At least in my ethernet scenario, the link negotiation takes much more time than the delay between "ip link set up" and the link check. - Why is it OK to just not configure that interface when there is no link? How is the link relevant for this? I think /etc/init.d/networking should only bring up "allow-auto" interfaces. The rest is handled nicely by udev and systemd. Please enlighten me why it is done the way it is. :) > The best course of action is just to bring the link down again in the > if-pre-up.d script. That's what is being done in some other pre-up > scripts as well. Thanks for the suggestion! However, I went back to calling ifup directly from my udev rule for the given interface. This seems to work alright.