Skip to content

Commit 7e1a12b

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 5a3f915 commit 7e1a12b

File tree

4 files changed

+108
-1
lines changed

4 files changed

+108
-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: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
router ospf
44+
ospf router-id 172.16.0.1
45+
network 172.16.0.0/24 area 10.0.0.1
46+
network 17.0.0.0/24 area 10.0.0.1
47+
exit
48+
!
49+
EOF
50+
51+
vtysh -N ospf-peer <<-EOF
52+
configure terminal
53+
ip router-id 172.16.0.2
54+
!
55+
debug ospf event
56+
debug ospf packet all
57+
!
58+
interface lo
59+
ip address 16.0.0.1/24
60+
exit
61+
!
62+
interface x-p0
63+
ip address 172.16.0.2/24
64+
exit
65+
!
66+
router ospf
67+
ospf router-id 172.16.0.2
68+
network 172.16.0.0/24 area 10.0.0.1
69+
network 16.0.0.0/24 area 10.0.0.1
70+
exit
71+
end
72+
!
73+
EOF
74+
75+
# Convergence takes ~1min, be patient.
76+
attempts=90
77+
while ! $(vtysh -c 'show ip ospf neighbor json' | jq '.neighbors."172.16.0.2"[0].converged == "Full"' -e > /dev/null) ; do
78+
sleep 1
79+
if [ "$attempts" -le 0 ]; then
80+
fail "OSPF failed to connect to neighbor."
81+
fi
82+
attempts=$((attempts - 1))
83+
done
84+
85+
attempts=5
86+
while ! $(vtysh -c 'show ip route ospf json' | jq '."16.0.0.1/32"[0].protocol == "ospf"' -e > /dev/null) ; do
87+
sleep 1
88+
if [ "$attempts" -le 0 ]; then
89+
fail "OSPF failed to get routes."
90+
fi
91+
attempts=$((attempts - 1))
92+
done
93+
94+
grcli ping 16.0.0.1 count 1

0 commit comments

Comments
 (0)