There was a request in this thread for a little more detail on how the
bonding sysfs interface works.  I have been running this set of patches
in a test environment so am familiar enough with the interface that I
should be able to give a brief explanation.  Here goes...

-----

This version of bonding exports a sysfs interface.  Loading the module
will create a file named bonding_masters and a directory for each bond
in the system in the sysfs net directory, /sys/class/net/.  For
instance, loading the module with default settings will add the
following items to the /sys/class/net directory:

drwxr-xr-x   4 root root    0 Jul  6 12:56 bond0
-rw-r--r--   1 root root 4096 Jul  6 12:56 bonding_masters

The /sys/class/net/bonding_masters file contains the name of each bond
in the file, hence after loading the module:

testbox:~ # cat /sys/class/net/bonding_masters
bond0
testbox:~ # 

The bonding configuration can be changed by echoing a new value into the
bonding_masters file.  The following line will add a bond named bond1 to
the system:

testbox:~ # echo bond0 bond1 > /sys/class/net/bonding_masters

To confirm this:

testbox:~ # cat /sys/class/net/bonding_masters
bond0 bond1

At this point the /sys/class/net/ directory will also have a bond1
directory as well as the bond0 directory.  Note, bond0 was included when
bond1 was added.  If it had not, bond0 would have been replaced by
bond1:

testbox:~ # echo bond1 > /sys/class/net/bonding_masters
testbox:~ # cat /sys/class/net/bonding_masters
bond1

The sysfs directory created for each bond, e.g. /sys/class/net/bond0/,
contains information specific to the bond interface.  It has the same
structure as directories created for an Ethernet interfaces, e.g.
/sys/class/net/eth0/, except that it contains a directory named bonding
in place of a link to a physical device.

The bonding directory for the given bond, e.g.
/sys/class/net/bond0/bonding/, is where the real values for the bond are
accessible.  The settable values are changed by echoing in a new value.
As an example, here is a set of statements that loads bonding with
default values then uses the sysfs interface to set the mode to
balance-tlb (mode 5), the MII link monitoring interval to something
reasonable (100 ms), brings the bond interface up so that adapters can
be enslaved and enslaves adapters eth0 and eth1 into the bond:

testbox:~ # modprobe bonding    
testbox:~ # echo 5 > /sys/class/net/bond0/bonding/mode
testbox:~ # echo 100 > /sys/class/net/bond0/bonding/miimon
testbox:~ # ifconfig bond0 up
testbox:~ # echo eth0 eth1 > /sys/class/net/bond0/bonding/slaves

Following is a listing of the bond0/bonding/ sysfs directory structure.
The type of value accepted and / or displayed dependent on what the
actual setting is, but in general are either an integer value, a text
string and in the case of the 'slaves' and 'arp_ip_target' settings,
like the bonding_masters file, a space delimited list of string values:

testbox:~ # ls -la /sys/class/net/bond0/bonding/
total 0
drwxr-xr-x  2 root root    0 Jul  6 13:03 .
drwxr-xr-x  4 root root    0 Jul  6 13:03 ..
-rw-r--r--  1 root root 4096 Jul  6 13:03 active_slave
-r--r--r--  1 root root 4096 Jul  6 13:03 ad_actor_key
-r--r--r--  1 root root 4096 Jul  6 13:03 ad_aggregator
-r--r--r--  1 root root 4096 Jul  6 13:03 ad_num_ports
-r--r--r--  1 root root 4096 Jul  6 13:03 ad_partner_key
-r--r--r--  1 root root 4096 Jul  6 13:03 ad_partner_mac
-rw-r--r--  1 root root 4096 Jul  6 13:03 arp_interval
-rw-r--r--  1 root root 4096 Jul  6 13:03 arp_ip_target
-rw-r--r--  1 root root 4096 Jul  6 13:03 down_delay
-rw-r--r--  1 root root 4096 Jul  6 13:03 lacp_rate
-r--r--r--  1 root root 4096 Jul  6 13:03 mii_status
-rw-r--r--  1 root root 4096 Jul  6 13:03 miimon
-rw-r--r--  1 root root 4096 Jul  6 12:56 mode
-rw-r--r--  1 root root 4096 Jul  6 13:03 primary
-rw-r--r--  1 root root 4096 Jul  6 12:56 slaves
-rw-r--r--  1 root root 4096 Jul  6 13:03 up_delay
-rw-r--r--  1 root root 4096 Jul  6 13:03 use_carrier
-rw-r--r--  1 root root 4096 Jul  6 13:03 xmit_hash_policy


-----

Regard,

- Aaron
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to