From: Thomas Lamprecht Date: Sun, 13 Nov 2022 12:37:45 +0000 (+0100) Subject: net devs: code cleanup new fdb mac add helper X-Git-Url: https://git.proxmox.com/?p=qemu-server.git;a=commitdiff_plain;h=1b5ba4ddc63f7e0b916131c7882f638c49cd4558 net devs: code cleanup new fdb mac add helper reduce a level of indentation and modernize slightly Signed-off-by: Thomas Lamprecht --- diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index ed42bd9..2733755 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -8316,19 +8316,18 @@ sub check_volume_storage_type { sub add_nets_bridge_fdb { my ($conf, $vmid) = @_; - foreach my $opt (keys %$conf) { - if ($opt =~ m/^net(\d+)$/) { - my $net = parse_net($conf->{$opt}); - next if !$net; - next if !$net->{macaddr}; + for my $opt (keys %$conf) { + next if $opt !~ m/^net(\d+)$/; + my $iface = "tap${vmid}i$1"; + my $net = parse_net($conf->{$opt}) or next; + my $mac = $net->{macaddr} or next; - my $iface = "tap${vmid}i$1"; - if ($have_sdn) { - PVE::Network::SDN::Zones::add_bridge_fdb($iface, $net->{macaddr}, $net->{bridge}, $net->{firewall}); - } else { - PVE::Network::add_bridge_fdb($iface, $net->{macaddr}, $net->{firewall}); - } + if ($have_sdn) { + PVE::Network::SDN::Zones::add_bridge_fdb($iface, $mac, $net->{bridge}, $net->{firewall}); + } else { + PVE::Network::add_bridge_fdb($iface, $mac, $net->{firewall}); } } } + 1;