summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-11-29 11:52:19 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2010-11-29 12:20:56 -0800
commit8b4aeb237248b744fe8314da772890d96bf24f18 (patch)
tree04b673ba90b0b9cce8560c1280887c3342ad32e9 /scripts
parent713fd8af92085f132da2b52708e7c3a3588cabf4 (diff)
downloadvyatta-cfg-quagga-8b4aeb237248b744fe8314da772890d96bf24f18.tar.gz
vyatta-cfg-quagga-8b4aeb237248b744fe8314da772890d96bf24f18.zip
Remove module rather than deleting link device
The special tunnel device gre0 (etc) are created by module when installed. If the the device is deleted directly then following attempts to create tunnels will fail. The proper way to cleanup is to remove the module which will remove the special device and save memory.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-tunnel-cleanup18
1 files changed, 8 insertions, 10 deletions
diff --git a/scripts/vyatta-tunnel-cleanup b/scripts/vyatta-tunnel-cleanup
index 2113d3ba..6094818c 100755
--- a/scripts/vyatta-tunnel-cleanup
+++ b/scripts/vyatta-tunnel-cleanup
@@ -8,11 +8,11 @@ use warnings;
use lib "/opt/vyatta/share/perl5";
use Vyatta::Config;
-# encapsulations and special network device
+# encapsulations and module names
my %encapsulation = (
- 'gre' => 'gre0',
- 'ipip' => 'tunl0',
- 'sit' => 'sit0',
+ 'gre' => 'ip_gre',
+ 'ipip' => 'ipip',
+ 'sit' => 'sit',
);
# Create map of encapsulations still in use
@@ -29,10 +29,8 @@ foreach my $type ( keys %encapsulation ) {
# skip if tunnel is still in use
next if $tunnel{$type};
- # skip if pseudo device is already gone
- my $dev = $encapsulation{$type};
- next unless ( -d "/sys/class/net/$dev" );
-
- system("ip link del $dev") == 0
- or warn "Can't delete $dev\n";
+ my $module = $encapsulation{$type};
+ next unless ( -d "/sys/module/$module" );
+ system("sudo /sbin/rmmod $module") == 0
+ or warn "rmmod $module failed\n";
}