Skip to content

Commit

Permalink
rules::ospf3: Allow filtering on incoming interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Dec 31, 2023
1 parent 98bdad7 commit 1b1b1a3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
14 changes: 14 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,20 @@ manage in ospf

manage in ospf3

#### Parameters

The following parameters are available in the `nftables::rules::ospf3` class:

* [`iifname`](#-nftables--rules--ospf3--iifname)

##### <a name="-nftables--rules--ospf3--iifname"></a>`iifname`

Data type: `Array[String[1]]`

optional list of incoming interfaces to allow traffic

Default value: `[]`

### <a name="nftables--rules--out--active_directory"></a>`nftables::rules::out::active_directory`

manage outgoing active diectory
Expand Down
21 changes: 16 additions & 5 deletions manifests/rules/ospf3.pp
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",
}
}
30 changes: 30 additions & 0 deletions spec/classes/rules/ospf3_spec.rb
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

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

RSpec/EmptyLineAfterExample: Add an empty line after `it`. (https://rspec.rubystyle.guide/#empty-lines-around-examples, https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterExample)
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

0 comments on commit 1b1b1a3

Please sign in to comment.