Skip to content

Commit c8b9a79

Browse files
committed
support --nflog-size as replacement for --nflog-range
--nflog-range was deprecated way back in 2016. https://git.netfilter.org/iptables/commit/?h=v1.6.1&id=7070b1f3c88a0c3d4e315c00cca61f05b0fbc882
1 parent 61ee4dd commit c8b9a79

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ firewall {'666 for NFLOG':
385385
jump => 'NFLOG',
386386
nflog_group => 3,
387387
nflog_prefix => 'nflog-test',
388-
nflog_range => 256,
388+
nflog_size => 256,
389389
nflog_threshold => 1,
390390
}
391391
```

lib/puppet/provider/firewall/ip6tables.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
has_feature :rpfilter
7171
end
7272

73+
if ip6tables_version && Puppet::Util::Package.versioncmp(ip6tables_version, '1.6.1') >= 0
74+
has_feature :nflog_size
75+
end
76+
7377
def initialize(*args)
7478
ip6tables_version = Facter.value('ip6tables_version')
7579
raise ArgumentError, 'The ip6tables provider is not supported on version 1.3 of iptables' if ip6tables_version&.match(%r{1\.3\.\d})
@@ -140,6 +144,7 @@ def self.iptables_save(*args)
140144
nflog_group: '--nflog-group',
141145
nflog_prefix: '--nflog-prefix',
142146
nflog_range: '--nflog-range',
147+
nflog_size: '--nflog-size',
143148
nflog_threshold: '--nflog-threshold',
144149
outiface: '-o',
145150
pkttype: '-m pkttype --pkt-type',
@@ -313,7 +318,9 @@ def self.iptables_save(*args)
313318
:ctorigsrcport, :ctorigdstport, :ctreplsrcport, :ctrepldstport, :ctstatus, :ctexpire, :ctdir,
314319
:icmp, :hop_limit, :limit, :burst, :length, :recent, :rseconds, :reap,
315320
:rhitcount, :rttl, :rname, :mask, :rsource, :rdest, :ipset, :string, :string_hex, :string_algo,
316-
:string_from, :string_to, :jump, :nflog_group, :nflog_prefix, :nflog_range, :nflog_threshold, :clamp_mss_to_pmtu, :gateway, :todest,
321+
:string_from, :string_to, :jump,
322+
:nflog_group, :nflog_prefix, :nflog_range, :nflog_size, :nflog_threshold,
323+
:clamp_mss_to_pmtu, :gateway, :todest,
317324
:tosource, :toports, :checksum_fill, :log_level, :log_prefix, :log_uid, :log_tcp_sequence, :log_tcp_options, :log_ip_options, :random_fully,
318325
:reject, :set_mss, :set_dscp, :set_dscp_class, :mss, :queue_num, :queue_bypass,
319326
:set_mark, :match_mark, :connlimit_above, :connlimit_mask, :connmark, :time_start, :time_stop, :month_days, :week_days, :date_start, :date_stop, :time_contiguous, :kernel_timezone,

lib/puppet/provider/firewall/iptables.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
has_feature :rpfilter
7777
end
7878

79+
if iptables_version && Puppet::Util::Package.versioncmp(iptables_version, '1.6.1') >= 0
80+
has_feature :nflog_size
81+
end
82+
7983
@protocol = 'IPv4'
8084

8185
@resource_map = {
@@ -129,6 +133,7 @@
129133
nflog_group: '--nflog-group',
130134
nflog_prefix: '--nflog-prefix',
131135
nflog_range: '--nflog-range',
136+
nflog_size: '--nflog-size',
132137
nflog_threshold: '--nflog-threshold',
133138
outiface: '-o',
134139
pkttype: '-m pkttype --pkt-type',
@@ -351,7 +356,7 @@ def munge_resource_map_from_resource(resource_map_original, compare)
351356
:rhitcount, :rttl, :rname, :mask, :rsource, :rdest, :ipset, :string, :string_hex, :string_algo,
352357
:string_from, :string_to, :jump, :goto, :clusterip_new, :clusterip_hashmode,
353358
:clusterip_clustermac, :clusterip_total_nodes, :clusterip_local_node, :clusterip_hash_init, :queue_num, :queue_bypass,
354-
:nflog_group, :nflog_prefix, :nflog_range, :nflog_threshold, :clamp_mss_to_pmtu, :gateway,
359+
:nflog_group, :nflog_prefix, :nflog_range, :nflog_size, :nflog_threshold, :clamp_mss_to_pmtu, :gateway,
355360
:set_mss, :set_dscp, :set_dscp_class, :todest, :tosource, :toports, :to, :checksum_fill, :random_fully, :random, :log_prefix,
356361
:log_level, :log_uid, :log_tcp_sequence, :log_tcp_options, :log_ip_options, :reject, :set_mark, :match_mark, :mss, :connlimit_above, :connlimit_mask, :connmark, :time_start, :time_stop,
357362
:month_days, :week_days, :date_start, :date_stop, :time_contiguous, :kernel_timezone,

lib/puppet/type/firewall.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
111111
* nflog_prefix: The ability to set a prefix for nflog messages.
112112
113-
* nflog_range: The ability to set nflog_range.
113+
* nflog_size: Set the max size of a message to send to nflog.
114114
115115
* nflog_threshold: The ability to set nflog_threshold.
116116
@@ -187,6 +187,7 @@
187187
feature :nflog_group, 'netlink group to subscribe to for logging'
188188
feature :nflog_prefix, ''
189189
feature :nflog_range, ''
190+
feature :nflog_size, ''
190191
feature :nflog_threshold, ''
191192
feature :ipset, 'Match against specified ipset list'
192193
feature :clusterip, 'Configure a simple cluster of nodes that share a certain IP and MAC address without an explicit load balancer in front of them.'
@@ -895,10 +896,17 @@ def should_to_s(value)
895896
end
896897

897898
newproperty(:nflog_range, required_features: :nflog_range) do
899+
desc <<-PUPPETCODE
900+
Used with the jump target NFLOG.
901+
This has never worked, use nflog_size instead.
902+
PUPPETCODE
903+
end
904+
905+
newproperty(:nflog_size, required_features: :nflog_size) do
898906
desc <<-PUPPETCODE
899907
Used with the jump target NFLOG.
900908
The number of bytes to be copied to userspace (only applicable for nfnetlink_log).
901-
nfnetlink_log instances may specify their own range, this option overrides it.
909+
nfnetlink_log instances may specify their own size, this option overrides it.
902910
PUPPETCODE
903911
end
904912

spec/acceptance/firewall_attributes_exceptions_spec.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ class {'::firewall': }
406406
end
407407
end
408408

409-
describe 'nflog_range' do
409+
# --nflog-range was deprecated and replaced by --nflog-size in iptables 1.6.1
410+
describe 'nflog_range', unless: iptables_version > '1.6.0' do
410411
it 'applies' do
411412
pp4 = <<-PUPPETCODE
412413
class {'::firewall': }
@@ -422,6 +423,22 @@ class {'::firewall': }
422423
end
423424
end
424425

426+
describe 'nflog_size', unless: iptables_version < '1.6.1' do
427+
it 'applies' do
428+
pp4 = <<-PUPPETCODE
429+
class {'::firewall': }
430+
firewall { '503 - test': jump => 'NFLOG', proto => 'all', nflog_size => 16}
431+
PUPPETCODE
432+
apply_manifest(pp4, catch_failures: true)
433+
end
434+
435+
it 'contains the rule' do
436+
run_shell('iptables-save') do |r|
437+
expect(r.stdout).to match(%r{NFLOG --nflog-size 16})
438+
end
439+
end
440+
end
441+
425442
describe 'nflog_threshold' do
426443
it 'applies' do
427444
pp5 = <<-PUPPETCODE

0 commit comments

Comments
 (0)