diff options
author | Mark O'Brien <mark@vyatta.com> | 2009-07-01 17:46:14 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2009-07-17 14:56:05 -0700 |
commit | fd48be9e4f0971a42bb9e74388e2cf3be12c3434 (patch) | |
tree | 2f5663d460e7c33dba98ba8791be1f848db839c7 | |
parent | 7d8e03018554ab64001d54c88280b71097f63804 (diff) | |
download | vyatta-cfg-quagga-fd48be9e4f0971a42bb9e74388e2cf3be12c3434.tar.gz vyatta-cfg-quagga-fd48be9e4f0971a42bb9e74388e2cf3be12c3434.zip |
Allow user to select round-robin mode.
* bug 4647
* scripts/vyatta-bonding.pl
(cherry picked from commit aba4e42b4b07b856cbcff0fcf5231824fc18bb37)
-rwxr-xr-x | scripts/vyatta-bonding.pl | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/scripts/vyatta-bonding.pl b/scripts/vyatta-bonding.pl index 2f2167fa..e2cc627d 100755 --- a/scripts/vyatta-bonding.pl +++ b/scripts/vyatta-bonding.pl @@ -36,19 +36,32 @@ use strict; use warnings; my %modes = ( - "round-robin" => 0, - "active-backup" => 1, - "xor-hash" => 2, - "broadcast" => 3, - "802.3ad" => 4, - "transmit-load-balance" => 5, - "adaptive-load-balance" => 6, + ## Linux bonding driver modes + 1 + ## (eg. bond driver expects round-robin = 0) + "invalid_opt" => 0, + "round-robin" => 1, + "active-backup" => 2, + "xor-hash" => 3, + "broadcast" => 4, + "802.3ad" => 5, + "transmit-load-balance" => 6, + "adaptive-load-balance" => 7, ); sub set_mode { my ($intf, $mode) = @_; + my $request_mode = $mode; my $val = $modes{$mode}; - die "Unknown bonding mode $mode\n" unless $val; + + ## Check if vaild bonding option is requested. + foreach my $item ( keys(%modes) ) { + $mode = "invalid_opt" unless( $mode =~ m/$item/); + }; + die "Unknown bonding mode $request_mode\n" unless $val; + + ## After above bonding option check, adjust value + ## to value the expected by bonding driver. -MOB + $val = ($val - 1); open my $fm, '>', "/sys/class/net/$intf/bonding/mode" or die "Error: $intf is not a bonding device:$!\n"; |