]> git.proxmox.com Git - pve-container.git/commitdiff
net: Pass network config directly to net_tap_plug()
authorChristoph Heiss <c.heiss@proxmox.com>
Wed, 22 Feb 2023 12:49:01 +0000 (13:49 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 16 Mar 2023 11:43:45 +0000 (12:43 +0100)
No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Tested-by:  Friedrich Weber <f.weber@proxmox.com>
src/PVE/LXC.pm
src/lxcnetaddbr

index 54ee0d97a5462608f5789fd127df306e95b45e47..54afd9777c5f0e7b2229463060a3bac82439993d 100644 (file)
@@ -918,15 +918,16 @@ sub vm_stop_cleanup {
     warn $@ if $@; # avoid errors - just warn
 }
 
-sub net_tap_plug : prototype($$$$$$;$) {
-    my ($iface, $bridge, $tag, $firewall, $trunks, $rate, $opts) = @_;
+sub net_tap_plug : prototype($$) {
+    my ($iface, $net) = @_;
+    my ($bridge, $tag, $firewall, $trunks, $rate, $hwaddr) =
+       $net->@{'bridge', 'tag', 'firewall', 'trunks', 'rate', 'hwaddr'};
 
     if ($have_sdn) {
        PVE::Network::SDN::Zones::tap_plug($iface, $bridge, $tag, $firewall, $trunks, $rate);
-       PVE::Network::SDN::Zones::add_bridge_fdb($iface, $opts->{mac}, $bridge, $firewall)
-           if defined($opts->{mac});
+       PVE::Network::SDN::Zones::add_bridge_fdb($iface, $hwaddr, $bridge, $firewall);
     } else {
-       PVE::Network::tap_plug($iface, $bridge, $tag, $firewall, $trunks, $rate, $opts);
+       PVE::Network::tap_plug($iface, $bridge, $tag, $firewall, $trunks, $rate, { mac => $hwaddr });
     }
 }
 
@@ -968,8 +969,7 @@ sub update_net {
                    PVE::LXC::Config->write_config($vmid, $conf);
                }
 
-               my ($bridge, $mac, $firewall, $rate) = $newnet->@{'bridge', 'hwaddr', 'firewall', 'rate'};
-               PVE::LXC::net_tap_plug($veth, $bridge, $newnet->{tag}, $firewall, $newnet->{trunks}, $rate, { mac => $mac });
+               PVE::LXC::net_tap_plug($veth, $newnet);
 
                # This includes the rate:
                foreach (qw(bridge tag firewall rate)) {
@@ -1003,10 +1003,8 @@ sub hotplug_net {
     } else {
        PVE::Network::veth_create($veth, $vethpeer, $newnet->{bridge}, $newnet->{hwaddr});
     }
-    PVE::LXC::net_tap_plug(
-        $veth, $newnet->{bridge}, $newnet->{tag}, $newnet->{firewall}, $newnet->{trunks},
-        $newnet->{rate}, { mac => $newnet->{hwaddr} },
-    );
+
+    PVE::LXC::net_tap_plug($veth, $newnet);
 
     # attach peer in container
     my $cmd = ['lxc-device', '-n', $vmid, 'add', $vethpeer, "$eth" ];
index ebd6baa82c732754320290ba9253ef479f372ea3..f2db43341c0bca892c7ca4073952b6cd7e184a68 100755 (executable)
@@ -36,13 +36,7 @@ die "unable to find network definition for interface '$iface'\n"
 
 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};
-my $hwaddr = $net->{hwaddr};
-
 die "missing bridge configuration" if !$bridge;
 
 if (-d "/sys/class/net/$iface") {
@@ -54,8 +48,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::LXC::net_tap_plug($iface, $bridge, $tag, $firewall, $trunks, $rate, { mac => $hwaddr });
+    PVE::LXC::net_tap_plug($iface, $net);
 }
 
 exit 0;