[pve-devel] [PATCH v2 firewall 1/2] Add ndp option to host and VM firewall options
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Feb 19 09:43:32 CET 2016
It's is enabled by default.
---
Changes sicne v1:
It's now a host-level as well as VM-level option
The option name changed from 'disable_ndp' with default 0 to just 'ndp' with
default 1.
Added a patch to include router-solicitation in the NeighborDiscovery macro.
src/PVE/API2/Firewall/Host.pm | 7 ++++++-
src/PVE/API2/Firewall/VM.pm | 5 +++++
src/PVE/Firewall.pm | 18 ++++++++++++++++--
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/src/PVE/API2/Firewall/Host.pm b/src/PVE/API2/Firewall/Host.pm
index 37a63b7..130ca02 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,
- }
+ },
+ ndp => {
+ description => "Enable NDP.",
+ type => 'boolean',
+ optional => 1,
+ },
};
my $add_option_properties = sub {
diff --git a/src/PVE/API2/Firewall/VM.pm b/src/PVE/API2/Firewall/VM.pm
index f483491..9cca0c6 100644
--- a/src/PVE/API2/Firewall/VM.pm
+++ b/src/PVE/API2/Firewall/VM.pm
@@ -28,6 +28,11 @@ my $option_properties = {
type => 'boolean',
optional => 1,
},
+ ndp => {
+ description => "Enable NDP.",
+ type => 'boolean',
+ optional => 1,
+ },
policy_in => {
description => "Input policy.",
type => 'string',
diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm
index 5b94052..25f1cc9 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 || (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-advertisement -j 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");
+}
+
sub ruleset_chain_add_conn_filters {
my ($ruleset, $chain, $accept) = @_;
@@ -1931,6 +1941,8 @@ sub ruleset_create_vm_chain {
}
+ ruleset_chain_add_ndp($ruleset, $chain, $ipversion, $options);
+
if ($direction eq 'OUT') {
if (defined($macaddr) && !(defined($options->{macfilter}) && $options->{macfilter} == 0)) {
ruleset_addrule($ruleset, $chain, "-m mac ! --mac-source $macaddr -j DROP");
@@ -2095,6 +2107,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 +2166,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
@@ -2327,7 +2341,7 @@ sub parse_vmfw_option {
my $loglevels = "emerg|alert|crit|err|warning|notice|info|debug|nolog";
- if ($line =~ m/^(enable|dhcp|macfilter|ips):\s*(0|1)\s*$/i) {
+ if ($line =~ m/^(enable|dhcp|ndp|macfilter|ips):\s*(0|1)\s*$/i) {
$opt = lc($1);
$value = int($2);
} elsif ($line =~ m/^(log_level_in|log_level_out):\s*(($loglevels)\s*)?$/i) {
@@ -2353,7 +2367,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|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