[pve-devel] [PATCH] Commits for feature request documented here, http://pve.proxmox.com/pipermail/pve-devel/2014-September/012730.html This introduces functionality to use a single multi-tagged interface within a guest (ie. for routers/firewalls)

Ben Lessani ben at sonassi.com
Mon Sep 15 19:49:07 CEST 2014


Signed-off-by: Ben Lessani <ben at sonassi.com>
---
 data/PVE/Network.pm |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/data/PVE/Network.pm b/data/PVE/Network.pm
index b141d09..c0d0cdc 100644
--- a/data/PVE/Network.pm
+++ b/data/PVE/Network.pm
@@ -113,10 +113,11 @@ my $bridge_add_interface = sub {
 };
 
 my $ovs_bridge_add_port = sub {
-    my ($bridge, $iface, $tag, $internal) = @_;
-
+    my ($bridge, $iface, $tag, $internal, $trunks) = @_;
     my $cmd = "/usr/bin/ovs-vsctl add-port $bridge $iface";
+    $trunks =~ s/;/,/g if $trunks;    
     $cmd .= " tag=$tag" if $tag;
+    $cmd .= " trunk=$trunks" if $trunks;
     $cmd .= " -- set Interface $iface type=internal" if $internal;
     system($cmd) == 0 ||
 	die "can't add ovs port '$iface'\n";
@@ -171,7 +172,7 @@ my $create_firewall_bridge_linux = sub {
 };
 
 my $create_firewall_bridge_ovs = sub {
-    my ($iface, $bridge, $tag) = @_;
+    my ($iface, $bridge, $tag, $trunks) = @_;
 
     my ($vmid, $devid) = &$parse_tap_devive_name($iface);
     my ($fwbr, undef, undef, $ovsintport) = &$compute_fwbr_names($vmid, $devid);
@@ -183,7 +184,7 @@ my $create_firewall_bridge_ovs = sub {
 
     &$bridge_add_interface($fwbr, $iface);
 
-    &$ovs_bridge_add_port($bridge, $ovsintport, $tag, 1);
+    &$ovs_bridge_add_port($bridge, $ovsintport, $tag, 1, $trunks);
 
     # set the same mtu for ovs int port
     PVE::Tools::run_command("/sbin/ifconfig $ovsintport mtu $bridgemtu");
@@ -216,7 +217,7 @@ my $cleanup_firewall_bridge = sub {
 };
 
 sub tap_plug {
-    my ($iface, $bridge, $tag, $firewall) = @_;
+    my ($iface, $bridge, $tag, $firewall, $trunks) = @_;
 
     #cleanup old port config from any openvswitch bridge
     eval {run_command("/usr/bin/ovs-vsctl del-port $iface", outfunc => sub {}, errfunc => sub {}) };
@@ -234,9 +235,9 @@ sub tap_plug {
 	&$cleanup_firewall_bridge($iface); # remove stale devices
 
 	if ($firewall) {
-	    &$create_firewall_bridge_ovs($iface, $bridge, $tag);
+        &$create_firewall_bridge_ovs($iface, $bridge, $tag, $trunks);
 	} else {
-	    &$ovs_bridge_add_port($bridge, $iface, $tag);
+        &$ovs_bridge_add_port($bridge, $iface, $tag, 0, $trunks);
 	}
     }
 }
-- 
1.7.10.4




More information about the pve-devel mailing list