all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v4 container 1/3] net: Pass network config directly to net_tap_plug()
Date: Wed, 22 Feb 2023 13:49:01 +0100	[thread overview]
Message-ID: <20230222124903.326612-2-c.heiss@proxmox.com> (raw)
In-Reply-To: <20230222124903.326612-1-c.heiss@proxmox.com>

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Changes v3 -> v4:
 * New patch

A note: The check in net_tap_plug() whether the MAC address is actually
passed in $opts is removed, as this was always the case anyway.

 src/PVE/LXC.pm  | 20 +++++++++-----------
 src/lxcnetaddbr |  9 +--------
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 54ee0d9..54afd97 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -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" ];
diff --git a/src/lxcnetaddbr b/src/lxcnetaddbr
index ebd6baa..f2db433 100755
--- a/src/lxcnetaddbr
+++ b/src/lxcnetaddbr
@@ -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;
--
2.39.1





  reply	other threads:[~2023-02-22 12:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-22 12:49 [pve-devel] [PATCH v4 container/manager 0/3] fix #3413: Add `Disconnect` option for LXC networks Christoph Heiss
2023-02-22 12:49 ` Christoph Heiss [this message]
2023-02-22 12:49 ` [pve-devel] [PATCH v4 container 2/3] net: Add `link_down` config to allow setting interfaces as disconnected Christoph Heiss
2023-02-22 12:49 ` [pve-devel] [PATCH v4 manager 3/3] lxc: Add `Disconnect` option for network interfaces Christoph Heiss
2023-03-16 15:06   ` [pve-devel] applied: " Wolfgang Bumiller
2023-02-23 13:54 ` [pve-devel] [PATCH v4 container/manager 0/3] fix #3413: Add `Disconnect` option for LXC networks Friedrich Weber
2023-03-16 11:51 ` [pve-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230222124903.326612-2-c.heiss@proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal