[pve-devel] [PATCH] cleanup ips detection

Alexandre Derumier aderumier at odiso.com
Wed Mar 26 13:26:54 CET 2014


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 src/PVE/Firewall.pm |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index d378c4f..630e5c4 100644
--- a/src/PVE/Firewall.pm
+++ b/src/PVE/Firewall.pm
@@ -1999,8 +1999,6 @@ sub compile {
 
     enable_host_firewall($ruleset, $hostfw_conf, $groups_conf) if $hostfw_enable;
 
-    my $ips_enable = undef;
-
     # generate firewall rules for QEMU VMs
     foreach my $vmid (keys %{$vmdata->{qemu}}) {
 	my $conf = $vmdata->{qemu}->{$vmid};
@@ -2008,8 +2006,6 @@ sub compile {
 	next if !$vmfw_conf;
 	next if defined($vmfw_conf->{options}->{enable}) && ($vmfw_conf->{options}->{enable} == 0);
 
-	$ips_enable = 1 if $vmfw_conf->{options}->{ips};
-
 	foreach my $netid (keys %$conf) {
 	    next if $netid !~ m/^net(\d+)$/;
 	    my $net = PVE::QemuServer::parse_net($conf->{$netid});
@@ -2039,8 +2035,6 @@ sub compile {
 	next if !$vmfw_conf;
 	next if defined($vmfw_conf->{options}->{enable}) && ($vmfw_conf->{options}->{enable} == 0);
 
-	$ips_enable = 1 if $vmfw_conf->{options}->{ips};
-
 	if ($conf->{ip_address} && $conf->{ip_address}->{value}) {
 	    my $ip = $conf->{ip_address}->{value};
 	    generate_venet_rules_direction($ruleset, $groups_conf, $vmfw_conf, $vmid, $ip, 'IN');
@@ -2071,7 +2065,7 @@ sub compile {
 
     if($hostfw_options->{optimize}){
 
-	my $accept = $ips_enable ? "PVEFW-IPS" : "ACCEPT";
+	my $accept = ruleset_chain_exist($ruleset, "PVEFW-IPS") ? "PVEFW-IPS" : "ACCEPT";
 	ruleset_insertrule($ruleset, "PVEFW-FORWARD", "-m conntrack --ctstate RELATED,ESTABLISHED -j $accept");
 	ruleset_insertrule($ruleset, "PVEFW-FORWARD", "-m conntrack --ctstate INVALID -j DROP");
     }
-- 
1.7.10.4




More information about the pve-devel mailing list