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 | |
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')
12 files changed, 187 insertions, 52 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 diff --git a/templates/interfaces/bridge/node.def b/templates/interfaces/bridge/node.def index a7d82012..55c961ba 100644 --- a/templates/interfaces/bridge/node.def +++ b/templates/interfaces/bridge/node.def @@ -8,10 +8,11 @@ syntax:expression: pattern $VAR(@) "^br[0-9]+$" ; "Must be (br0 - br999)" create: sudo brctl addbr $VAR(@) sudo ip link set $VAR(@) up -delete: if [ -n "`ls /sys/class/net/$VAR(@)/brif`" ]; then - echo "Interfaces are still assigned to bridge $VAR(@)"; - exit 1; - fi; +delete: if ! /opt/vyatta/sbin/vyatta-bridgegroup-depedency.pl \ + --no-interfaces-assigned \ + --bridge-interface="$VAR(@)"; then \ + exit 1 + fi sudo ip link set $VAR(@) down; sudo brctl delbr $VAR(@); diff --git a/templates/interfaces/bridge/node.tag/address/node.def b/templates/interfaces/bridge/node.tag/address/node.def index 0c4ba0bd..7278df30 100644 --- a/templates/interfaces/bridge/node.tag/address/node.def +++ b/templates/interfaces/bridge/node.tag/address/node.def @@ -5,7 +5,17 @@ help: Set an IP address for this interface syntax:expression: exec "/opt/vyatta/sbin/vyatta-interfaces.pl --valid-addr $VAR(@) --dev $VAR(../@)";\ "Invalid IP address/prefix [$VAR(@)] for interface $VAR(../@)" create: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-update $VAR(@) --dev $VAR(../@) -delete: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-delete $VAR(@) --dev $VAR(../@) +delete: + if /opt/vyatta/sbin/vyatta-bridgegroup-depedency.pl \ + --bridge-notin-proposedcfg \ + --bridge-interface="$VAR(../@)"; then \ + # bridge has higher priority than bridge-address so bridge gets deleted + # before bridge-address in case the whole of bridge config was deleted. + # In that case we do not need to delete address here now + exit 0 + else + sudo /opt/vyatta/sbin/vyatta-interfaces.pl --eth-addr-delete $VAR(@) --dev $VAR(../@) + fi allowed: echo "dhcp <>" comp_help:Possible completions: <x.x.x.x/x> Set the IP address and prefix length diff --git a/templates/interfaces/ethernet/node.tag/bridge-group/node.def b/templates/interfaces/ethernet/node.tag/bridge-group/node.def index b30a9e10..7590dc96 100644 --- a/templates/interfaces/ethernet/node.tag/bridge-group/node.def +++ b/templates/interfaces/ethernet/node.tag/bridge-group/node.def @@ -22,7 +22,17 @@ end: fi elif [ ${COMMIT_ACTION} = 'DELETE' ]; then echo "Removing interface $ethif from bridge $oldbridge." - sudo brctl delif $oldbridge $ethif + 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 $ethif + fi else if [ -z "$newbridge" ]; then echo "Must specify bridge name." @@ -30,7 +40,13 @@ end: else if [ "$oldbridge" != "$newbridge" ]; then echo "Removing interface $ethif from bridge $oldbridge and adding it to $newbridge." - sudo brctl delif $oldbridge $ethif + # 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 $ethif + fi sudo brctl addif $newbridge $ethif fi if [ -n "$VAR(./cost/@)" ]; then diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def index e3645b1c..dd3863a0 100644 --- a/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def +++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/bridge-group/node.def @@ -25,7 +25,17 @@ end: fi elif [ ${COMMIT_ACTION} = 'DELETE' ]; then echo "Removing interface $ethif from bridge $oldbridge." - sudo brctl delif $oldbridge $ethif + 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 $ethif + fi else if [ -z "$newbridge" ]; then echo "Must specify bridge name." @@ -33,7 +43,13 @@ end: else if [ "$oldbridge" != "$newbridge" ]; then echo "Removing interface $ethif from bridge $oldbridge and adding it to $newbridge." - sudo brctl delif $oldbridge $ethif + # 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 $ethif + fi sudo brctl addif $newbridge $ethif fi if [ -n "$VAR(./cost/@)" ]; then |