|
| 1 | +#!/bin/bash |
| 2 | +# SPDX-License-Identifier: BSD-3-Clause |
| 3 | +# Copyright (c) 2025 Christophe Fontaine |
| 4 | + |
| 5 | +# .--------------------. |
| 6 | +# | netns "ospf6-peer" | |
| 7 | +# .--------..------------. | .--------. | |
| 8 | +# | zebra || grout | | | ospf6d | | |
| 9 | +# '--------'| | | '--------' | |
| 10 | +# .--------.| .-----------. .------------. .-------. | |
| 11 | +# | ospf6d || | p0 | net_tap | x-p0 | | zebra | | |
| 12 | +# '--------'| | +---------------+ | '-------' | |
| 13 | +# .----------. | fe80::/64 | | fe80::/64 |.----------. | |
| 14 | +# | gr-loop0 | '-----------' '------------'| lo | | |
| 15 | +# '----------' | | | | | |
| 16 | +# | ping <-----------------------------------> |2001:db8: | | |
| 17 | +# | | | | 1000::1 | | |
| 18 | +# '-------------' | '----------' | |
| 19 | +# '--------------------' |
| 20 | + |
| 21 | +. $(dirname $0)/_init_frr.sh |
| 22 | + |
| 23 | +create_interface p0 |
| 24 | +set_ip_address p0 2001:db8::1/64 |
| 25 | + |
| 26 | +start_frr_on_namespace ospf6-peer |
| 27 | +ip link set x-p0 netns ospf6-peer |
| 28 | + |
| 29 | +ip -n grout l set p0 up |
| 30 | +ip -n ospf6-peer l set x-p0 up |
| 31 | + |
| 32 | +# Configure Grout FRR instance |
| 33 | +vtysh <<-EOF |
| 34 | +configure terminal |
| 35 | +ipv6 forwarding |
| 36 | +! |
| 37 | +#debug ospf6 event |
| 38 | +#debug ospf6 message all |
| 39 | +! |
| 40 | +interface p0 |
| 41 | + ipv6 ospf6 area 0.0.0.1 |
| 42 | + ipv6 ospf6 hello-interval 1 |
| 43 | +exit |
| 44 | +! |
| 45 | +router ospf6 |
| 46 | + ospf6 router-id 1.1.1.1 |
| 47 | + area 0.0.0.1 range 2001:db8::/48 |
| 48 | +exit |
| 49 | +! |
| 50 | +EOF |
| 51 | + |
| 52 | +vtysh -N ospf6-peer <<-EOF |
| 53 | +configure terminal |
| 54 | +ipv6 forwarding |
| 55 | +! |
| 56 | +#debug ospf6 event |
| 57 | +#debug ospf6 message all |
| 58 | +! |
| 59 | +interface lo |
| 60 | + ipv6 address 2001:db8:1000::1/64 |
| 61 | +exit |
| 62 | +! |
| 63 | +interface x-p0 |
| 64 | + ipv6 ospf6 area 0.0.0.1 |
| 65 | + ipv6 ospf6 hello-interval 1 |
| 66 | +exit |
| 67 | +! |
| 68 | +router ospf6 |
| 69 | + ospf6 router-id 2.2.2.2 |
| 70 | + area 0.0.0.1 range 2001:db8::/48 |
| 71 | + redistribute connected |
| 72 | +exit |
| 73 | +end |
| 74 | +! |
| 75 | +EOF |
| 76 | + |
| 77 | +# Convergence takes ~40s, be patient. |
| 78 | +attempts=60 |
| 79 | +while ! $(vtysh -c 'show ipv6 ospf6 neighbor json' | jq '.neighbors[] | select(.neighborId=="2.2.2.2") | .state == "Full"' -e > /dev/null) ; do |
| 80 | + sleep 1 |
| 81 | + if [ "$attempts" -le 0 ]; then |
| 82 | + fail "OSPF6 failed to connect to neighbor." |
| 83 | + fi |
| 84 | + attempts=$((attempts - 1)) |
| 85 | +done |
| 86 | + |
| 87 | +attempts=10 |
| 88 | +while ! $(vtysh -c 'show ipv6 route ospf6 json' | jq '."2001:db8:1000::/64"[0].protocol == "ospf6"' -e > /dev/null) ; do |
| 89 | + sleep 1 |
| 90 | + if [ "$attempts" -le 0 ]; then |
| 91 | + fail "OSPF6 failed to get routes." |
| 92 | + fi |
| 93 | + attempts=$((attempts - 1)) |
| 94 | +done |
| 95 | + |
| 96 | +grcli ping6 2001:db8:1000::1 count 3 delay 10 |
0 commit comments