From 4e41f747e53ebdba0e6f835ec701fa9ee6bb2ead Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen.hemminger@vyatta.com>
Date: Wed, 10 Jun 2009 15:59:05 -0700
Subject: Fix management of delete of policy in use

Minor config confusion in script.
Bug 4532
(cherry picked from commit 28650945b96e0990fbe39e4743bca436662bae66)
---
 scripts/vyatta-qos.pl | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'scripts')

diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl
index 693da36..86b8fe2 100755
--- a/scripts/vyatta-qos.pl
+++ b/scripts/vyatta-qos.pl
@@ -182,6 +182,7 @@ sub update_interface {
     }
 }
 
+
 # return array of names using given qos-policy
 sub interfaces_using {
     my $policy = shift;
@@ -191,9 +192,13 @@ sub interfaces_using {
     foreach my $name ( getInterfaces() ) {
         my $intf = new Vyatta::Interface($name);
         next unless $intf;
-
-        $config->setLevel( $intf->path() );
-        push @inuse, $name if ( $config->exists("qos-policy $policy") );
+	$config->setLevel($intf->path() . ' qos-policy');
+	
+        foreach my $direction ($config->listNodes()) {
+	    my $cur = $config->returnValue($direction);
+	    next unless $cur;
+	    push @inuse, $name if ($cur eq $policy); 
+	}
     }
     return @inuse;
 }
@@ -204,7 +209,7 @@ sub delete_policy {
         my @inuse = interfaces_using($name);
 
         die "QoS policy still in use on ", join( ' ', @inuse ), "\n"
-          if (@inuse);
+	    if @inuse;
     }
 }
 
-- 
cgit v1.2.3