]> git.proxmox.com Git - pve-firewall.git/blobdiff - src/PVE/Firewall.pm
ebtables: remove PVE chains properly
[pve-firewall.git] / src / PVE / Firewall.pm
index ef724a7085871580b7bc11807fb29699827561a3..3b67186ed35c18ca7ed62c0f2001c5dbb0e649bb 100644 (file)
@@ -2473,14 +2473,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");
            }
        });
     }
@@ -2542,14 +2539,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");
            }
        });
     }
@@ -3525,7 +3519,8 @@ sub compile {
        $hostfw_conf = load_hostfw_conf($cluster_conf, undef) if !$hostfw_conf;
 
        # cfs_update is handled by daemon or API
-       $corosync_conf = PVE::Cluster::cfs_read_file("corosync.conf") if !$corosync_conf;
+       $corosync_conf = PVE::Cluster::cfs_read_file("corosync.conf")
+           if !defined($corosync_conf) && PVE::Corosync::check_conf_exists(1);
 
        $vmdata = read_local_vm_config();
        $vmfw_configs = read_vm_firewall_configs($cluster_conf, $vmdata, undef);
@@ -4274,6 +4269,7 @@ sub remove_pvefw_chains {
     PVE::Firewall::remove_pvefw_chains_iptables("iptables");
     PVE::Firewall::remove_pvefw_chains_iptables("ip6tables");
     PVE::Firewall::remove_pvefw_chains_ipset();
+    PVE::Firewall::remove_pvefw_chains_ebtables();
 
 }
 
@@ -4319,6 +4315,11 @@ sub remove_pvefw_chains_ipset {
     ipset_restore_cmdlist($cmdlist) if $cmdlist;
 }
 
+sub remove_pvefw_chains_ebtables {
+    # apply empty ruleset = remove all our chains
+    ebtables_restore_cmdlist(get_ebtables_cmdlist({}));
+}
+
 sub init {
     my $cluster_conf = load_clusterfw_conf();
     my $cluster_options = $cluster_conf->{options};