diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-06-03 16:11:52 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2009-06-12 15:19:00 -0700 |
commit | 42745536c2c960c84e4d928b1a32dd350298bb16 (patch) | |
tree | 6e04faaaeebd7da99bb1297218c8993ef7e7dec8 | |
parent | e00ade655c314c3aee7ab19c0fb53967b67577c7 (diff) | |
download | vyatta-cfg-42745536c2c960c84e4d928b1a32dd350298bb16.tar.gz vyatta-cfg-42745536c2c960c84e4d928b1a32dd350298bb16.zip |
Handle speed/duplex settings better
Bugs 3952 and 3797
Make the ethtool settings management smarter.
Don't try and set a device that has been unplugged (causing commit fail).
Don't force autonegotiation if device is already in that mode.
(cherry picked from commit ad4f2a101203e71076a3e23a0a2a093326927d45)
-rw-r--r-- | templates/interfaces/ethernet/node.tag/duplex/node.def | 32 | ||||
-rw-r--r-- | templates/interfaces/ethernet/node.tag/speed/node.def | 30 |
2 files changed, 32 insertions, 30 deletions
diff --git a/templates/interfaces/ethernet/node.tag/duplex/node.def b/templates/interfaces/ethernet/node.tag/duplex/node.def index a44efd1..ba81cca 100644 --- a/templates/interfaces/ethernet/node.tag/duplex/node.def +++ b/templates/interfaces/ethernet/node.tag/duplex/node.def @@ -2,21 +2,23 @@ type: txt help: Set the duplex mode for this interface default: "auto" syntax:expression: $VAR(@) in "auto", "half", "full"; "duplex must be auto, half or full" -commit:expression: exec "if [ x$VAR(@) != xauto ]; then \ - if [ x$VAR(../speed/@) == xauto ]; then \ - exit 1; \ - fi; \ - else \ - if [ x$VAR(../speed/@) != xauto ]; then \ - exit 1; \ - fi; \ - fi; " ; "if duplex is hardcoded, speed must also be hardcoded" -update:expression: "if [ x$VAR(@) != xauto ]; then \ - sudo ethtool -s $VAR(../@) speed $VAR(../speed/@) duplex $VAR(@) autoneg off; \ - else \ - sudo ethtool -s $VAR(../@) autoneg on; \ - fi; " -delete:expression: "sudo ethtool -s $VAR(../@) autoneg on" +commit:expression: ( $VAR(@) == "auto" && $VAR(../speed/@) == "auto" ) || \ + ( $VAR(@) != "auto" && $VAR(../speed/@) != "auto" ) ; \ + "if duplex is hardcoded, speed must also be hardcoded" + +update: if [ "$VAR(@)" = "auto" ] + then + if ! sudo ethtool $VAR(../@) | grep -q 'Auto-negotiation: on' + then sudo ethtool -s $VAR(../@) autoneg on + fi + else + sudo ethtool -s $VAR(../@) \ + speed $VAR(../speed/@) duplex $VAR(@) autoneg off + fi + +delete: if [ -d /sys/class/net/$VAR(../@) ]; then + sudo ethtool -s $VAR(../@) autoneg on + fi comp_help:Possible completions: auto\t\tAuto negotiation half\t\tHalf duplex diff --git a/templates/interfaces/ethernet/node.tag/speed/node.def b/templates/interfaces/ethernet/node.tag/speed/node.def index d042074..b22e93c 100644 --- a/templates/interfaces/ethernet/node.tag/speed/node.def +++ b/templates/interfaces/ethernet/node.tag/speed/node.def @@ -2,18 +2,18 @@ type: txt help: Set the speed for this interface default: "auto" syntax:expression: $VAR(@) in "auto", "10", "100", "1000", "2500", "10000"; "Speed must be auto, 10, 100, 1000, 2500, or 10000" -commit:expression: exec "if [ x$VAR(@) != xauto ]; then \ - if [ x$VAR(../duplex/@) == xauto ]; then \ - exit 1; \ - fi; \ - else \ - if [ x$VAR(../duplex/@) != xauto ]; then \ - exit 1; \ - fi; \ - fi;"; "if speed is hardcoded, duplex must also be hardcoded" -update:expression: "if [ x$VAR(@) != xauto ]; then \ - sudo ethtool -s $VAR(../@) speed $VAR(@) duplex $VAR(../duplex/@) autoneg off; \ - else \ - sudo ethtool -s $VAR(../@) autoneg on; \ - fi; " -delete:expression: "sudo ethtool -s $VAR(../@) autoneg on" +commit:expression: ( $VAR(@) == "auto" && $VAR(../speed/@) == "auto" ) || \ + ( $VAR(@) != "auto" && $VAR(../speed/@) != "auto" ) ; \ + "if speed is hardcoded, duplex must also be hardcoded" +update: if [ "$VAR(@)" = "auto" ] + then + if ! sudo ethtool $VAR(../@) | grep -q 'Auto-negotiation: on' + then sudo ethtool -s $VAR(../@) autoneg on + fi + else + sudo ethtool -s $VAR(../@) \ + speed $VAR(../speed/@) duplex $VAR(@) autoneg off + fi +delete: if [ -d /sys/class/net/$VAR(../@) ]; then + sudo ethtool -s $VAR(../@) autoneg on + fi |