Skip to content

Commit 72c9567

Browse files
Group target match options right behind targets
The @resource_list determines the order in which arguments appear on the generated commandline for ip[6]tables; if there are options which belong to a match module interleaved with options which belong to a target extension, and both the target and match extensions are used in the same rule, perverse outputs like '-j SYNPROXY -m tcpmss --mss 1360 --sack-perm' are possible - where an entire match extension and its arguments are inserted between a target extension and its arguments. Group options which belong to a target extension together immediately behind :jump, so a target extension spec and its arguments cannot be separated; and add comments in the array to ensure it remains clear why this is important.
1 parent aac83b5 commit 72c9567

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

lib/puppet/provider/firewall/ip6tables.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ def self.iptables_save(*args)
320320
# not provided with current parser [georg.koester])
321321
@resource_list = [
322322
:table, :source, :destination, :iniface, :outiface,
323+
# Match module options
323324
:physdev_in, :physdev_out, :physdev_is_bridged, :physdev_is_in, :physdev_is_out,
324325
:proto, :ishasmorefrags, :islastfrag, :isfirstfrag,
325326
:src_range, :dst_range, :tcp_flags, :uid, :gid, :mac_source, :sport, :dport, :port,
@@ -328,14 +329,20 @@ def self.iptables_save(*args)
328329
:ctorigsrcport, :ctorigdstport, :ctreplsrcport, :ctrepldstport, :ctstatus, :ctexpire, :ctdir,
329330
:icmp, :hop_limit, :limit, :burst, :length, :recent, :rseconds, :reap,
330331
:rhitcount, :rttl, :rname, :mask, :rsource, :rdest, :ipset, :string, :string_hex, :string_algo,
331-
:string_from, :string_to, :jump, :queue_num, :queue_bypass,
332-
:nflog_group, :nflog_prefix, :nflog_range, :nflog_size, :nflog_threshold, :clamp_mss_to_pmtu, :gateway,
332+
:string_from, :string_to,
333+
# ONLY target extension options from here to END
334+
# otherwise a jump target spec and its options can end up separated by a match module and ITS options
335+
:jump,
336+
:queue_num, :queue_bypass, :nflog_group, :nflog_prefix, :nflog_range, :nflog_size, :nflog_threshold, :clamp_mss_to_pmtu, :gateway,
333337
:set_mss, :set_dscp, :set_dscp_class, :todest, :tosource, :toports, :checksum_fill, :random_fully, :log_prefix,
334-
: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,
338+
:log_level, :log_uid, :log_tcp_sequence, :log_tcp_options, :log_ip_options, :reject, :set_mark, :zone, :helper, :notrack,
335339
:synproxy_sack_perm, :synproxy_timestamp, :synproxy_wscale, :synproxy_mss, :synproxy_ecn,
340+
# END target extension options
341+
# Resume matcher options
342+
:match_mark, :mss, :connlimit_above, :connlimit_mask, :connmark, :time_start, :time_stop,
336343
:month_days, :week_days, :date_start, :date_stop, :time_contiguous, :kernel_timezone,
337344
:src_cc, :dst_cc, :hashlimit_upto, :hashlimit_above, :hashlimit_name, :hashlimit_burst,
338345
:hashlimit_mode, :hashlimit_srcmask, :hashlimit_dstmask, :hashlimit_htable_size,
339-
:hashlimit_htable_max, :hashlimit_htable_expire, :hashlimit_htable_gcinterval, :bytecode, :zone, :helper, :rpfilter, :condition, :name, :notrack
346+
:hashlimit_htable_max, :hashlimit_htable_expire, :hashlimit_htable_gcinterval, :bytecode, :rpfilter, :condition, :name
340347
]
341348
end

lib/puppet/provider/firewall/iptables.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ def munge_resource_map_from_resource(resource_map_original, compare)
355355
# This order can be determined by going through iptables source code or just tweaking and trying manually
356356
@resource_list = [
357357
:table, :source, :destination, :iniface, :outiface,
358+
# Match module options
358359
:physdev_in, :physdev_out, :physdev_is_bridged, :physdev_is_in, :physdev_is_out,
359360
:proto, :isfragment, :stat_mode, :stat_every, :stat_packet, :stat_probability,
360361
:src_range, :dst_range, :tcp_flags, :uid, :gid, :mac_source, :sport, :dport, :port,
@@ -363,16 +364,22 @@ def munge_resource_map_from_resource(resource_map_original, compare)
363364
:ctorigsrcport, :ctorigdstport, :ctreplsrcport, :ctrepldstport, :ctstatus, :ctexpire, :ctdir,
364365
:icmp, :limit, :burst, :length, :recent, :rseconds, :reap,
365366
:rhitcount, :rttl, :rname, :mask, :rsource, :rdest, :ipset, :string, :string_hex, :string_algo,
366-
:string_from, :string_to, :jump, :goto, :clusterip_new, :clusterip_hashmode,
367-
:clusterip_clustermac, :clusterip_total_nodes, :clusterip_local_node, :clusterip_hash_init, :queue_num, :queue_bypass,
368-
:nflog_group, :nflog_prefix, :nflog_range, :nflog_size, :nflog_threshold, :clamp_mss_to_pmtu, :gateway,
367+
:string_from, :string_to,
368+
# ONLY target extension options from here to END
369+
# otherwise a target spec and its options can end up separated by a match module and ITS options
370+
:jump, :goto,
371+
:clusterip_new, :clusterip_hashmode, :clusterip_clustermac, :clusterip_total_nodes, :clusterip_local_node, :clusterip_hash_init,
372+
:queue_num, :queue_bypass, :nflog_group, :nflog_prefix, :nflog_range, :nflog_size, :nflog_threshold, :clamp_mss_to_pmtu, :gateway,
369373
:set_mss, :set_dscp, :set_dscp_class, :todest, :tosource, :toports, :to, :checksum_fill, :random_fully, :random, :log_prefix,
370-
: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,
374+
:log_level, :log_uid, :log_tcp_sequence, :log_tcp_options, :log_ip_options, :reject, :set_mark, :zone, :helper, :notrack,
371375
:synproxy_sack_perm, :synproxy_timestamp, :synproxy_wscale, :synproxy_mss, :synproxy_ecn,
376+
# END target extension options
377+
# Resume matcher options
378+
:match_mark, :mss, :connlimit_above, :connlimit_mask, :connmark, :time_start, :time_stop,
372379
:month_days, :week_days, :date_start, :date_stop, :time_contiguous, :kernel_timezone,
373380
:src_cc, :dst_cc, :hashlimit_upto, :hashlimit_above, :hashlimit_name, :hashlimit_burst,
374381
:hashlimit_mode, :hashlimit_srcmask, :hashlimit_dstmask, :hashlimit_htable_size,
375-
:hashlimit_htable_max, :hashlimit_htable_expire, :hashlimit_htable_gcinterval, :bytecode, :ipvs, :zone, :helper, :cgroup, :rpfilter, :condition, :name, :notrack
382+
:hashlimit_htable_max, :hashlimit_htable_expire, :hashlimit_htable_gcinterval, :bytecode, :ipvs, :cgroup, :rpfilter, :condition, :name
376383
]
377384

378385
def insert

0 commit comments

Comments
 (0)