Skip to content

Commit 079e4ff

Browse files
committed
Allowing ICMP types.
1 parent 5f675b3 commit 079e4ff

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/puppet_x/puppetlabs/firewall/utility.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def self.host_to_mask(value, proto)
141141

142142
# Translate the symbolic names for icmp packet types to integers
143143
def self.icmp_name_to_number(value_icmp, protocol)
144-
if value_icmp.to_s.match?(%r{^\d+$})
144+
if value_icmp.to_s.match?(%r{^(\d+|\d+\/\d+)$})
145145
value_icmp.to_s
146146
elsif ['IPv4', 'iptables'].include?(protocol)
147147
# https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml

spec/acceptance/rules_spec.rb

+7
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ class { 'firewall': }
194194
icmp => 'time-exceeded',
195195
jump => 'ACCEPT',
196196
}
197+
firewall { '014 icmp destination-unreachable/fragmentation-needed':
198+
proto => 'icmp',
199+
icmp => '3/4',
200+
jump => 'ACCEPT',
201+
}
202+
197203
firewall { '443 ssl on aliased interface':
198204
proto => 'tcp',
199205
dport => '443',
@@ -260,6 +266,7 @@ class { 'firewall': }
260266
%r{-A INPUT -p (icmp|1) -m icmp --icmp-type 3 -m comment --comment "013 icmp destination-unreachable" -j ACCEPT},
261267
%r{-A INPUT -s 10.0.0.0/(8|255\.0\.0\.0) -p (icmp|1) -m icmp --icmp-type 8 -m comment --comment "013 icmp echo-request" -j ACCEPT},
262268
%r{-A INPUT -p (icmp|1) -m icmp --icmp-type 11 -m comment --comment "013 icmp time-exceeded" -j ACCEPT},
269+
%r{-A INPUT -p (icmp|1) -m icmp --icmp-type 3/4 -m comment --comment "014 icmp destination-unreachable/fragmentation-needed" -j ACCEPT},
263270
%r{-A INPUT -p (tcp|6) -m tcp --dport 22 -m conntrack --ctstate NEW -m comment --comment "020 ssh" -j ACCEPT},
264271
%r{-A INPUT -i eth0:3 -p (tcp|6) -m tcp --dport 443 -m conntrack --ctstate NEW -m comment --comment "443 ssl on aliased interface" -j ACCEPT},
265272
%r{-A INPUT -m comment --comment "900 LOCAL_INPUT" -j LOCAL_INPUT},

spec/unit/puppet_x/puppetlabs/firewall/utility_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
it { expect(utility.icmp_name_to_number('timestamp-reply', proto)).to eql '14' }
144144
it { expect(utility.icmp_name_to_number('address-mask-request', proto)).to eql '17' }
145145
it { expect(utility.icmp_name_to_number('address-mask-reply', proto)).to eql '18' }
146+
it { expect(utility.icmp_name_to_number('3/4', proto)).to eql '3/4' }
146147
end
147148

148149
context 'with proto IPv6' do

0 commit comments

Comments
 (0)