Skip to content

Commit dca6c22

Browse files
authored
Merge pull request #1194 from gcoxmoz/tcp-reset
Add `tcp-reset` as an allowed option for `--reject-with`
2 parents 3e8717d + c947ced commit dca6c22

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

REFERENCE.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,13 +1267,15 @@ Data type: `Optional[Enum['set', 'update', 'rcheck', 'remove', '! set', '! updat
12671267

12681268
Data type: `Optional[Enum['icmp-net-unreachable', 'icmp-host-unreachable', 'icmp-port-unreachable', 'icmp-proto-unreachable',
12691269
'icmp-net-prohibited', 'icmp-host-prohibited', 'icmp-admin-prohibited', 'icmp6-no-route', 'no-route',
1270-
'icmp6-adm-prohibited', 'adm-prohibited', 'icmp6-addr-unreachable', 'addr-unreach', 'icmp6-port-unreachable']]`
1270+
'icmp6-adm-prohibited', 'adm-prohibited', 'icmp6-addr-unreachable', 'addr-unreach', 'icmp6-port-unreachable',
1271+
'tcp-reset']]`
12711272

12721273
When combined with jump => "REJECT" you can specify a different icmp response to be sent back to the packet sender.
12731274
Valid values differ depending on if the protocol is `IPv4` or `IPv6`.
12741275
IPv4 allows: icmp-net-unreachable, icmp-host-unreachable, icmp-port-unreachable, icmp-proto-unreachable, icmp-net-prohibited,
1275-
icmp-host-prohibited, or icmp-admin-prohibited.
1276-
IPv6 allows: icmp6-no-route, no-route, icmp6-adm-prohibited, adm-prohibited, icmp6-addr-unreachable, addr-unreach, or icmp6-port-unreachable.
1276+
icmp-host-prohibited, icmp-admin-prohibited, or tcp-reset.
1277+
IPv6 allows: icmp6-no-route, no-route, icmp6-adm-prohibited, adm-prohibited, icmp6-addr-unreachable, addr-unreach,
1278+
icmp6-port-unreachable, or tcp-reset.
12771279

12781280
##### `rhitcount`
12791281

lib/puppet/type/firewall.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,13 +1261,15 @@
12611261
reject: {
12621262
type: "Optional[Enum['icmp-net-unreachable', 'icmp-host-unreachable', 'icmp-port-unreachable', 'icmp-proto-unreachable',
12631263
'icmp-net-prohibited', 'icmp-host-prohibited', 'icmp-admin-prohibited', 'icmp6-no-route', 'no-route',
1264-
'icmp6-adm-prohibited', 'adm-prohibited', 'icmp6-addr-unreachable', 'addr-unreach', 'icmp6-port-unreachable']]",
1264+
'icmp6-adm-prohibited', 'adm-prohibited', 'icmp6-addr-unreachable', 'addr-unreach', 'icmp6-port-unreachable',
1265+
'tcp-reset']]",
12651266
desc: <<-DESC
12661267
When combined with jump => "REJECT" you can specify a different icmp response to be sent back to the packet sender.
12671268
Valid values differ depending on if the protocol is `IPv4` or `IPv6`.
12681269
IPv4 allows: icmp-net-unreachable, icmp-host-unreachable, icmp-port-unreachable, icmp-proto-unreachable, icmp-net-prohibited,
1269-
icmp-host-prohibited, or icmp-admin-prohibited.
1270-
IPv6 allows: icmp6-no-route, no-route, icmp6-adm-prohibited, adm-prohibited, icmp6-addr-unreachable, addr-unreach, or icmp6-port-unreachable.
1270+
icmp-host-prohibited, icmp-admin-prohibited, or tcp-reset.
1271+
IPv6 allows: icmp6-no-route, no-route, icmp6-adm-prohibited, adm-prohibited, icmp6-addr-unreachable, addr-unreach,
1272+
icmp6-port-unreachable, or tcp-reset.
12711273
DESC
12721274
},
12731275
set_mark: {

spec/acceptance/firewall_attributes_happy_path_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ class { '::firewall': }
239239
chain => 'FORWARD',
240240
table => 'mangle',
241241
}
242+
firewall { '605 - reject with tcp-reset':
243+
proto => tcp,
244+
jump => reject,
245+
reject => 'tcp-reset',
246+
}
247+
242248
firewall { '700 - blah-A Test Rule':
243249
jump => 'LOG',
244250
log_prefix => 'FW-A-INPUT: ',
@@ -477,6 +483,10 @@ class { '::firewall': }
477483
expect(result.stdout).to match(%r{-A FORWARD -p (tcp|6) -m tcp --tcp-flags SYN,RST SYN -m tcpmss --mss 1361:1541 -m comment --comment "604 - set_mss" -j TCPMSS --set-mss 1360})
478484
end
479485

486+
it 'tcp-reset is set' do
487+
expect(result.stdout).to match(%r{-A INPUT -p (tcp|6) -m comment --comment "605 - reject with tcp-reset" -j REJECT --reject-with tcp-reset})
488+
end
489+
480490
it 'clamp_mss_to_pmtu is set' do
481491
expect(result.stdout).to match(%r{-A FORWARD -p (tcp|6) -m tcp --tcp-flags SYN,RST SYN -m comment --comment "601 - clamp_mss_to_pmtu" -j TCPMSS --clamp-mss-to-pmtu})
482492
end

spec/acceptance/firewall_attributes_ipv6_happy_path_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ class { '::firewall': }
217217
src_type => ['LOCAL', '! LOCAL'],
218218
protocol => 'ip6tables',
219219
}
220+
firewall { '621 - reject with tcp-reset':
221+
proto => tcp,
222+
jump => reject,
223+
reject => 'tcp-reset',
224+
protocol => 'ip6tables',
225+
}
220226
firewall { '801 - ipt_modules tests':
221227
proto => tcp,
222228
dport => '8080',
@@ -396,6 +402,10 @@ class { '::firewall': }
396402
expect(result.stdout).to match(%r{-A INPUT -p (tcp|6) -m addrtype --src-type LOCAL -m addrtype ! --src-type LOCAL -m comment --comment "620 - src_type multiple values" -j ACCEPT})
397403
end
398404

405+
it 'tcp-reset is set' do
406+
expect(result.stdout).to match(%r{-A INPUT -p (tcp|6) -m comment --comment "621 - reject with tcp-reset" -j REJECT --reject-with tcp-reset})
407+
end
408+
399409
it 'all the modules with multiple args is set' do
400410
expect(result.stdout).to match(%r{-A OUTPUT -p (tcp|6) -m physdev\s+--physdev-in eth0 --physdev-out eth1 --physdev-is-bridged -m iprange --src-range 2001::-2002::\s+--dst-range 2003::-2004:: -m owner --uid-owner (0|root) --gid-owner 404 -m tcp --dport 8080 -m addrtype --src-type LOCAL -m addrtype --dst-type UNICAST -m comment --comment "801 - ipt_modules tests" -j REJECT --reject-with icmp6-port-unreachable}) # rubocop:disable Layout/LineLength
401411
end

0 commit comments

Comments
 (0)