From 2619f6c8fa01ab3ade6dfe6edb6815825c89cfd0 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 3 Jun 2009 16:25:24 -0700 Subject: Allow delete of ethernet settings when device does not exist More bug 3952 fixes --- templates/interfaces/ethernet/node.def | 3 ++- templates/interfaces/ethernet/node.tag/disable/node.def | 7 ++++--- templates/interfaces/ethernet/node.tag/mac/node.def | 3 ++- templates/interfaces/ethernet/node.tag/mtu/node.def | 7 +++++-- templates/interfaces/ethernet/node.tag/smp_affinity/node.def | 5 ++--- templates/interfaces/ethernet/node.tag/vif/node.def | 3 ++- 6 files changed, 17 insertions(+), 11 deletions(-) (limited to 'templates') diff --git a/templates/interfaces/ethernet/node.def b/templates/interfaces/ethernet/node.def index d4e86c4..e53bbdb 100644 --- a/templates/interfaces/ethernet/node.def +++ b/templates/interfaces/ethernet/node.def @@ -6,4 +6,5 @@ syntax:expression: exec \ allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=ethernet create: sudo ip link set "$VAR(@)" up /opt/vyatta/sbin/vyatta-link-detect $VAR(@) on -delete: sudo ip link set "$VAR(@)" down +delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 + sudo ip link set $VAR(@) down diff --git a/templates/interfaces/ethernet/node.tag/disable/node.def b/templates/interfaces/ethernet/node.tag/disable/node.def index ad03336..fbfb155 100644 --- a/templates/interfaces/ethernet/node.tag/disable/node.def +++ b/templates/interfaces/ethernet/node.tag/disable/node.def @@ -5,7 +5,8 @@ create: /etc/netplug/linkdown.d/dhclient $VAR(../@) /etc/netplug/linkup.d/dhclient $VAR(../@) exit 1 fi -delete: if ! sudo ip link set $VAR(../@) up; then - echo "Error enabling dev $VAR(../@)" - exit 1 +delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 + if ! sudo ip link set $VAR(../@) up; then + echo "Error enabling dev $VAR(../@)" + exit 1 fi diff --git a/templates/interfaces/ethernet/node.tag/mac/node.def b/templates/interfaces/ethernet/node.tag/mac/node.def index abafa7a..55264cf 100644 --- a/templates/interfaces/ethernet/node.tag/mac/node.def +++ b/templates/interfaces/ethernet/node.tag/mac/node.def @@ -3,5 +3,6 @@ help: Set the Media Access Control (MAC) address of this interface syntax:expression: exec "\ /opt/vyatta/sbin/vyatta-interfaces.pl --dev $VAR(../@) --valid-mac $VAR(@)" update: /opt/vyatta/sbin/vyatta-interfaces.pl --dev $VAR(../@) --set-mac $VAR(@) -delete: /opt/vyatta/sbin/vyatta-interfaces.pl --dev $VAR(../@) --set-mac $VAR(../hw-id/@) +delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 + /opt/vyatta/sbin/vyatta-interfaces.pl --dev $VAR(../@) --set-mac $VAR(../hw-id/@) diff --git a/templates/interfaces/ethernet/node.tag/mtu/node.def b/templates/interfaces/ethernet/node.tag/mtu/node.def index 07c102a..dc03ae1 100644 --- a/templates/interfaces/ethernet/node.tag/mtu/node.def +++ b/templates/interfaces/ethernet/node.tag/mtu/node.def @@ -1,5 +1,8 @@ type: u32 help: Set the Maximum Transmission Unit (MTU) for this interface syntax:expression: $VAR(@) >= 68 && $VAR(@) <= 9000; "MTU must be between 68 and 9000" -update:expression: "sudo ip link set $VAR(../@) mtu $VAR(@)"; "Error setting MTU on dev $VAR(../@)" -delete:expression: "sudo ip link set $VAR(../@) mtu 1500"; "Error deleting MTU on dev $VAR(../@)" +update: if ! sudo ip link set $VAR(../@) mtu $VAR(@) + then echo "Error setting MTU on dev $VAR(../@)"; exit 1 + fi +delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 + sudo ip link set $VAR(../@) mtu 1500 diff --git a/templates/interfaces/ethernet/node.tag/smp_affinity/node.def b/templates/interfaces/ethernet/node.tag/smp_affinity/node.def index 9d5d289..c07fa1d 100644 --- a/templates/interfaces/ethernet/node.tag/smp_affinity/node.def +++ b/templates/interfaces/ethernet/node.tag/smp_affinity/node.def @@ -24,9 +24,8 @@ update: exit 1 fi -delete: - sudo /opt/vyatta/sbin/vyatta-irqaffin reset $VAR(../@) - if [ $? -ne 0 ]; then +delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 + if ! sudo /opt/vyatta/sbin/vyatta-irqaffin reset $VAR(../@); then echo "Error deleting CPU affinity mask on interface $VAR(../@)" exit 1 fi diff --git a/templates/interfaces/ethernet/node.tag/vif/node.def b/templates/interfaces/ethernet/node.tag/vif/node.def index dabfa56..4cb0639 100644 --- a/templates/interfaces/ethernet/node.tag/vif/node.def +++ b/templates/interfaces/ethernet/node.tag/vif/node.def @@ -11,6 +11,7 @@ create: if ! sudo ip link add link $VAR(../@) name "$VAR(../@).$VAR(@)" type vla sudo ip link set "$VAR(../@).$VAR(@)" up fi /opt/vyatta/sbin/vyatta-link-detect "$VAR(../@).$VAR(@)" on -delete: sudo ip link delete dev "$VAR(../@).$VAR(@)" type vlan id $VAR(@) +delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 + sudo ip link delete dev "$VAR(../@).$VAR(@)" type vlan id $VAR(@) comp_help: possible completions: <0-4094> Set VLAN ID -- cgit v1.2.3