Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 391881 - sys-apps/openrc-0.8.3-r1: bonding.sh tries to add interface that can be up
Summary: sys-apps/openrc-0.8.3-r1: bonding.sh tries to add interface that can be up
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: OpenRC Team
URL: http://forums.gentoo.org/viewtopic-p-...
Whiteboard: openrc:oldnet
Keywords:
Depends on:
Blocks: openrc-tracker
  Show dependency tree
 
Reported: 2011-11-25 17:41 UTC by Yun Zheng Hu
Modified: 2013-04-25 23:08 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Bring interface down before adding it as a slave interface (bonding_patch_391881.patch,351 bytes, patch)
2011-12-12 14:36 UTC, Yun Zheng Hu
Details | Diff
Example conf.d/net script (net,1.54 KB, text/plain)
2012-01-11 21:59 UTC, Kevin Bryan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yun Zheng Hu 2011-11-25 17:41:12 UTC
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
Comment 1 William Hubbs gentoo-dev 2011-12-10 22:50:37 UTC
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
Comment 2 Yun Zheng Hu 2011-12-12 14:36:06 UTC
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.
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2011-12-13 02:54:00 UTC
I have committed a variant of your patch to the Git tree (you had missed the case of a primary slave).
Comment 4 Kevin Bryan 2012-01-11 15:49:49 UTC
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.
Comment 5 Yun Zheng Hu 2012-01-11 16:24:05 UTC
(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)
Comment 6 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2012-01-11 18:33:34 UTC
(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
====
Comment 7 Kevin Bryan 2012-01-11 21:59:31 UTC
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.
Comment 8 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2012-01-12 06:19:20 UTC
(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).
Comment 9 Kevin Bryan 2012-01-12 19:58:49 UTC
(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.