If you have a bonding interface with an interface and the same interface with a vlan interface, eg: eth1 and eth1.2020 OpenRC's bonding.sh will first ensure that these interfaces are down but when it adds eth1 to the slave the interface eth1.2020 will also get up. Reproducible: Always Steps to Reproduce: 1. create a bond named bond0 with eth2 and eth2.2020 2. restart bond0 interface 3. you will see /lib/rc/net/bonding.sh: line 108: echo: write error: Operation not permitted [ !! ] Actual Results: Error and bond0 only containing eth2 Expected Results: No errors and bond0 containing eth2 and eth2.2020 I think the interface should explicitly be set to down before it adds it to the bonding interface. For example: for s in ${slaves}; do [ "${s}" = "${primary}" ] && continue if ! grep -q ${s} $sys_bonding_path/slaves; then ( # Fix for: http://forums.gentoo.org/viewtopic-p-6879612.html#6879612 IFACE="${s}" _down ) echo "+${s}" >$sys_bonding_path/slaves fi done
Can you please attach the patch as a unified diff so that I can apply it? Patches put inline in comments cannot be applied to the code. Thanks, William
Created attachment 295565 [details, diff] Bring interface down before adding it as a slave interface This makes sure that interfaces are in down state before it is added as a slave. This fixes that interfaces with vlan tags become in the up state if the original interface is added first.
I have committed a variant of your patch to the Git tree (you had missed the case of a primary slave).
Can this be made optional/configurable? This fix breaks functionality for me. I have a setup on a laptop that bonds the wireless and wired interfaces (allows plugging in the wired for speed and unplugging without losing connections). I rely on the wireless interface being up when postup for the bonding interface is configured so I can copy the wireless config to the bonding interface. The patch that fixes this bug brings the wireless interface down, so I lose the ESSID I need for doing the configuration. Also, the postup function for bond0 is now being called with eth0 (I assume the last slave) instead of bond0. This worked fine in 0.9.7.
(In reply to comment #4) > Can this be made optional/configurable? This fix breaks functionality for me. > I have a setup on a laptop that bonds the wireless and wired interfaces (allows > plugging in the wired for speed and unplugging without losing connections). I > rely on the wireless interface being up when postup for the bonding interface > is configured so I can copy the wireless config to the bonding interface. The > patch that fixes this bug brings the wireless interface down, so I lose the > ESSID I need for doing the configuration. > > Also, the postup function for bond0 is now being called with eth0 (I assume the > last slave) instead of bond0. This worked fine in 0.9.7. Is your interface not already being set to down state by the following code?: 87 # Must force the slaves to a particular state before adding them 88 for IFACE in ${slaves}; do 89 _delete_addresses 90 _down 91 done Maybe post your /etc/conf.d/net. Also my patch contained a parenthesis around the _down function to avoid overriding the IFACE variable. Should be easy to change it to change IFACE=$s _down to: (IFACE=$s _down)
(In reply to comment #5) > Is your interface not already being set to down state by the following code?: > 87 # Must force the slaves to a particular state before adding them > 88 for IFACE in ${slaves}; do > 89 _delete_addresses > 90 _down > 91 done Yes, his interface should have already been down due to that, unless it failed the exists check before that? > Maybe post your /etc/conf.d/net. Agreed. > Also my patch contained a parenthesis around the _down function to avoid > overriding the IFACE variable. > > Should be easy to change it to change > > IFACE=$s _down > > to: > > (IFACE=$s _down) You don't need that at all. The IFACE var change is only for the scope of the function call. Testcase to prove it: ==== foo() { echo foo:$IFACE } IFACE=1 foo IFACE=2 foo foo ==== will output: ==== foo:1 foo:2 foo:1 ====
Created attachment 298675 [details] Example conf.d/net script Ok, so under further testing it looks like it is more the issue of postup being called with the wrong interface name (even under 0.9.6, the wireless interface would go down, but now I think bringing it into the bond0 will bring it back up and make it re-associate). I commented out the "IFACE=$slave _down" line and it does fix the postup issue. While I agree that it shouldn't go beyond that statement, it apparently does. You can even see the difference if you do /etc/init.d/net.bond0 -d start. Also, putting the parentheses around the statement does fix the problem.
(In reply to comment #7) > commented out the "IFACE=$slave _down" line and > it does fix the postup issue. While I agree that it shouldn't go beyond that > statement, it apparently does. Around "IFACE=$slave _down", can you please change it to this: einfo "Debug 1 IFACE=$IFACE" IFACE=$slave _down einfo "Debug 2 IFACE=$IFACE" And attach the output of: /etc/init.d/net.bond0 --verbose start (from a clean boot/ with all interfaces down).
(In reply to comment #8) > (In reply to comment #7) > > commented out the "IFACE=$slave _down" line and > > it does fix the postup issue. While I agree that it shouldn't go beyond that > > statement, it apparently does. > Around "IFACE=$slave _down", can you please change it to this: > einfo "Debug 1 IFACE=$IFACE" > IFACE=$slave _down > einfo "Debug 2 IFACE=$IFACE" > > And attach the output of: > /etc/init.d/net.bond0 --verbose start (from a clean boot/ with all interfaces > down). What that (fixed from $slave to $s): * Debug 1 IFACE=bond0 * Debug 2 IFACE=eth1 * Debug 1 IFACE=eth1 * Debug 2 IFACE=eth0 Whereas putting it in parentheses: * Debug 1 IFACE=bond0 * Debug 2 IFACE=bond0 * Debug 1 IFACE=bond0 * Debug 2 IFACE=bond0 Note that I had to bring up eth1 (wireless) first to get this output, because trying to start bond0 directly will cause eth1 to start (I have rc_net_bond0_need="net.eth1" in /etc/rc.conf), which then says it's being backgrounded and the rest of the output is suppressed: * Backgrounding ... ... * WARNING: net.eth1 has started, but is inactive * WARNING: net.bond0 is scheduled to start when net.eth1 has started I wish there was a way to prevent it from backgrounding, but I haven't found it.