]> git.proxmox.com Git - pve-container.git/blobdiff - src/lxcnetaddbr
tests: add alpine 3.13 test for network config
[pve-container.git] / src / lxcnetaddbr
index a297bf241fbae589fe304e81b1d4c29a3824c653..8bd9d227bcfaab2b839a4ee12cf4129e284e8c74 100755 (executable)
@@ -10,6 +10,12 @@ use PVE::Tools qw(run_command);
 use PVE::Network;
 use PVE::ProcFSTools;
 
+my $have_sdn;
+eval {
+    require PVE::Network::SDN::Zones;
+    $have_sdn = 1;
+};
+
 die "got unexpected argument count\n" if scalar(@ARGV) != 5;
 
 my ($vmid, $arg2, $arg3, $type, $iface) = @ARGV;
@@ -18,7 +24,7 @@ die "got unexpected argument ($arg2 != net)\n" if $arg2 ne 'net';
 die "got unexpected argument ($arg3 != up)\n" if $arg3 ne 'up';
 
 die "got unexpected argument ($type != veth)\n" if $type ne 'veth';
-    
+
 die "got unexpected environment" if $vmid ne $ENV{LXC_NAME};
 
 die "missing vmid parameter\n" if !$vmid;
@@ -35,12 +41,13 @@ if ($iface =~ m/^veth(\d+)i(\d+)$/) {
 die "unable to find network definition for interface '$iface'\n"
     if !defined($netconf);
 
-my $net = PVE::LXC::parse_lxc_network($netconf);
-    
+my $net = PVE::LXC::Config->parse_lxc_network($netconf);
+
 my $tag = $net->{tag};
 my $firewall = $net->{firewall};
 my $bridge = $net->{bridge};
 my $trunks = $net->{trunks};
+my $rate = $net->{rate};
 
 die "missing bridge configuration" if !$bridge;
 
@@ -53,7 +60,12 @@ 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, $trunks);
+
+    if ($have_sdn) {
+       PVE::Network::SDN::Zones::tap_plug($iface, $net->{bridge}, $tag, $firewall, $trunks, $rate);
+    } else {
+       PVE::Network::tap_plug($iface, $bridge, $tag, $firewall, $trunks, $rate);
+    }
 }
 
 exit 0;