[pve-devel] [PATCH firewall 3/7] corosync: refactor if conditions

Stefan Reiter s.reiter at proxmox.com
Mon Jul 22 15:21:51 CEST 2019


From: Fabian Grünbichler <f.gruenbichler at proxmox.com>

to remove one level of indentation

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
(cherry picked from commit a9c463ce6917bcccd012bcfc37b1c756a16958cc)
Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
 src/PVE/Firewall.pm | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index c497109..ce3d937 100644
--- a/src/PVE/Firewall.pm
+++ b/src/PVE/Firewall.pm
@@ -2468,14 +2468,11 @@ sub enable_host_firewall {
 
 	PVE::Corosync::for_all_corosync_addresses($corosync_conf, $ipversion, sub {
 	    my ($node_name, $node_ip, $node_ipversion, $key) = @_;
+	    my $destination = $corosync_local_addresses->{$key};
 
-	    if ($node_name ne $local_hostname) {
-		my $destination = $corosync_local_addresses->{$key};
-
+	    if ($node_name ne $local_hostname && defined($destination)) {
 		# accept only traffic on same ring
-		if (defined($destination)) {
-		    ruleset_addrule($ruleset, $chain, "-d $destination -s $node_ip $corosync_rule", "-j $accept_action");
-		}
+		ruleset_addrule($ruleset, $chain, "-d $destination -s $node_ip $corosync_rule", "-j $accept_action");
 	    }
 	});
     }
@@ -2537,14 +2534,11 @@ sub enable_host_firewall {
 
 	PVE::Corosync::for_all_corosync_addresses($corosync_conf, $ipversion, sub {
 	    my ($node_name, $node_ip, $node_ipversion, $key) = @_;
+	    my $source = $corosync_local_addresses->{$key};
 
-	    if ($node_name ne $local_hostname) {
-		my $source = $corosync_local_addresses->{$key};
-
+	    if ($node_name ne $local_hostname && defined($source)) {
 		# accept only traffic on same ring
-		if (defined($source)) {
-		    ruleset_addrule($ruleset, $chain, "-s $source -d $node_ip $corosync_rule", "-j $accept_action");
-		}
+		ruleset_addrule($ruleset, $chain, "-s $source -d $node_ip $corosync_rule", "-j $accept_action");
 	    }
 	});
     }
-- 
2.20.1





More information about the pve-devel mailing list