]> git.proxmox.com Git - pve-firewall.git/commitdiff
Add radv option to VM options.
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 25 Feb 2016 12:07:02 +0000 (13:07 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 7 Mar 2016 13:01:06 +0000 (14:01 +0100)
By default firewalled VMs should not be allowed to send
router advertisement packets.

src/PVE/API2/Firewall/VM.pm
src/PVE/Firewall.pm

index 9cca0c66084f69e6651d95d4bd774bcba64d3815..aad973bb33e2fe9bedeb886845d995be9725935f 100644 (file)
@@ -33,6 +33,11 @@ my $option_properties = {
        type => 'boolean',
        optional => 1,
     },
+    radv => {
+       description => "Allow sending Router Advertisement.",
+       type => 'boolean',
+       optional => 1,
+    },
     policy_in => {
        description => "Input policy.",
        type => 'string',
index 5ec5c81562002b7d583fe6e61922e49fcc65c505..e9b9ac3fd2d6a1610208317199a916845fb9d760 100644 (file)
@@ -1877,11 +1877,13 @@ sub ruleset_add_chain_policy {
 }
 
 sub ruleset_chain_add_ndp {
-    my ($ruleset, $chain, $ipversion, $options) = @_;
+    my ($ruleset, $chain, $ipversion, $options, $direction) = @_;
     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");
+    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 neighbor-solicitation -j ACCEPT");
     ruleset_addrule($ruleset, $chain, "-p icmpv6 --icmpv6-type neighbor-advertisement -j ACCEPT");
 }
@@ -1935,12 +1937,15 @@ sub ruleset_create_vm_chain {
        }
     }
 
-    ruleset_chain_add_ndp($ruleset, $chain, $ipversion, $options);
+    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");
        }
+       if ($ipversion == 6 && !$options->{radv}) {
+           ruleset_addrule($ruleset, $chain, '-p icmpv6 --icmpv6-type router-advertisement -j DROP');
+       }
        if ($ipfilter_ipset) {
            ruleset_addrule($ruleset, $chain, "-m set ! --match-set $ipfilter_ipset src -j DROP");
        }
@@ -2377,7 +2382,7 @@ sub parse_vmfw_option {
 
     my $loglevels = "emerg|alert|crit|err|warning|notice|info|debug|nolog";
 
-    if ($line =~ m/^(enable|dhcp|ndp|macfilter|ips):\s*(0|1)\s*$/i) {
+    if ($line =~ m/^(enable|dhcp|ndp|radv|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) {