mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-27 13:44:54 +00:00
tap_unplug: auto-detect bridge, improve error messages
Based on patch sent by Alexandre.
This commit is contained in:
parent
39313ced7e
commit
2db1cc0de9
@ -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") {
|
my $path= "/sys/class/net/$iface/brport/bridge";
|
||||||
$bridge .= "v$tag" if $tag;
|
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 {
|
} else {
|
||||||
system ("/usr/bin/ovs-vsctl del-port $iface") == 0 ||
|
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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user