summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-04-15 16:18:39 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2010-04-15 17:00:44 -0700
commitff7a087858d97a98e7de05f3925c74d2b143b9fb (patch)
tree2a65944a9fb2a2e225844c7fd16f8a60e700d39f
parent4a59bd28bf2d7c901505be21db4bc12415f0711d (diff)
downloadvyatta-cfg-qos-ff7a087858d97a98e7de05f3925c74d2b143b9fb.tar.gz
vyatta-cfg-qos-ff7a087858d97a98e7de05f3925c74d2b143b9fb.zip
Add checking at commit for input policy
Handle configuration errors in policy.
-rw-r--r--interface-templates/input-policy/node.def2
-rwxr-xr-xscripts/vyatta-qos.pl22
2 files changed, 20 insertions, 4 deletions
diff --git a/interface-templates/input-policy/node.def b/interface-templates/input-policy/node.def
index 4f25d62..8062561 100644
--- a/interface-templates/input-policy/node.def
+++ b/interface-templates/input-policy/node.def
@@ -1,2 +1,4 @@
help: Set incoming packet policy
+commit:expression:exec "/opt/vyatta/sbin/vyatta-qos.pl --check-ingress $IFNAME"
end: /opt/vyatta/sbin/vyatta-qos.pl --update-ingress $IFNAME
+
diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl
index 0fd003f..e552497 100755
--- a/scripts/vyatta-qos.pl
+++ b/scripts/vyatta-qos.pl
@@ -234,8 +234,9 @@ sub ingress_policy {
my $config = new Vyatta::Config;
$config->setLevel( "$path input-policy" );
- my @names = $config->listNodes( );
- return if $#names < 0;
+ my @names = $config->listNodes();
+ return if ($#names < 0);
+
die "Only one incoming policy is allowed\n" if ($#names > 0);
$config->setLevel( "$path input-policy " . $names[0] );
@@ -247,11 +248,19 @@ sub ingress_policy {
return $class->new( $config, $ifname );
}
+# check definition of input filtering
+sub check_ingress {
+ my $device = shift;
+
+ my $ingress = ingress_policy( $device );
+ return unless $ingress;
+}
+
# sets up input filtering
sub update_ingress {
my $device = shift;
- die "$device not present\n"
+ die "Interface $device not present\n"
unless (-d "/sys/class/net/$device");
# Drop existing ingress and recreate
@@ -298,6 +307,7 @@ usage: vyatta-qos.pl --list-policy
vyatta-qos.pl --update-interface interface policy-name
vyatta-qos.pl --delete-interface interface
+ vyatta-qos.pl --check-ingress interface
vyatta-qos.pl --update-ingress interface
EOF
exit 1;
@@ -312,16 +322,19 @@ my @applyPolicy = ();
my @deletePolicy = ();
my @startList = ();
-my $updateIngress;
+my ($checkIngress, $updateIngress);
GetOptions(
"start-interface=s" => \@startList,
"update-interface=s{2}" => \@updateInterface,
"delete-interface=s" => \$deleteInterface,
+
"list-policy" => \$listPolicy,
"delete-policy=s" => \@deletePolicy,
"create-policy=s{2}" => \@createPolicy,
"apply-policy=s" => \@applyPolicy,
+
+ "check-ingress=s" => \$checkIngress,
"update-ingress=s" => \$updateIngress
) or usage();
@@ -334,5 +347,6 @@ create_policy(@createPolicy) if ( $#createPolicy == 1 );
delete_policy(@deletePolicy) if (@deletePolicy);
apply_policy(@applyPolicy) if (@applyPolicy);
+check_ingress($checkIngress) if ($checkIngress);
update_ingress($updateIngress) if ($updateIngress);