From 704b79464af13b67a943f877020ff6a1514a0235 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 16 Feb 2010 16:16:47 -0800 Subject: Use template to do syntax checks on ethernet device name Bug 5256 Going out to perl to repeatedly validate ethernet device name slows down adding VLAN's and other operations with lots of sub-devices. --- templates/interfaces/ethernet/node.def | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'templates/interfaces/ethernet/node.def') diff --git a/templates/interfaces/ethernet/node.def b/templates/interfaces/ethernet/node.def index a46ae722..081cabb5 100644 --- a/templates/interfaces/ethernet/node.def +++ b/templates/interfaces/ethernet/node.def @@ -2,9 +2,14 @@ tag: priority: 318 type: txt help: Set ethernet interface -syntax:expression: exec \ - "/opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(@) --check=ethernet" allowed: /opt/vyatta/sbin/vyatta-interfaces.pl --show=ethernet +syntax:expression: pattern $VAR(@) "^eth[0-9]+$" \ + ; "interface ethernet $VAR(@): not a valid name" +syntax:expression: exec \ + "if [ ! -d /sys/class/net/$VAR(@) ]; then \ + echo \"interface ethernet $VAR(@): does not exist\"; + exit 1; \ + fi" create: sudo ip link set "$VAR(@)" up /opt/vyatta/sbin/vyatta-link-detect $VAR(@) on delete: [ -d /sys/class/net/$VAR(../@) ] || exit 0 -- cgit v1.2.3