]> git.proxmox.com Git - pve-container.git/commitdiff
add support for network trunks
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 18 Jan 2016 08:29:53 +0000 (09:29 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 18 Jan 2016 10:02:50 +0000 (11:02 +0100)
Like in qemu:

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

src/PVE/LXC.pm
src/lxcnetaddbr

index f964acaf93e67f49866e7d7931c25a1c6581f535..035b3abfa8540e71ebf67cfbcfd4d605867de4f7 100644 (file)
@@ -336,7 +336,14 @@ my $netconf_desc = {
        format_description => 'VlanNo',
        minimum => '2',
        maximum => '4094',
-       description => "VLAN tag foro this interface.",
+       description => "VLAN tag for this interface.",
+       optional => 1,
+    },
+    trunks => {
+       type => 'string',
+       pattern => qr/\d+(?:;\d+)*/,
+       format_description => 'vlanid[;vlanid...]',
+       description => "VLAN ids to pass through the interface",
        optional => 1,
     },
 };
@@ -1531,7 +1538,7 @@ sub update_net {
                    write_config($vmid, $conf);
                }
 
-               PVE::Network::tap_plug($veth, $newnet->{bridge}, $newnet->{tag}, $newnet->{firewall});
+               PVE::Network::tap_plug($veth, $newnet->{bridge}, $newnet->{tag}, $newnet->{firewall}, $newnet->{trunks});
                foreach (qw(bridge tag firewall)) {
                    $oldnet->{$_} = $newnet->{$_} if $newnet->{$_};
                }
@@ -1553,7 +1560,7 @@ sub hotplug_net {
     my $eth = $newnet->{name};
 
     PVE::Network::veth_create($veth, $vethpeer, $newnet->{bridge}, $newnet->{hwaddr});
-    PVE::Network::tap_plug($veth, $newnet->{bridge}, $newnet->{tag}, $newnet->{firewall});
+    PVE::Network::tap_plug($veth, $newnet->{bridge}, $newnet->{tag}, $newnet->{firewall}, $newnet->{trunks});
 
     # attach peer in container
     my $cmd = ['lxc-device', '-n', $vmid, 'add', $vethpeer, "$eth" ];
index 44ba24a600a6ec4537a950005293eca0e56e7b16..254ea6ce8f5191ee96600e438406d63fe10ba31b 100755 (executable)
@@ -40,6 +40,7 @@ my $net = PVE::LXC::parse_lxc_network($netconf);
 my $tag = $net->{tag};
 my $firewall = $net->{firewall};
 my $bridge = $net->{bridge};
+my $trunks = $net->{trunks};
 
 die "missing bridge configuration" if !$bridge;
 
@@ -52,7 +53,7 @@ if (-d "/sys/class/net/$iface") {
 
     PVE::Tools::run_command("/sbin/ip link set dev $iface up mtu $bridgemtu");
     PVE::Tools::run_command("/sbin/ip addr add 0.0.0.0/0 dev $iface");
-    PVE::Network::tap_plug($iface, $bridge, $tag, $firewall);
+    PVE::Network::tap_plug($iface, $bridge, $tag, $firewall, $trunks);
 }
 
 exit 0;