Skip to content

Commit d33e390

Browse files
authored
Revert "Add negate to match_mark"
1 parent 0fdc9ba commit d33e390

File tree

2 files changed

+6
-30
lines changed

2 files changed

+6
-30
lines changed

lib/puppet/type/firewall.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,33 +1481,28 @@ def insync?(is)
14811481
desc <<-PUPPETCODE
14821482
Match the Netfilter mark value associated with the packet. Accepts either of:
14831483
mark/mask or mark. These will be converted to hex if they are not already.
1484-
1485-
match_mark => '0x02'
1486-
1487-
You can also negate a value by putting ! in front. For example:
1488-
1489-
match_mark => '! 0x02'
14901484
PUPPETCODE
14911485
munge do |value|
1492-
mark_regex = %r{\A(!\s)?((?:0x)?[0-9A-F]+)(/)?((?:0x)?[0-9A-F]+)?\z}i
1486+
mark_regex = %r{\A((?:0x)?[0-9A-F]+)(/)?((?:0x)?[0-9A-F]+)?\z}i
14931487
match = value.to_s.match(mark_regex)
14941488
if match.nil?
14951489
raise ArgumentError, 'Match MARK value must be integer or hex between 0 and 0xffffffff'
14961490
end
1497-
mark = @resource.to_hex32(match[2])
1491+
mark = @resource.to_hex32(match[1])
14981492

14991493
# Values that can't be converted to hex.
15001494
# Or contain a trailing slash with no mask.
1501-
if mark.nil? || (mark && match[3] && match[4].nil?)
1495+
if mark.nil? || (mark && match[2] && match[3].nil?)
15021496
raise ArgumentError, 'Match MARK value must be integer or hex between 0 and 0xffffffff'
15031497
end
15041498

15051499
# There should not be a mask on match_mark
1506-
unless match[4].nil?
1500+
unless match[3].nil?
15071501
raise ArgumentError, 'iptables does not support masks on MARK match rules'
15081502
end
1503+
value = mark
15091504

1510-
match[1] ? "! #{mark}" : mark
1505+
value
15111506
end
15121507
end
15131508

spec/acceptance/firewall_attributes_exceptions_spec.rb

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,25 +1251,6 @@ class { '::firewall': }
12511251
expect(r.stdout).to match(%r{-A INPUT -m mark --mark 0x1 -m comment --comment "503 match_mark - test" -j REJECT --reject-with icmp-port-unreachable})
12521252
end
12531253
end
1254-
1255-
context 'when ! 0x1' do
1256-
pp1 = <<-PUPPETCODE
1257-
class { '::firewall': }
1258-
firewall { '504 match_mark - negate test':
1259-
proto => 'all',
1260-
match_mark => '! 0x1',
1261-
action => reject,
1262-
}
1263-
PUPPETCODE
1264-
it 'applies' do
1265-
apply_manifest(pp1, catch_failures: true)
1266-
end
1267-
1268-
it 'contains the rule' do
1269-
run_shell('iptables-save') do |r|
1270-
expect(r.stdout).to match(%r{-A INPUT -m mark --mark ! 0x1 -m comment --comment "504 match_mark - negate test" -j REJECT --reject-with icmp-port-unreachable})
1271-
end
1272-
end
12731254
end
12741255
end
12751256

0 commit comments

Comments
 (0)