1 # This test runs FRR and checks if OSPF routing works.
4 # [ client ]--net1--[ router1 ]--net2--[ router2 ]--net3--[ server ]
6 # All interfaces are in OSPF Area 0.
8 import ./make-test-python.nix ({ pkgs, ... }:
11 ifAddr = node: iface: (pkgs.lib.head node.config.networking.interfaces.${iface}.ipv4.addresses).address;
15 network 192.168.0.0/16 area 0
20 ip ospf hello-interval 1
21 ip ospf dead-interval 5
24 network 192.168.0.0/16 area 0
31 meta = with pkgs.lib.maintainers; {
40 virtualisation.vlans = [ 1 ];
43 ip route 192.168.0.0/16 ${ifAddr nodes.router1 "eth1"}
51 virtualisation.vlans = [ 1 2 ];
52 boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
53 networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
59 specialisation.ospf.configuration = {
60 services.frr.config = ospfConf2;
67 virtualisation.vlans = [ 3 2 ];
68 boot.kernel.sysctl."net.ipv4.ip_forward" = "1";
69 networking.firewall.extraCommands = "iptables -A nixos-fw -i eth2 -p ospfigp -j ACCEPT";
79 virtualisation.vlans = [ 3 ];
82 ip route 192.168.0.0/16 ${ifAddr nodes.router2 "eth1"}
93 # Wait for the networking to start on all machines
94 for machine in client, router1, router2, server:
95 machine.wait_for_unit("network.target")
97 with subtest("Wait for FRR"):
98 for gw in client, router1, router2, server:
99 gw.wait_for_unit("frr")
101 router1.succeed("${nodes.router1.config.system.build.toplevel}/specialisation/ospf/bin/switch-to-configuration test >&2")
103 with subtest("Wait for OSPF to form adjacencies"):
104 for gw in router1, router2:
105 gw.wait_until_succeeds("vtysh -c 'show ip ospf neighbor' | grep Full")
106 gw.wait_until_succeeds("vtysh -c 'show ip route' | grep '^O>'")
108 with subtest("Test ICMP"):
109 client.wait_until_succeeds("ping -4 -c 3 server >&2")