qemu-server/pve-bridge
Alexandre Derumier c30aea2b10 add support for network trunks
This add support for net trunks vlan filtering
for ovs and linux vlan-aware bridge

Can be mixed with current "tag" option

examples:
----------

allow only 802.1Q packets with vlanid 2,3,4 :

netx: .....,trunks=2,3,4

allow only 802.1Q packets with vlanid 2,3,4 and tag non-802.1Q packets to vlanid 5 :

netx: tag=5,trunks=2,3,4

tag non-802.1Q packets to vlanid 5

netx: tag=5
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2016-01-15 17:23:59 +01:00

48 lines
1.2 KiB
Perl
Executable File

#!/usr/bin/perl
use strict;
use warnings;
use PVE::QemuServer;
use PVE::Tools qw(run_command);
use PVE::Network;
my $iface = shift;
my $hotplug = 0;
if ($iface eq '--hotplug') {
$hotplug = 1;
$iface = shift;
}
die "no interface specified\n" if !$iface;
die "got strange interface name '$iface'\n"
if $iface !~ m/^tap(\d+)i(\d+)$/;
my $vmid = $1;
my $netid = "net$2";
my $migratedfrom = $hotplug ? undef : $ENV{PVE_MIGRATED_FROM};
my $conf = PVE::QemuServer::load_config($vmid, $migratedfrom);
my $netconf = $conf->{$netid};
$netconf = $conf->{pending}->{$netid} if !$migratedfrom && defined($conf->{pending}->{$netid});
die "unable to get network config '$netid'\n"
if !defined($netconf);
my $net = PVE::QemuServer::parse_net($netconf);
die "unable to parse network config '$netid'\n" if !$net;
PVE::Network::tap_create($iface, $net->{bridge});
# if ovs is under this bridge all traffic control settings will be flushed.
# so we need to call tap_rate_limit after tap_plug
PVE::Network::tap_plug($iface, $net->{bridge}, $net->{tag}, $net->{firewall}, $net->{trunks});
PVE::Network::tap_rate_limit($iface, $net->{rate}) if $net->{rate};
exit 0;