Skip to content

Commit 6552426

Browse files
committed
tests/ospf-ptp: init
1 parent 3b7d3dd commit 6552426

2 files changed

Lines changed: 215 additions & 0 deletions

File tree

tests/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@
1919
| ipsec-transport | strongswan |
2020
| nat64-dns64 | Jool, BIND9 |
2121
| ospf | FRR, BIRD3 |
22+
| ospf-ptp | FRR, BIRD3 |
23+
| ospf | FRR, BIRD3 |
24+
| ospf-ptp | FRR, BIRD3 |
2225
| ping6-local-link | |

tests/ospf-ptp/default.nix

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
{ lib, pkgs, ... }:
2+
{
3+
name = "ospf-ptp";
4+
5+
defaults = {
6+
networking = {
7+
useDHCP = false;
8+
firewall.extraCommands = ''
9+
iptables -I INPUT -p 89 -j ACCEPT
10+
ip6tables -I INPUT -p 89 -j ACCEPT
11+
'';
12+
};
13+
};
14+
15+
nodes = {
16+
a = {
17+
networking.interfaces.eth1 = {
18+
ipv4.addresses = [
19+
{
20+
address = "192.0.2.1";
21+
prefixLength = 30;
22+
}
23+
];
24+
ipv6.addresses = [
25+
# be aware that the address given in the routing daemon configuration must be used for ospf v3 to work properly
26+
{
27+
address = "fe80::5054:ff:fe12:101";
28+
prefixLength = 64;
29+
}
30+
];
31+
};
32+
33+
services.frr = {
34+
ospfd.enable = true;
35+
ospf6d.enable = true;
36+
config = ''
37+
!debug ospf event
38+
debug ospf6 event
39+
40+
ip route 198.51.100.0/24 Null0
41+
ipv6 route 2001:db8:beef::/48 Null0
42+
43+
interface eth1
44+
ip ospf area 0
45+
ip ospf network non-broadcast
46+
ip ospf hello-interval 10
47+
ip ospf dead-interval 40
48+
49+
ipv6 ospf6 area 0
50+
ipv6 ospf6 network point-to-multipoint
51+
ipv6 ospf6 hello-interval 10
52+
ipv6 ospf6 dead-interval 40
53+
ipv6 ospf6 p2p-p2mp config-neighbors-only
54+
ipv6 ospf6 p2p-p2mp disable-multicast-hello
55+
ipv6 ospf6 neighbor fe80::5054:ff:fe12:102 poll-interval 5
56+
exit
57+
58+
router ospf
59+
ospf router-id 192.0.2.1
60+
redistribute static
61+
62+
neighbor 192.0.2.2 poll-interval 5
63+
64+
router ospf6
65+
ospf router-id 192.0.2.1
66+
redistribute static
67+
'';
68+
};
69+
};
70+
b = {
71+
networking.interfaces.eth1 = {
72+
ipv4.addresses = [
73+
{
74+
address = "192.0.2.2";
75+
prefixLength = 30;
76+
}
77+
];
78+
ipv6.addresses = [
79+
{
80+
address = "fe80::5054:ff:fe12:102";
81+
prefixLength = 64;
82+
}
83+
];
84+
};
85+
86+
services.bird = {
87+
enable = true;
88+
config = ''
89+
router id 192.0.2.2;
90+
log syslog all;
91+
# debug protocols all;
92+
93+
protocol device {
94+
scan time 10;
95+
}
96+
97+
protocol kernel kernel4 {
98+
ipv4 {
99+
import none;
100+
export all;
101+
};
102+
}
103+
protocol kernel kernel6 {
104+
ipv6 {
105+
import none;
106+
export all;
107+
};
108+
}
109+
110+
protocol static static4 {
111+
ipv4;
112+
route 203.0.113.0/24 blackhole;
113+
}
114+
protocol static static6 {
115+
ipv6;
116+
route 2001:db8:c0de::/48 blackhole;
117+
}
118+
119+
protocol ospf v2 ospf4 {
120+
ipv4 {
121+
export all;
122+
import all;
123+
};
124+
area 0 {
125+
interface "eth1" {
126+
type nonbroadcast;
127+
hello 10;
128+
dead 40;
129+
wait 5;
130+
poll 5;
131+
neighbors {
132+
192.0.2.1 eligible;
133+
};
134+
};
135+
};
136+
}
137+
protocol ospf v3 ospf6 {
138+
debug all;
139+
ipv6 {
140+
export all;
141+
import all;
142+
};
143+
area 0 {
144+
interface "eth1" {
145+
type nonbroadcast;
146+
hello 10;
147+
dead 40;
148+
wait 5;
149+
poll 5;
150+
neighbors {
151+
fe80::5054:ff:fe12:101 eligible;
152+
};
153+
};
154+
};
155+
}
156+
'';
157+
};
158+
};
159+
};
160+
161+
interactive.nodes = lib.listToAttrs (
162+
map
163+
(name: {
164+
inherit name;
165+
value.environment.systemPackages = with pkgs; [
166+
tcpdump
167+
];
168+
})
169+
[
170+
"a"
171+
"b"
172+
]
173+
);
174+
175+
testScript =
176+
let
177+
jq = lib.getExe pkgs.jq;
178+
in
179+
''
180+
start_all()
181+
182+
for m in [a, b]:
183+
m.wait_for_unit("network.target")
184+
185+
a.wait_for_unit("frr.service")
186+
b.wait_for_unit("bird.service")
187+
188+
b.succeed("systemctl reload bird.service")
189+
190+
with subtest("Ensure ospf is running"):
191+
a.wait_until_succeeds("vtysh -c 'show ip ospf neighbor' | grep Full/DR")
192+
b.wait_until_succeeds("birdc show protocols ospf4 | grep Running")
193+
194+
a.wait_until_succeeds("vtysh -c 'show ipv6 ospf6 neighbor' | grep Full/PtMultipoint")
195+
b.wait_until_succeeds("birdc show protocols ospf6 | grep Running")
196+
197+
with subtest("Ensure routes are being advertised"):
198+
a.wait_until_succeeds("""
199+
ip --json r | ${jq} -e 'map(select(.dst == "203.0.113.0/24")) | any'
200+
""")
201+
b.wait_until_succeeds("""
202+
ip --json r | ${jq} -e 'map(select(.dst == "198.51.100.0/24")) | any'
203+
""")
204+
205+
a.wait_until_succeeds("""
206+
ip --json -6 r | ${jq} -e 'map(select(.dst == "2001:db8:c0de::/48")) | any'
207+
""")
208+
b.wait_until_succeeds("""
209+
ip --json -6 r | ${jq} -e 'map(select(.dst == "2001:db8:beef::/48")) | any'
210+
""")
211+
'';
212+
}

0 commit comments

Comments
 (0)