[pve-devel] [PATCH firewall] Add disable_ndp option and default to NDP enabled
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Feb 17 14:01:46 CET 2016
---
src/PVE/API2/Firewall/Host.pm | 7 ++++++-
src/PVE/Firewall.pm | 14 +++++++++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/PVE/API2/Firewall/Host.pm b/src/PVE/API2/Firewall/Host.pm
index 37a63b7..ee0de8e 100644
--- a/src/PVE/API2/Firewall/Host.pm
+++ b/src/PVE/API2/Firewall/Host.pm
@@ -84,7 +84,12 @@ my $option_properties = {
type => 'integer',
optional => 1,
minimum => 7875,
- }
+ },
+ disable_ndp => {
+ description => "Disable NDP.",
+ type => 'boolean',
+ optional => 1,
+ },
};
my $add_option_properties = sub {
diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index 5b94052..bf86b03 100644
--- a/src/PVE/Firewall.pm
+++ b/src/PVE/Firewall.pm
@@ -1869,6 +1869,16 @@ sub ruleset_add_chain_policy {
}
}
+sub ruleset_chain_add_ndp {
+ my ($ruleset, $chain, $ipversion, $options) = @_;
+ return if $ipversion != 6 || $options->{disable_ndp};
+
+ ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type router-solicitation");
+ ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type router-advertisement");
+ ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type neighbor-solicitation");
+ ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type neighbor-advertisement");
+}
+
sub ruleset_chain_add_conn_filters {
my ($ruleset, $chain, $accept) = @_;
@@ -2095,6 +2105,7 @@ 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_input_filters($ruleset, $chain, $ipversion, $options, $cluster_conf, $loglevel);
@@ -2153,6 +2164,7 @@ 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
@@ -2353,7 +2365,7 @@ sub parse_hostfw_option {
my $loglevels = "emerg|alert|crit|err|warning|notice|info|debug|nolog";
- if ($line =~ m/^(enable|nosmurfs|tcpflags):\s*(0|1)\s*$/i) {
+ if ($line =~ m/^(enable|nosmurfs|tcpflags|disable_ndp):\s*(0|1)\s*$/i) {
$opt = lc($1);
$value = int($2);
} elsif ($line =~ m/^(log_level_in|log_level_out|tcp_flags_log_level|smurf_log_level):\s*(($loglevels)\s*)?$/i) {
--
2.1.4
More information about the pve-devel
mailing list