-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from voxpupuli/icmp
rules::icmp: Allow ICMP packets with extensions
- Loading branch information
Showing
3 changed files
with
37 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,46 @@ | ||
# | ||
# @summary allows incoming ICMP | ||
# | ||
# @param v4_types ICMP v4 types that should be allowed | ||
# @param v6_types ICMP v6 types that should be allowed | ||
# @param order the ordering of the rules | ||
# | ||
class nftables::rules::icmp ( | ||
# lint:ignore:parameter_documentation | ||
Optional[Array[String]] $v4_types = undef, | ||
Optional[Array[String]] $v6_types = undef, | ||
String $order = '10', | ||
# lint:endignore | ||
) { | ||
if $v4_types { | ||
$v4_types.each | String $icmp_type | { | ||
nftables::rule { | ||
"default_in-accept_icmpv4_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}": | ||
content => "ip protocol icmp icmp type ${icmp_type} accept", | ||
order => $order, | ||
nftables::rule { "default_in-accept_icmpv4_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}": | ||
content => "ip protocol icmp icmp type ${icmp_type} accept", | ||
order => $order, | ||
} | ||
} | ||
} else { | ||
nftables::rule { | ||
'default_in-accept_icmpv4': | ||
content => 'ip protocol icmp accept', | ||
order => $order, | ||
} elsif $v6_types { | ||
nftables::rule { 'default_in-accept_icmpv4': | ||
content => 'ip protocol icmp accept', | ||
order => $order, | ||
} | ||
} | ||
|
||
if $v6_types { | ||
$v6_types.each | String $icmp_type | { | ||
nftables::rule { | ||
"default_in-accept_icmpv6_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}": | ||
content => "ip6 nexthdr ipv6-icmp icmpv6 type ${icmp_type} accept", | ||
order => $order, | ||
nftables::rule { "default_in-accept_icmpv6_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}": | ||
content => "ip6 nexthdr ipv6-icmp icmpv6 type ${icmp_type} accept", | ||
order => $order, | ||
} | ||
} | ||
} else { | ||
nftables::rule { | ||
'default_in-accept_icmpv6': | ||
content => 'ip6 nexthdr ipv6-icmp accept', | ||
order => $order, | ||
} elsif $v4_types { | ||
nftables::rule { 'default_in-accept_icmpv6': | ||
content => 'meta l4proto icmpv6 accept', | ||
order => $order, | ||
} | ||
} | ||
if $v6_types == undef and $v4_types == undef { | ||
nftables::rule { 'default_in-accept_icmp': | ||
content => 'meta l4proto { icmp, icmpv6} accept', | ||
order => $order, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters