]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Add support for hop limit
authorRaphaël Pinson <raphael.pinson@camptocamp.com>
Thu, 30 May 2013 11:37:53 +0000 (13:37 +0200)
committerGeorg Koester <georg.koester@gmail.com>
Wed, 10 Jul 2013 09:23:52 +0000 (02:23 -0700)
lib/puppet/provider/firewall/ip6tables.rb
lib/puppet/type/firewall.rb
spec/fixtures/ip6tables/conversion_hash.rb

index 8e34fbe1705e6a402ad92b8944d87c83775c65e8..1a7b16c71ab1057198ef78fc782ae6d8944d7944 100644 (file)
@@ -2,6 +2,7 @@ Puppet::Type.type(:firewall).provide :ip6tables, :parent => :iptables, :source =
   @doc = "Ip6tables type provider"
 
   has_feature :iptables
+  has_feature :hop_limiting
   has_feature :rate_limiting
   has_feature :snat
   has_feature :dnat
@@ -42,6 +43,7 @@ Puppet::Type.type(:firewall).provide :ip6tables, :parent => :iptables, :source =
     :icmp => "-m icmp6 --icmpv6-type",
     :iniface => "-i",
     :jump => "-j",
+    :hop_limit => "-m hl --hl-eq",
     :limit => "-m limit --limit",
     :log_level => "--log-level",
     :log_prefix => "--log-prefix",
@@ -83,7 +85,8 @@ Puppet::Type.type(:firewall).provide :ip6tables, :parent => :iptables, :source =
   # I put it when calling the command. So compability with manual changes
   # not provided with current parser [georg.koester])
   @resource_list = [:table, :source, :destination, :iniface, :outiface,
-    :proto, :ishasmorefrags, :islastfrag, :isfirstfrag, :gid, :uid, :sport, :dport, :port, :pkttype, :name, :state, :icmp, :limit, :burst, :jump,
+    :proto, :ishasmorefrags, :islastfrag, :isfirstfrag, :gid, :uid, :sport, :dport,
+    :port, :pkttype, :name, :state, :icmp, :hop_limit, :limit, :burst, :jump,
     :todest, :tosource, :toports, :log_level, :log_prefix, :reject]
 
   # These are known booleans that do not take a value, but we want to munge
index 1c6f7732fb7710d46c9a1c7bf98d78d421e8d80a..685f7e9161cae7c94c05ce661dd936cc0d332325 100644 (file)
@@ -28,6 +28,7 @@ Puppet::Type.newtype(:firewall) do
     installed.
   EOS
 
+  feature :hop_limiting, "Hop limiting features."
   feature :rate_limiting, "Rate limiting features."
   feature :snat, "Source NATing"
   feature :dnat, "Destination NATing"
@@ -552,6 +553,14 @@ Puppet::Type.newtype(:firewall) do
     end
   end
 
+  # Hop limiting properties
+  newproperty(:hop_limit, :required_features => :hop_limiting) do
+    desc <<-EOS
+      Hop limiting value for matched packets.
+    EOS
+    newvalue(/^\d+$/)
+  end
+
   # Rate limiting properties
   newproperty(:limit, :required_features => :rate_limiting) do
     desc <<-EOS
index 42816d6081b06fc7d3da718cbce3a890a26930fb..7c507d78bdf1ce3e7b2306b097cec8f07dbb9865 100644 (file)
@@ -95,4 +95,13 @@ HASH_TO_ARGS6 = {
     },
     :args => ["-t", :filter, "-p", :tcp, "-m", "frag", "--fragid", "0", "--fragfirst", "-m", "comment", "--comment", "100 first fragment"],
   },
+  'hop_limit' => {
+    :params => {
+      :name => "100 hop limit",
+      :hop_limit => 255,
+      :provider => 'ip6tables',
+      :table => "filter",
+    },
+    :args => ["-t", :filter, "-p", :tcp, "-m", "comment", "--comment", "100 hop limit", "-m", "hl", "--hl-eq", 255],
+  },
 }