diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-11-17 15:12:47 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-11-17 20:29:03 -0800 |
commit | e7de8b95b1ba4e50abaa62013e84baa98ecdefa4 (patch) | |
tree | fb5abee6beff17e80d01170e17895187e5284bc2 /templates/interfaces | |
parent | 112158ad4b7e3a9c2a7060ca6d21e3fc519b53c6 (diff) | |
download | vyatta-cfg-quagga-e7de8b95b1ba4e50abaa62013e84baa98ecdefa4.tar.gz vyatta-cfg-quagga-e7de8b95b1ba4e50abaa62013e84baa98ecdefa4.zip |
Cleanup bridge port management
Consolidate bridge port management into a single perl script.
Done to fix the following bug.
Bug 4745
Don't allow interface with address to be added to bridge.
Diffstat (limited to 'templates/interfaces')
4 files changed, 4 insertions, 240 deletions
diff --git a/templates/interfaces/bonding/node.tag/bridge-group/node.def b/templates/interfaces/bonding/node.tag/bridge-group/node.def index 9ce97b1b..778226a8 100644 --- a/templates/interfaces/bonding/node.tag/bridge-group/node.def +++ b/templates/interfaces/bonding/node.tag/bridge-group/node.def @@ -1,61 +1,4 @@ priority: 320 help: Add this interface to a bridge group -end: - bondif=$VAR(../@) - oldbridge=`/opt/vyatta/sbin/vyatta-cli-expand-var.pl \\$VAR\(/interfaces/bonding/$bondif/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." - /usr/sbin/brctl addif $newbridge $bondif; - - if [ -n "$VAR(./cost/@)" ]; then - /usr/sbin/brctl setpathcost $newbridge $bondif $VAR(./cost/@); - fi; - if [ -n "$VAR(./priority/@)" ]; then - /usr/sbin/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 - /usr/sbin/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 \ - /usr/sbin/brctl delif $oldbridge $bondif - fi - /usr/sbin/brctl addif $newbridge $bondif - fi - if [ -n "$VAR(./cost/@)" ]; then - /usr/sbin/brctl setpathcost $newbridge $bondif $VAR(./cost/@) - fi - if [ -n "$VAR(./priority/@)" ]; then - /usr/sbin/brctl setportprio $newbridge $bondif $VAR(./priority/@) - fi - fi - fi - exit 0 +end: /opt/vyatta/sbin/vyatta-bridge.pl ${COMMIT_ACTION} $VAR(../@) 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 7a4008ea..b603bb8c 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,63 +1,4 @@ priority: 325 # after vif and bridge 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." - /usr/sbin/brctl addif $newbridge $bondif; - - if [ -n "$VAR(./cost/@)" ]; then - /usr/sbin/brctl setpathcost $newbridge $bondif $VAR(./cost/@); - fi; - if [ -n "$VAR(./priority/@)" ]; then - /usr/sbin/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 - /usr/sbin/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 \ - /usr/sbin/brctl delif $oldbridge $bondif - fi - /usr/sbin/brctl addif $newbridge $bondif - fi - if [ -n "$VAR(./cost/@)" ]; then - /usr/sbin/brctl setpathcost $newbridge $bondif $VAR(./cost/@) - fi - if [ -n "$VAR(./priority/@)" ]; then - /usr/sbin/brctl setportprio $newbridge $bondif $VAR(./priority/@) - fi - fi - fi - exit 0 +end: /opt/vyatta/sbin/vyatta-bridge.pl ${COMMIT_ACTION} $VAR(../../@).$VAR(../@) diff --git a/templates/interfaces/ethernet/node.tag/bridge-group/node.def b/templates/interfaces/ethernet/node.tag/bridge-group/node.def index c56c31cc..74ecab4d 100644 --- a/templates/interfaces/ethernet/node.tag/bridge-group/node.def +++ b/templates/interfaces/ethernet/node.tag/bridge-group/node.def @@ -1,62 +1,3 @@ help: Add this interface to a bridge group -end: - ethif=$VAR(../@) - oldbridge=`/opt/vyatta/sbin/vyatta-cli-expand-var.pl \\$VAR\(/interfaces/ethernet/$ethif/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 $ethif to bridge $newbridge." - /usr/sbin/brctl addif $newbridge $ethif; - - if [ -n "$VAR(./cost/@)" ]; then - /usr/sbin/brctl setpathcost $newbridge $ethif $VAR(./cost/@); - fi; - if [ -n "$VAR(./priority/@)" ]; then - /usr/sbin/brctl setportprio $newbridge $ethif $VAR(./priority/@); - fi - fi - elif [ ${COMMIT_ACTION} = 'DELETE' ]; then - echo "Removing interface $ethif 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 - /usr/sbin/brctl delif $oldbridge $ethif - fi - else - if [ -z "$newbridge" ]; then - echo "Must specify bridge name." - exit 1 - else - if [ "$oldbridge" != "$newbridge" ]; then - echo "Removing interface $ethif 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 \ - /usr/sbin/brctl delif $oldbridge $ethif - fi - /usr/sbin/brctl addif $newbridge $ethif - fi - if [ -n "$VAR(./cost/@)" ]; then - /usr/sbin/brctl setpathcost $newbridge $ethif $VAR(./cost/@) - fi - if [ -n "$VAR(./priority/@)" ]; then - /usr/sbin/brctl setportprio $newbridge $ethif $VAR(./priority/@) - fi - fi - fi - exit 0 - - +end: /opt/vyatta/sbin/vyatta-bridge.pl ${COMMIT_ACTION} $VAR(../@) 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 84fa14f1..dfd046c2 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 @@ -1,65 +1,4 @@ priority: 320 help: Add this interface to a bridge group -end: - eth=$VAR(../../@) - vif=$VAR(../@) - ethif=$eth.$vif - oldbridge=`/opt/vyatta/sbin/vyatta-cli-expand-var.pl \\$VAR\(/interfaces/ethernet/$eth/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 $ethif to bridge $newbridge." - /usr/sbin/brctl addif $newbridge $ethif; - - if [ -n "$VAR(./cost/@)" ]; then - /usr/sbin/brctl setpathcost $newbridge $ethif $VAR(./cost/@); - fi; - if [ -n "$VAR(./priority/@)" ]; then - /usr/sbin/brctl setportprio $newbridge $ethif $VAR(./priority/@); - fi - fi - elif [ ${COMMIT_ACTION} = 'DELETE' ]; then - echo "Removing interface $ethif 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 - /usr/sbin/brctl delif $oldbridge $ethif - fi - else - if [ -z "$newbridge" ]; then - echo "Must specify bridge name." - exit 1 - else - if [ "$oldbridge" != "$newbridge" ]; then - echo "Removing interface $ethif 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 \ - /usr/sbin/brctl delif $oldbridge $ethif - fi - /usr/sbin/brctl addif $newbridge $ethif - fi - if [ -n "$VAR(./cost/@)" ]; then - /usr/sbin/brctl setpathcost $newbridge $ethif $VAR(./cost/@) - fi - if [ -n "$VAR(./priority/@)" ]; then - /usr/sbin/brctl setportprio $newbridge $ethif $VAR(./priority/@) - fi - fi - fi - exit 0 - - +end: /opt/vyatta/sbin/vyatta-bridge.pl ${COMMIT_ACTION} $VAR(../../@).$VAR(../@) |