X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=data%2FPVE%2FNetwork.pm;h=380b334af4dedac79f7e711e436d2473e016a3c5;hp=1b755c0431dd8cf5f43ef5b581a4e05225a049ad;hb=4cbabd40a7db4f810c3383b13555e9502a0b9382;hpb=f0a10afc25d71c4f5e88fb559c94c17f0fb21961 diff --git a/data/PVE/Network.pm b/data/PVE/Network.pm index 1b755c0..380b334 100644 --- a/data/PVE/Network.pm +++ b/data/PVE/Network.pm @@ -68,20 +68,36 @@ sub tap_create { sub tap_plug { my ($iface, $bridge, $tag) = @_; - my $newbridge = activate_bridge_vlan($bridge, $tag); - copy_bridge_config($bridge, $newbridge) if $bridge ne $newbridge; - - system ("/sbin/brctl addif $newbridge $iface") == 0 || - die "can't add interface to bridge\n"; + #cleanup old port config from any openvswitch bridge + eval {run_command("/usr/bin/ovs-vsctl del-port $iface", outfunc => sub {}, errfunc => sub {}) }; + + if (-d "/sys/class/net/$bridge/bridge"){ + my $newbridge = activate_bridge_vlan($bridge, $tag); + copy_bridge_config($bridge, $newbridge) if $bridge ne $newbridge; + + system ("/sbin/brctl addif $newbridge $iface") == 0 || + die "can't add interface to bridge\n"; + }else{ + my $cmd = "/usr/bin/ovs-vsctl add-port $bridge $iface"; + $cmd .= " tag=$tag" if $tag; + system ($cmd) == 0 || + die "can't add interface to bridge\n"; + } } sub tap_unplug { my ($iface, $bridge, $tag) = @_; - $bridge .= "v$tag" if $tag; + if (-d "/sys/class/net/$bridge/bridge"){ - system ("/sbin/brctl delif $bridge $iface") == 0 || - die "can't del interface from bridge\n"; + $bridge .= "v$tag" if $tag; + + system ("/sbin/brctl delif $bridge $iface") == 0 || + die "can't del interface from bridge\n"; + }else{ + system ("/usr/bin/ovs-vsctl del-port $iface") == 0 || + die "can't del interface from bridge\n"; + } } sub copy_bridge_config {