diff options
author | Mohit Mehta <mohit.mehta@vyatta.com> | 2010-02-18 17:11:35 -0800 |
---|---|---|
committer | Mohit Mehta <mohit.mehta@vyatta.com> | 2010-02-18 17:11:35 -0800 |
commit | fab23c4e4b7e5566e43ccbaa9f4dbc7d1b60fc69 (patch) | |
tree | 6f575f9aaf66f266315c00155d5c930fa1af995e /templates/interfaces/bonding | |
parent | 8989b47af4fbf6c980003dfe6b721130044b0d6a (diff) | |
download | vyatta-cfg-quagga-fab23c4e4b7e5566e43ccbaa9f4dbc7d1b60fc69.tar.gz vyatta-cfg-quagga-fab23c4e4b7e5566e43ccbaa9f4dbc7d1b60fc69.zip |
Fix Bug 5064 can't delete bridge group and membership in one commit
* fix this for eth, eth.vif, bond, bond.vif interfaces
* also, bridge-group code for bonding interfaces wasn't changed
with commit ec080f99 that re-strucutred bridging code in eth and
eth.vifs to fix bug 4708. bridge-group code for bond and bond.vif
interfaces is now similar to the fix for 4708
Diffstat (limited to 'templates/interfaces/bonding')
8 files changed, 135 insertions, 43 deletions
diff --git a/templates/interfaces/bonding/node.tag/bridge-group/bridge/node.def b/templates/interfaces/bonding/node.tag/bridge-group/bridge/node.def index dc958dd5..bf4d0f7f 100644 --- a/templates/interfaces/bonding/node.tag/bridge-group/bridge/node.def +++ b/templates/interfaces/bonding/node.tag/bridge-group/bridge/node.def @@ -1,6 +1,8 @@ type: txt + help: Set this interface to a bridge-group + commit:expression: exec \ "/opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(@) --check=bridge" -delete: echo $VAR(@) > /tmp/bridge-no.$PPID + allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=bridge diff --git a/templates/interfaces/bonding/node.tag/bridge-group/cost/node.def b/templates/interfaces/bonding/node.tag/bridge-group/cost/node.def index ef2d9940..f90f4769 100644 --- a/templates/interfaces/bonding/node.tag/bridge-group/cost/node.def +++ b/templates/interfaces/bonding/node.tag/bridge-group/cost/node.def @@ -1,4 +1,6 @@ type: u32 + help: Set the path cost for this port + comp_help: possible completions: <0-2147483647> Set port cost diff --git a/templates/interfaces/bonding/node.tag/bridge-group/node.def b/templates/interfaces/bonding/node.tag/bridge-group/node.def index dc82ec7a..940295fa 100644 --- a/templates/interfaces/bonding/node.tag/bridge-group/node.def +++ b/templates/interfaces/bonding/node.tag/bridge-group/node.def @@ -1,24 +1,61 @@ priority: 320 help: Add this interface to a bridge group -create: sudo brctl addif $VAR(./bridge/@) $VAR(../@); +end: + bondif=$VAR(../@) + oldbridge=`/opt/vyatta/sbin/vyatta-cli-expand-var.pl \\$VAR\(/interfaces/bonding/$bondif/bridge-group/bridge/@\)` + newbridge="$VAR(./bridge/@)" -delete: touch /tmp/bond-$VAR(../@)-bridge.$PPID; + if [ ${COMMIT_ACTION} = 'SET' ]; then + if [ -z "$newbridge" ]; then + echo "Must specify bridge name." + exit 1 + else + echo "Adding interface $bondif to bridge $newbridge." + sudo brctl addif $newbridge $bondif; -end: if [ -f "/tmp/bond-$VAR(../@)-bridge.$PPID" ]; then - rm -f /tmp/bond-$VAR(../@)-bridge.$PPID; - brno=$(cat /tmp/bridge-no.$PPID); - sudo brctl delif $brno $VAR(../@); - rm -f /tmp/bridge-no.$PPID; - else - if [ -z "$VAR(./bridge/@)" ]; then - echo "Must set the bridge interface"; - exit 1; - fi; - if [ -n "$VAR(./cost/@)" ]; then - sudo brctl setpathcost $VAR(./bridge/@) $VAR(../@) $VAR(./cost/@); - fi; - if [ -n "$VAR(./priority/@)" ]; then - sudo brctl setportprio $VAR(./bridge/@) $VAR(../@) $VAR(./priority/@); - fi; - fi; + if [ -n "$VAR(./cost/@)" ]; then + sudo brctl setpathcost $newbridge $bondif $VAR(./cost/@); + fi; + if [ -n "$VAR(./priority/@)" ]; then + sudo brctl setportprio $newbridge $bondif $VAR(./priority/@); + fi + fi + elif [ ${COMMIT_ACTION} = 'DELETE' ]; then + echo "Removing interface $bondif from bridge $oldbridge." + if /opt/vyatta/sbin/vyatta-bridgegroup-depedency.pl \ + --bridge-notin-proposedcfg \ + --bridge-interface="$oldbridge"; then \ + # this is the case where the bridge that this interface is assigned + # to is getting deleted in the same commit as the bridge node under + # this interface - Bug 5064|4734. Since bridge has a higher priority; + # it gets deleted before the removal of bridge-groups under interfaces + exit 0 + else + sudo brctl delif $oldbridge $bondif + fi + else + if [ -z "$newbridge" ]; then + echo "Must specify bridge name." + exit 1 + else + if [ "$oldbridge" != "$newbridge" ]; then + echo "Removing interface $bondif from bridge $oldbridge and adding it to $newbridge." + # do not remove interface from bridge if bridge not in proposed config + # reason is same as mentioned in the ${COMMIT_ACTION} = 'DELETE' section + if ! /opt/vyatta/sbin/vyatta-bridgegroup-depedency.pl \ + --bridge-notin-proposedcfg \ + --bridge-interface="$oldbridge"; then \ + sudo brctl delif $oldbridge $bondif + fi + sudo brctl addif $newbridge $bondif + fi + if [ -n "$VAR(./cost/@)" ]; then + sudo brctl setpathcost $newbridge $bondif $VAR(./cost/@) + fi + if [ -n "$VAR(./priority/@)" ]; then + sudo brctl setportprio $newbridge $bondif $VAR(./priority/@) + fi + fi + fi + exit 0 diff --git a/templates/interfaces/bonding/node.tag/bridge-group/priority/node.def b/templates/interfaces/bonding/node.tag/bridge-group/priority/node.def index 8688c394..5c11ec4f 100644 --- a/templates/interfaces/bonding/node.tag/bridge-group/priority/node.def +++ b/templates/interfaces/bonding/node.tag/bridge-group/priority/node.def @@ -1,4 +1,6 @@ type: u32 + help: Set the path priority for this port + comp_help: possible completions: <0-255> Set port priority diff --git a/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/bridge/node.def b/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/bridge/node.def index e3674bcd..4e3e22ec 100644 --- a/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/bridge/node.def +++ b/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/bridge/node.def @@ -1,11 +1,8 @@ type: txt + help: Set this interface to a bridge-group -syntax:expression: exec " \ - if [ -z \"`sudo brctl show | grep $VAR(@) `\" ]; then \ - echo bridge interface $VAR(@) doesn\\'t exist on this system ; \ - exit 1 ; \ - fi ; " -delete:expression: "sudo brctl delif $VAR(@) $VAR(../../../@).$VAR(../../@)" -allowed: local -a array ; - array=( /sys/class/net/br* ) ; - echo -n ${array[@]##*/} + +commit:expression: exec \ + "/opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(@) --check=bridge" + +allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=bridge diff --git a/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/cost/node.def b/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/cost/node.def index ef2d9940..f90f4769 100644 --- a/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/cost/node.def +++ b/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/cost/node.def @@ -1,4 +1,6 @@ type: u32 + help: Set the path cost for this port + comp_help: possible completions: <0-2147483647> Set port cost diff --git a/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/node.def b/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/node.def index 3e93d112..04dc957b 100644 --- a/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/node.def +++ b/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/node.def @@ -1,14 +1,62 @@ -help: Set this interface to a bridge group -commit:expression: $VAR(./bridge/) != ""; "Must set the bridge interface" -create:sudo brctl addif $VAR(./bridge/@) $VAR(../../@).$VAR(../@) -delete:touch /tmp/bond-$VAR(../@)-bridge.$PPID -end: if [ -f "/tmp/bond-$VAR(../@)-bridge.$PPID" ]; then - rm -f "/tmp/bond-$VAR(../@)-bridge.$PPID" - else - if [ -n "$VAR(./cost/@)" ]; then - sudo brctl setpathcost $VAR(./bridge/@) "$VAR(../../@).$VAR(../@)" "$VAR(./cost/@)" - fi - if [ -n "$VAR(./priority/@)" ]; then - sudo brctl setportprio $VAR(./bridge/@) "$VAR(../../@).$VAR(../@)" "$VAR(./priority/@)" - fi - fi +help: Add this interface to a bridge group + +end: + bond=$VAR(../../@) + vif=$VAR(../@) + bondif=$bond.$vif + oldbridge=`/opt/vyatta/sbin/vyatta-cli-expand-var.pl \\$VAR\(/interfaces/bonding/$bond/vif/$vif/bridge-group/bridge/@\)` + newbridge="$VAR(./bridge/@)" + + if [ ${COMMIT_ACTION} = 'SET' ]; then + if [ -z "$newbridge" ]; then + echo "Must specify bridge name." + exit 1 + else + echo "Adding interface $bondif to bridge $newbridge." + sudo brctl addif $newbridge $bondif; + + if [ -n "$VAR(./cost/@)" ]; then + sudo brctl setpathcost $newbridge $bondif $VAR(./cost/@); + fi; + if [ -n "$VAR(./priority/@)" ]; then + sudo brctl setportprio $newbridge $bondif $VAR(./priority/@); + fi + fi + elif [ ${COMMIT_ACTION} = 'DELETE' ]; then + echo "Removing interface $bondif from bridge $oldbridge." + if /opt/vyatta/sbin/vyatta-bridgegroup-depedency.pl \ + --bridge-notin-proposedcfg \ + --bridge-interface="$oldbridge"; then \ + # this is the case where the bridge that this interface is assigned + # to is getting deleted in the same commit as the bridge node under + # this interface - Bug 5064|4734. Since bridge has a higher priority; + # it gets deleted before the removal of bridge-groups under interfaces + exit 0 + else + sudo brctl delif $oldbridge $bondif + fi + else + if [ -z "$newbridge" ]; then + echo "Must specify bridge name." + exit 1 + else + if [ "$oldbridge" != "$newbridge" ]; then + echo "Removing interface $bondif from bridge $oldbridge and adding it to $newbridge." + # do not remove interface from bridge if bridge not in proposed config + # reason is same as mentioned in the ${COMMIT_ACTION} = 'DELETE' section + if ! /opt/vyatta/sbin/vyatta-bridgegroup-depedency.pl \ + --bridge-notin-proposedcfg \ + --bridge-interface="$oldbridge"; then \ + sudo brctl delif $oldbridge $bondif + fi + sudo brctl addif $newbridge $bondif + fi + if [ -n "$VAR(./cost/@)" ]; then + sudo brctl setpathcost $newbridge $bondif $VAR(./cost/@) + fi + if [ -n "$VAR(./priority/@)" ]; then + sudo brctl setportprio $newbridge $bondif $VAR(./priority/@) + fi + fi + fi + exit 0 diff --git a/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/priority/node.def b/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/priority/node.def index 8688c394..5c11ec4f 100644 --- a/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/priority/node.def +++ b/templates/interfaces/bonding/node.tag/vif/node.tag/bridge-group/priority/node.def @@ -1,4 +1,6 @@ type: u32 + help: Set the path priority for this port + comp_help: possible completions: <0-255> Set port priority |