|
1 | | -{ ... }: |
| 1 | +{ inputs, ... }: |
2 | 2 | { |
3 | 3 | name = "bgp-extended-nexthop"; |
4 | 4 |
|
| 5 | + # required in node c - gobgp module |
| 6 | + node.pkgsReadOnly = false; |
| 7 | + |
5 | 8 | defaults = { |
6 | 9 | networking.firewall.allowedTCPPorts = [ 179 ]; |
7 | 10 | }; |
|
29 | 32 | neighbor fe80::2 capability extended-nexthop |
30 | 33 | neighbor fe80::2 interface eth1 |
31 | 34 |
|
| 35 | + neighbor fe80::3 remote-as 64498 |
| 36 | + neighbor fe80::3 capability extended-nexthop |
| 37 | + neighbor fe80::3 interface eth1 |
| 38 | +
|
32 | 39 | address-family ipv4 unicast |
33 | 40 | network 198.51.100.0/25 |
34 | 41 | neighbor fe80::2 activate |
| 42 | + neighbor fe80::3 activate |
35 | 43 | exit-address-family |
36 | 44 |
|
37 | 45 | address-family ipv6 unicast |
38 | 46 | network 2001:db8:beef::/48 |
39 | 47 | neighbor fe80::2 activate |
| 48 | + neighbor fe80::3 activate |
40 | 49 | exit-address-family |
41 | 50 | ''; |
42 | 51 | }; |
|
73 | 82 | } |
74 | 83 |
|
75 | 84 | protocol static static4 { |
76 | | - vrf "vrf0"; |
77 | 85 | ipv4; |
78 | 86 |
|
79 | 87 | route 198.51.100.128/25 unreachable; |
80 | 88 | } |
81 | 89 |
|
82 | 90 | protocol static static6 { |
83 | | - vrf "vrf0"; |
84 | 91 | ipv6; |
85 | 92 |
|
86 | 93 | route 2001:db8:c0de::/48 unreachable; |
|
102 | 109 | export all; |
103 | 110 | }; |
104 | 111 | } |
| 112 | +
|
| 113 | + protocol bgp c { |
| 114 | + local as 64497; |
| 115 | + neighbor fe80::3 as 64498; |
| 116 | + interface "eth1"; |
| 117 | +
|
| 118 | + ipv4 { |
| 119 | + extended next hop on; |
| 120 | + import all; |
| 121 | + export all; |
| 122 | + }; |
| 123 | +
|
| 124 | + ipv6 { |
| 125 | + import all; |
| 126 | + export all; |
| 127 | + }; |
| 128 | + } |
105 | 129 | ''; |
106 | 130 | }; |
107 | 131 | }; |
| 132 | + c = { |
| 133 | + imports = [ inputs.gobgp.nixosModules.gobgp ]; |
| 134 | + networking.interfaces.eth1.ipv6.addresses = [ |
| 135 | + { |
| 136 | + address = "fe80::3"; |
| 137 | + prefixLength = 64; |
| 138 | + } |
| 139 | + ]; |
| 140 | + services.gobgpd = { |
| 141 | + enable = true; |
| 142 | + zebra = true; |
| 143 | + validateConfig = false; |
| 144 | + config = { |
| 145 | + global = { |
| 146 | + as = 64498; |
| 147 | + router-id = "192.0.2.3"; |
| 148 | + apply-policy = { |
| 149 | + default-import-policy = "accept-route"; |
| 150 | + export-policy-list = [ "c-out" ]; |
| 151 | + default-export-policy = "reject-route"; |
| 152 | + }; |
| 153 | + }; |
| 154 | + zebra = { |
| 155 | + enabled = true; |
| 156 | + redistribute-route-type-list = [ |
| 157 | + "kernel" |
| 158 | + "directly-connected" |
| 159 | + "static" |
| 160 | + ]; |
| 161 | + }; |
| 162 | + static-paths = { |
| 163 | + "unreachable-ipv4".prefix = "203.0.113.0/24"; |
| 164 | + "unreachable-ipv6".prefix = "2001:db8:dead::/48"; |
| 165 | + }; |
| 166 | + neighbors = { |
| 167 | + "a" = { |
| 168 | + neighbor-address = "fe80::1%eth1"; |
| 169 | + peer-as = 64496; |
| 170 | + afi-safis = { |
| 171 | + "ipv4-unicast" = { }; |
| 172 | + "ipv6-unicast" = { }; |
| 173 | + }; |
| 174 | + }; |
| 175 | + "b" = { |
| 176 | + neighbor-address = "fe80::2%eth1"; |
| 177 | + peer-as = 64497; |
| 178 | + afi-safis = { |
| 179 | + "ipv4-unicast" = { }; |
| 180 | + "ipv6-unicast" = { }; |
| 181 | + }; |
| 182 | + }; |
| 183 | + }; |
| 184 | + defined-sets.prefix-sets = { |
| 185 | + "c-out-ipv4".prefix-list = [ |
| 186 | + { |
| 187 | + ip-prefix = "203.0.113.0/24"; |
| 188 | + masklength-range = "24..32"; |
| 189 | + } |
| 190 | + ]; |
| 191 | + "c-out-ipv6".prefix-list = [ |
| 192 | + { |
| 193 | + ip-prefix = "2001:db8:dead::/48"; |
| 194 | + masklength-range = "48..128"; |
| 195 | + } |
| 196 | + ]; |
| 197 | + }; |
| 198 | + policy-definitions."c-out" = { |
| 199 | + statements = { |
| 200 | + "c-out-ipv4" = { |
| 201 | + actions.route-disposition = "accept-route"; |
| 202 | + conditions = { |
| 203 | + match-prefix-set = { |
| 204 | + prefix-set = "c-out-ipv4"; |
| 205 | + match-set-options = "any"; |
| 206 | + }; |
| 207 | + }; |
| 208 | + }; |
| 209 | + "c-out-ipv6" = { |
| 210 | + actions.route-disposition = "accept-route"; |
| 211 | + conditions = { |
| 212 | + match-prefix-set = { |
| 213 | + prefix-set = "c-out-ipv6"; |
| 214 | + match-set-options = "any"; |
| 215 | + }; |
| 216 | + }; |
| 217 | + }; |
| 218 | + }; |
| 219 | + }; |
| 220 | + }; |
| 221 | + }; |
| 222 | + }; |
108 | 223 | }; |
109 | 224 |
|
110 | 225 | testScript = '' |
|
117 | 232 | b.wait_for_unit("bird.service") |
118 | 233 |
|
119 | 234 | with subtest("ensure bgp sessions are established"): |
120 | | - a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep 'fe80::2.*1\\s*2\\s*N/A'") |
121 | | - a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep 'fe80::2.*1\\s*2\\s*N/A'") |
| 235 | + a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep 'fe80::2.*2\\s*3\\s*N/A'") |
| 236 | + a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep 'fe80::3.*1\\s*3\\s*N/A'") |
122 | 237 | b.wait_until_succeeds("birdc show protocols | grep 'a.*Established'") |
| 238 | + b.wait_until_succeeds("birdc show protocols | grep 'c.*Established'") |
| 239 | + c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep 'fe80::1%eth1.*Establ.*|.*3.*2'") |
| 240 | + c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep 'fe80::2%eth1.*Establ.*|.*2.*2'") |
| 241 | +
|
| 242 | + # IPv6 DAD might need some time to complete for the local link address, which is required by frr |
| 243 | + a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep 'fe80::2.*2\\s*3\\s*N/A'") |
| 244 | + a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep 'fe80::3.*1\\s*3\\s*N/A'") |
| 245 | + c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep 'fe80::1%eth1.*Establ.*|.*3.*2'") |
| 246 | + c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep 'fe80::2%eth1.*Establ.*|.*2.*2'") |
123 | 247 |
|
124 | 248 | with subtest("ensure routes have been installed"): |
125 | | - a.succeed("ip route show | grep 198.51.100.128/25") |
126 | 249 | b.succeed("ip route show | grep 198.51.100.0/25") |
127 | | - a.succeed("ip -6 route show | grep 2001:db8:c0de::/48") |
| 250 | + c.succeed("ip route show | grep 198.51.100.0/25") |
| 251 | + a.succeed("ip route show | grep 198.51.100.128/25") |
| 252 | + c.succeed("ip route show | grep 198.51.100.128/25") |
| 253 | + a.succeed("ip route show | grep 203.0.113.0/24") |
| 254 | + b.succeed("ip route show | grep 203.0.113.0/24") |
128 | 255 | b.succeed("ip -6 route show | grep 2001:db8:beef::/48") |
| 256 | + c.succeed("ip -6 route show | grep 2001:db8:beef::/48") |
| 257 | + a.succeed("ip -6 route show | grep 2001:db8:c0de::/48") |
| 258 | + c.succeed("ip -6 route show | grep 2001:db8:c0de::/48") |
| 259 | + a.succeed("ip -6 route show | grep 2001:db8:dead::/48") |
| 260 | + b.succeed("ip -6 route show | grep 2001:db8:dead::/48") |
129 | 261 | ''; |
130 | 262 | } |
0 commit comments