]> git.proxmox.com Git - pve-common.git/commitdiff
tap_unplug: auto-detect bridge, improve error messages
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 8 May 2014 07:09:12 +0000 (09:09 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 8 May 2014 07:09:56 +0000 (09:09 +0200)
Based on patch sent by Alexandre.

data/PVE/Network.pm

index 4677bf94009d1fe79eaba999eaf5d30ce4f61b6f..885be0ef1083450e11af6294956a3384312b0a5e 100644 (file)
@@ -88,16 +88,19 @@ sub tap_plug {
 }
 
 sub tap_unplug {
 }
 
 sub tap_unplug {
-    my ($iface, $bridge, $tag) = @_;
+    my ($iface) = @_;
 
 
-    if (-d "/sys/class/net/$bridge/bridge") {
-       $bridge .= "v$tag" if $tag;
+    my $path= "/sys/class/net/$iface/brport/bridge";
+    if (-l $path) {
+       my $bridge = basename(readlink($path));
+       #avoid insecure dependency;
+       ($bridge) = $bridge =~ /(\S+)/;
 
        system("/sbin/brctl delif $bridge $iface") == 0 ||
 
        system("/sbin/brctl delif $bridge $iface") == 0 ||
-           die "can't del interface from bridge\n";
+           die "can't del interface '$iface' from bridge '$bridge'\n";
     } else {
        system ("/usr/bin/ovs-vsctl del-port $iface") == 0 ||
     } else {
        system ("/usr/bin/ovs-vsctl del-port $iface") == 0 ||
-           die "can't del interface from bridge\n";
+           die "can't del ovs port '$iface'\n";
     }
 }
 
     }
 }