Skip to content

Commit 481032b

Browse files
frr: add smoke test for ospfd
With the following configuration, we're able to peer with a remote ospf instance. As point-to-multipoint (which is the default) is more prone to errors compared to point-to-point, the smoke test use it, even if it is slower to converge. router ospf network 10.0.0.0/24 area 10.0.0.1 exit fedora-linux-42# show ip ospf route ============ OSPF network routing table ============ N 10.0.0.0/24 [10] area: 10.0.0.1 directly attached to p0 ============ OSPF router routing table ============= R 10.0.0.2 [10] area: 10.0.0.1, ASBR via 10.0.0.2, p0 ============ OSPF external routing table =========== N E2 192.0.0.0/24 [10/20] tag: 0 via 10.0.0.2, p0 fedora-linux-42# show ip route ospf Codes: K - kernel route, C - connected, L - local, S - static, O - OSPF, I - IS-IS, B - BGP, T - Table, v - VNC, V - VNC-Direct, t - Table-Direct, > - selected route, * - FIB route, q - queued, r - rejected, b - backup t - trapped, o - offload failure IPv4 unicast VRF default: O 10.0.0.0/24 [110/10] is directly connected, p0, weight 1, 00:06:36 O>* 192.0.0.0/24 [110/20] via 10.0.0.2, p0, weight 1, 00:05:50 Signed-off-by: Christophe Fontaine <[email protected]>
1 parent 15a544a commit 481032b

File tree

4 files changed

+113
-1
lines changed

4 files changed

+113
-1
lines changed

frr/frr_plugin_install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ install -D -m 755 "$1" "$2"
99
sed -i -e '/^zebra_options=/ {
1010
/-M[[:space:]]*dplane_grout/! s/"$/ -M dplane_grout"/
1111
}' "$3"
12-
sed -i -e '/isisd=no/isisd=yes/' "$3"
12+
sed -i -e 's/isisd=no/isisd=yes/' "$3"
13+
sed -i -e 's/ospfd=no/ospfd=yes/' "$3"
1314
touch "$4"

smoke/_init.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,12 @@ if [ "$test_frr" = true ] && [ "$run_frr" = true ]; then
224224
cat >$builddir/frr_install/etc/frr/daemons <<EOF
225225
bgpd=yes
226226
isisd=yes
227+
ospfd=yes
227228
vtysh_enable=yes
228229
zebra_options="-A 127.0.0.1 -s 90000000 --log file:$flog -M dplane_grout"
229230
bgpd_options="-A 127.0.0.1 --log file:$flog"
230231
isisd_options="--daemon -A 127.0.0.1 --log file:$flog"
232+
ospfd_options="--daemon -A 127.0.0.1 --log file:$flog"
231233
EOF
232234
cat >$builddir/frr_install/etc/frr/frr.conf <<EOF
233235
hostname grout

smoke/_init_frr.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,12 @@ start_frr_on_namespace() {
247247
cat >${frr_namespace_folder}/daemons <<EOF
248248
bgpd=yes
249249
isisd=yes
250+
ospfd=yes
250251
vtysh_enable=yes
251252
zebra_options="--daemon -A 127.0.0.1 -s 90000000 --log file:$flog"
252253
bgpd_options="--daemon -A 127.0.0.1 --log file:$flog"
253254
isisd_options="--daemon -A 127.0.0.1 --log file:$flog"
255+
ospfd_options="--daemon -A 127.0.0.1 --log file:$flog"
254256
watchfrr_options="--netns=$namespace"
255257
EOF
256258
cat >$frr_namespace_folder/frr.conf <<EOF
@@ -293,4 +295,12 @@ EOF
293295
fi
294296
sleep 0.1
295297
done
298+
299+
SECONDS=0
300+
while ! pgrep -f "ospfd -N $namespace"; do
301+
if [ "$SECONDS" -ge "5" ]; then
302+
fail "OSPF daemon not started for namespace $namespace"
303+
fi
304+
sleep 0.1
305+
done
296306
}

smoke/ospf_frr_test.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
# Copyright (c) 2025 Christophe Fontaine
4+
5+
# .--------------------.
6+
# | netns "ospf-peer" |
7+
# .--------..------------. | .-------. |
8+
# | zebra || grout | | | ospfd | |
9+
# '--------'| | | '-------' |
10+
# .-------. | .------------. .------------. .-------. |
11+
# | ospfd | | | p0 | net_tap | x-p0 | | zebra | |
12+
# '-------' | | +---------------+ | '-------' |
13+
# .----------. | 172.16.0.1 | | 172.16.0.2 |.----------. |
14+
# | gr-loop0 | '------------' '------------'| lo | |
15+
# '----------' | | | | |
16+
# | ping <------------------------------------> | 16.0.0.1 | |
17+
# | | | '----------' |
18+
# '-------------' '--------------------'
19+
20+
. $(dirname $0)/_init_frr.sh
21+
22+
create_interface p0
23+
set_ip_address p0 172.16.0.1/24
24+
25+
start_frr_on_namespace ospf-peer
26+
ip link set x-p0 netns ospf-peer
27+
28+
ip -n grout l set p0 up
29+
ip -n ospf-peer l set x-p0 up
30+
31+
# Configure Grout FRR instance
32+
vtysh <<-EOF
33+
configure terminal
34+
ip router-id 172.16.0.1
35+
!
36+
debug ospf event
37+
debug ospf packet all
38+
!
39+
interface lo
40+
ip address 17.0.0.1/24
41+
exit
42+
!
43+
interface p0
44+
ip ospf hello-interval 1
45+
exit
46+
!
47+
!
48+
router ospf
49+
ospf router-id 172.16.0.1
50+
network 172.16.0.0/24 area 10.0.0.1
51+
network 17.0.0.0/24 area 10.0.0.1
52+
exit
53+
!
54+
EOF
55+
56+
vtysh -N ospf-peer <<-EOF
57+
configure terminal
58+
ip router-id 172.16.0.2
59+
!
60+
debug ospf event
61+
debug ospf packet all
62+
!
63+
interface lo
64+
ip address 16.0.0.1/24
65+
exit
66+
!
67+
interface x-p0
68+
ip address 172.16.0.2/24
69+
ip ospf hello-interval 1
70+
exit
71+
!
72+
router ospf
73+
ospf router-id 172.16.0.2
74+
network 172.16.0.0/24 area 10.0.0.1
75+
network 16.0.0.0/24 area 10.0.0.1
76+
exit
77+
end
78+
!
79+
EOF
80+
81+
attempts=20
82+
while ! $(vtysh -c 'show ip ospf neighbor json' | jq '.neighbors."172.16.0.2"[0].converged == "Full"' -e > /dev/null) ; do
83+
sleep 1
84+
if [ "$attempts" -le 0 ]; then
85+
fail "OSPF failed to connect to neighbor."
86+
fi
87+
attempts=$((attempts - 1))
88+
done
89+
90+
attempts=10
91+
while ! $(vtysh -c 'show ip route ospf json' | jq '."16.0.0.1/32"[0].protocol == "ospf"' -e > /dev/null) ; do
92+
sleep 1
93+
if [ "$attempts" -le 0 ]; then
94+
fail "OSPF failed to get routes."
95+
fi
96+
attempts=$((attempts - 1))
97+
done
98+
99+
grcli ping 16.0.0.1 count 1

0 commit comments

Comments
 (0)