-
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.
rules::ospf3: Allow filtering on incoming interfaces
- Loading branch information
1 parent
98bdad7
commit 1b1b1a3
Showing
3 changed files
with
60 additions
and
5 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,7 +1,18 @@ | ||
# manage in ospf3 | ||
class nftables::rules::ospf3 { | ||
nftables::rule { | ||
'default_in-ospf3': | ||
content => 'ip6 saddr fe80::/64 ip6 daddr { ff02::5, ff02::6 } meta l4proto 89 accept', | ||
# | ||
# @summary manage in ospf3 | ||
# | ||
# @param iifname optional list of incoming interfaces to allow traffic | ||
# | ||
class nftables::rules::ospf3 ( | ||
Array[String[1]] $iifname = [], | ||
) { | ||
if empty($iifname) { | ||
$_iifname = '' | ||
} else { | ||
$iifdata = $iifname.map |String[1] $interface| { "\"${interface}\"" }.join(', ') | ||
$_iifname = "iifname { ${iifdata} } " | ||
} | ||
nftables::rule { 'default_in-ospf3': | ||
content => "${_iifname}ip6 saddr fe80::/64 ip6 daddr { ff02::5, ff02::6 } meta l4proto 89 accept", | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::ospf3' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let :facts do | ||
os_facts | ||
end | ||
|
||
context 'default options' do | ||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_nftables__rule('default_in-ospf3').with_content('ip6 saddr fe80::/64 ip6 daddr { ff02::5, ff02::6 } meta l4proto 89 accept') } | ||
end | ||
|
||
context 'with input interfaces set' do | ||
let :params do | ||
{ | ||
iifname: %w[docker0 eth0], | ||
} | ||
end | ||
|
||
it { is_expected.to compile } | ||
Check failure on line 24 in spec/classes/rules/ospf3_spec.rb GitHub Actions / Puppet / Static validations
|
||
str = 'iifname { "docker0", "eth0" } ip6 saddr fe80::/64 ip6 daddr { ff02::5, ff02::6 } meta l4proto 89 accept' | ||
it { is_expected.to contain_nftables__rule('default_in-ospf3').with_content(str) } | ||
end | ||
end | ||
end | ||
end |