[pve-devel] [PATCH firewall 3/7] ndp: use PVEFW-SET-ACCEPT-MARK and move rules further down
Wolfgang Bumiller
w.bumiller at proxmox.com
Tue Mar 1 12:20:17 CET 2016
On host level: moved NDP to after connection tracking and
switched to RETURN instead of ACCEPT.
On VM level:
The output direction now uses the accept-mark like the dhcp
option does, too.
Also moved NDP rules below the macfilter & ipset rules.
---
src/PVE/Firewall.pm | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index ae47197..eaead51 100644
--- a/src/PVE/Firewall.pm
+++ b/src/PVE/Firewall.pm
@@ -1883,15 +1883,15 @@ sub ruleset_add_chain_policy {
}
sub ruleset_chain_add_ndp {
- my ($ruleset, $chain, $ipversion, $options, $direction) = @_;
+ my ($ruleset, $chain, $ipversion, $options, $direction, $accept) = @_;
return if $ipversion != 6 || (defined($options->{ndp}) && !$options->{ndp});
- ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type router-solicitation -j ACCEPT");
+ ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type router-solicitation $accept");
if ($direction ne 'OUT' || $options->{radv}) {
- ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type router-advertisement -j ACCEPT");
+ ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type router-advertisement $accept");
}
- ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type neighbor-solicitation -j ACCEPT");
- ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT");
+ ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type neighbor-solicitation $accept");
+ ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type neighbor-advertisement $accept");
}
sub ruleset_chain_add_conn_filters {
@@ -1956,8 +1956,6 @@ sub ruleset_create_vm_chain {
}
- ruleset_chain_add_ndp($ruleset, $chain, $ipversion, $options, $direction);
-
if ($direction eq 'OUT') {
if (defined($macaddr) && !(defined($options->{macfilter}) && $options->{macfilter} == 0)) {
ruleset_addrule($ruleset, $chain, "-m mac ! --mac-source $macaddr -j DROP");
@@ -1970,6 +1968,9 @@ sub ruleset_create_vm_chain {
}
ruleset_addrule($ruleset, $chain, "-j MARK --set-mark 0"); # clear mark
}
+
+ my $accept_action = $direction eq 'OUT' ? '-g PVEFW-SET-ACCEPT-MARK' : "-j $accept";
+ ruleset_chain_add_ndp($ruleset, $chain, $ipversion, $options, $direction, $accept_action);
}
sub ruleset_add_group_rule {
@@ -2125,8 +2126,8 @@ sub enable_host_firewall {
ruleset_addrule($ruleset, $chain, "-i lo -j ACCEPT");
- ruleset_chain_add_ndp($ruleset, $chain, $ipversion, $options);
ruleset_chain_add_conn_filters($ruleset, $chain, 'ACCEPT');
+ ruleset_chain_add_ndp($ruleset, $chain, $ipversion, $options, 'IN', '-j RETURN');
ruleset_chain_add_input_filters($ruleset, $chain, $ipversion, $options, $cluster_conf, $loglevel);
# we use RETURN because we need to check also tap rules
@@ -2184,11 +2185,11 @@ sub enable_host_firewall {
ruleset_addrule($ruleset, $chain, "-o lo -j ACCEPT");
- ruleset_chain_add_ndp($ruleset, $chain, $ipversion, $options);
ruleset_chain_add_conn_filters($ruleset, $chain, 'ACCEPT');
# we use RETURN because we may want to check other thigs later
$accept_action = 'RETURN';
+ ruleset_chain_add_ndp($ruleset, $chain, $ipversion, $options, 'OUT', "-j $accept_action");
ruleset_addrule($ruleset, $chain, "-p igmp -j $accept_action"); # important for multicast
--
2.1.4
More information about the pve-devel
mailing list