Actually it was not clear to me the bonding parameters could be changed in that way after the bonding interface has been brought up...
Apparently your solution should work but I'm not sure...
To be sure *all* the parameters in both bonding modes are set correctly I have made the following procedure:
1st step:
Code:
modprobe bonding mode=4 lacp_rate=1 downdelay=200 updelay=200 miimon=100
This command brings up the bonding interface bond0 with all the parameters I need for the link aggregation bonding mode.
2nd step:
Now all the settings of the current bond0 interface need be dumped to allow the manual re-set to be preformed later on (4th step). I did that using the following bash command:
Code:
for setting in /sys/class/net/bond0/bonding/*; do echo "echo \"$(/usr/bin/cat $setting)\" > $setting"; done > bond0_settings
This command produced the following "bond0_settings" file:
Code:
echo "" > /sys/class/net/bond0/bonding/active_slave
echo "0" > /sys/class/net/bond0/bonding/ad_actor_key
echo "0" > /sys/class/net/bond0/bonding/ad_aggregator
echo "0" > /sys/class/net/bond0/bonding/ad_num_ports
echo "0" > /sys/class/net/bond0/bonding/ad_partner_key
echo "" > /sys/class/net/bond0/bonding/ad_partner_mac
echo "stable 0" > /sys/class/net/bond0/bonding/ad_select
echo "0" > /sys/class/net/bond0/bonding/all_slaves_active
echo "0" > /sys/class/net/bond0/bonding/arp_interval
echo "" > /sys/class/net/bond0/bonding/arp_ip_target
echo "none 0" > /sys/class/net/bond0/bonding/arp_validate
echo "200" > /sys/class/net/bond0/bonding/downdelay
echo "none 0" > /sys/class/net/bond0/bonding/fail_over_mac
echo "fast 1" > /sys/class/net/bond0/bonding/lacp_rate
echo "down" > /sys/class/net/bond0/bonding/mii_status
echo "100" > /sys/class/net/bond0/bonding/miimon
echo "802.3ad 4" > /sys/class/net/bond0/bonding/mode
echo "1" > /sys/class/net/bond0/bonding/num_grat_arp
echo "1" > /sys/class/net/bond0/bonding/num_unsol_na
echo "" > /sys/class/net/bond0/bonding/primary
echo "always 0" > /sys/class/net/bond0/bonding/primary_reselect
echo "" > /sys/class/net/bond0/bonding/queue_id
echo "1" > /sys/class/net/bond0/bonding/resend_igmp
echo "" > /sys/class/net/bond0/bonding/slaves
echo "200" > /sys/class/net/bond0/bonding/updelay
echo "1" > /sys/class/net/bond0/bonding/use_carrier
echo "layer2 0" > /sys/class/net/bond0/bonding/xmit_hash_policy
3th step:
Code:
rmmod bonding
modprobe bonding mode=1 miimon=100 max_bonds=2
The first command removes the bonding module previously loaded while the second loads it again generating two bonding interfaces with exactly the same bonding parameters (this time active-backup bonding mode).
4th step:
At this point I have two bonding interfaces "bond0" and "bond1" under /proc/net/bonding.
The last step would be to load the previously dumped bond0 settings to the actual bond0 interface to switch from active-backup bonding mode (the actual state in which the interface is) to the link aggregation bonding mode (the state in which I would like to have the interface).
I was expected the command lines in the file "bond0_settings" should make that job nicely. Actually they did it but only partially as some of the command lines above returned "Permission denied" or "Operation not permitted" error.
To my understanding when the bonding module is loaded also all the corresponding bonding parameters are set according to the provided options. It seems also the permissions of some files generated under /sys/class/net/bondX/bonding depend on the bonding mode (the cause of "Permission denied" errors). Moreover, on some other files it is not possible to write (the cause of "Operation not permitted" error) even if they are flagged as writable.
This triggers me to the question: is it enough to change only the "changeable" options to switch from one bonding mode to another?
I have to say that, apparently this procedure seems to work as the two bonding interfaces seem to be set up correctly (I mean just looking at contents of /proc/net/bonding/). Anyway I will make more real and careful connection tests to check if everything is working as expected.
Thanks for the precious help!
P.S.
Just for completeness I would like to add here that the problem with the option '-o' was not related to the bonding module but to the modprobe script. It seems this option is not supported anymore by modprobe (at least the version shipped with slackware distribution).