|
25 | 25 | services.frr = { |
26 | 26 | bgpd.enable = true; |
27 | 27 | config = '' |
| 28 | + ip route 198.51.100.0/25 reject |
| 29 | + ipv6 route 2001:db8:beef::/48 reject |
| 30 | +
|
28 | 31 | router bgp 64496 |
29 | 32 | no bgp ebgp-requires-policy |
30 | 33 | no bgp default ipv4-unicast |
|
37 | 40 | neighbor 2001:db8::3 remote-as 64498 |
38 | 41 |
|
39 | 42 | address-family ipv4 unicast |
| 43 | + network 198.51.100.0/25 |
40 | 44 | neighbor 192.0.2.2 activate |
41 | 45 | neighbor 192.0.2.3 activate |
42 | 46 | exit-address-family |
43 | 47 |
|
44 | 48 | address-family ipv6 unicast |
| 49 | + network 2001:db8:beef::/48 |
45 | 50 | neighbor 2001:db8::2 activate |
46 | 51 | neighbor 2001:db8::3 activate |
47 | 52 | exit-address-family |
|
96 | 101 | # families and to disable/enable various groups of static routes on the fly). |
97 | 102 | protocol static static4 { |
98 | 103 | ipv4; |
| 104 | +
|
| 105 | + route 198.51.100.128/25 unreachable; |
99 | 106 | } |
100 | 107 | protocol static static6 { |
101 | 108 | ipv6; |
| 109 | +
|
| 110 | + route 2001:db8:c0de::/48 unreachable; |
102 | 111 | } |
103 | 112 |
|
104 | 113 | protocol bgp a_v4 { |
|
145 | 154 | }; |
146 | 155 | c = { |
147 | 156 | environment.systemPackages = with pkgs; [ gobgp ]; |
148 | | - networking.interfaces.eth1 = { |
149 | | - ipv4.addresses = [ |
150 | | - { |
151 | | - address = "192.0.2.3"; |
152 | | - prefixLength = 29; |
153 | | - } |
154 | | - ]; |
155 | | - ipv6.addresses = [ |
156 | | - { |
157 | | - address = "2001:db8::3"; |
158 | | - prefixLength = 64; |
159 | | - } |
160 | | - ]; |
| 157 | + networking.interfaces = { |
| 158 | + eth1 = { |
| 159 | + ipv4.addresses = [ |
| 160 | + { |
| 161 | + address = "192.0.2.3"; |
| 162 | + prefixLength = 29; |
| 163 | + } |
| 164 | + ]; |
| 165 | + ipv6.addresses = [ |
| 166 | + { |
| 167 | + address = "2001:db8::3"; |
| 168 | + prefixLength = 64; |
| 169 | + } |
| 170 | + ]; |
| 171 | + }; |
| 172 | + lo = { |
| 173 | + ipv4.routes = [ |
| 174 | + { |
| 175 | + address = "203.0.113.0"; |
| 176 | + prefixLength = 24; |
| 177 | + } |
| 178 | + ]; |
| 179 | + ipv6.routes = [ |
| 180 | + { |
| 181 | + address = "2001:db8:dead::"; |
| 182 | + prefixLength = 48; |
| 183 | + } |
| 184 | + ]; |
| 185 | + }; |
161 | 186 | }; |
162 | 187 | services.gobgpd = { |
163 | 188 | enable = true; |
|
228 | 253 | b.wait_for_unit("bird.service") |
229 | 254 | c.wait_for_unit("gobgpd.service") |
230 | 255 |
|
231 | | - a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep '192.0.2.2.*0\\s*0\\s*N/A'") |
232 | | - a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep '192.0.2.3.*0\\s*0\\s*N/A'") |
| 256 | + a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep '192.0.2.2.*1\\s*2\\s*N/A'") |
| 257 | + a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep '192.0.2.3.*1\\s*2\\s*N/A'") |
233 | 258 | b.wait_until_succeeds("birdc show protocols | grep 'a_v4.*Established'") |
234 | 259 | b.wait_until_succeeds("birdc show protocols | grep 'c_v4.*Established'") |
235 | 260 | c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep '192.0.2.1.*Establ'") |
236 | 261 | c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep '192.0.2.2.*Establ'") |
237 | 262 |
|
238 | 263 | # IPv6 DAD might need some time to complete for the local link address, which is required by frr |
239 | | - a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep '2001:db8::2.*0\\s*0\\s*N/A'") |
240 | | - a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep '2001:db8::3.*0\\s*0\\s*N/A'") |
| 264 | + a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep '2001:db8::2.*1\\s*2\\s*N/A'") |
| 265 | + a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep '2001:db8::3.*1\\s*2\\s*N/A'") |
241 | 266 | b.wait_until_succeeds("birdc show protocols | grep 'a_v6.*Established'") |
242 | 267 | b.wait_until_succeeds("birdc show protocols | grep 'c_v4.*Established'") |
243 | 268 | c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep '2001:db8::1.*Establ'") |
244 | 269 | c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep '2001:db8::2.*Establ'") |
| 270 | +
|
| 271 | + with subtest("ensure routes have been installed in fib"): |
| 272 | + b.succeed("ip route show | grep 198.51.100.0/25") |
| 273 | + # c.succeed("ip route show | grep 198.51.100.0/25") |
| 274 | + a.succeed("ip route show | grep 198.51.100.128/25") |
| 275 | + # c.succeed("ip route show | grep 198.51.100.128/25") |
| 276 | + # a.succeed("ip route show | grep 203.0.113.0/24") |
| 277 | + # b.succeed("ip route show | grep 203.0.113.0/24") |
| 278 | + b.succeed("ip -6 route show | grep 2001:db8:beef::/48") |
| 279 | + # c.succeed("ip -6 route show | grep 2001:db8:beef::/48") |
| 280 | + a.succeed("ip -6 route show | grep 2001:db8:c0de::/48") |
| 281 | + # c.succeed("ip -6 route show | grep 2001:db8:c0de::/48") |
| 282 | + # a.succeed("ip -6 route show | grep 2001:db8:dead::/48") |
| 283 | + # b.succeed("ip -6 route show | grep 2001:db8:dead::/48") |
245 | 284 | ''; |
246 | 285 | } |
0 commit comments