1 /* This test ensures that we can configure spanning-tree protocol
2 across bridges using systemd-networkd.
7 node1 --- sw1 --- sw2 --- node2
16 where switches 1, 2, and 3 bridge their links and use STP,
17 and each link is labeled with the VLAN we are assigning it in
23 systemd.services.systemd-networkd.environment.SYSTEMD_LOG_LEVEL = "debug";
24 networking.useNetworkd = true;
25 networking.useDHCP = false;
26 networking.firewall.enable = false;
29 generateNodeConf = { octet, vlan }:
30 { lib, pkgs, config, ... }: {
31 imports = [ common/user-account.nix commonConf ];
32 virtualisation.vlans = [ vlan ];
37 matchConfig.Name = "eth1";
38 address = [ "10.0.0.${toString octet}/24" ];
44 generateSwitchConf = vlans:
45 { lib, pkgs, config, ... }: {
46 imports = [ common/user-account.nix commonConf ];
47 virtualisation.vlans = vlans;
56 bridgeConfig.STP = "yes";
61 matchConfig.Name = "eth*";
62 networkConfig.Bridge = "br0";
64 "40-br0" = { matchConfig.Name = "br0"; };
68 in import ./make-test-python.nix ({ pkgs, ... }: {
70 meta = with pkgs.lib.maintainers; { maintainers = [ picnoir ]; };
72 node1 = generateNodeConf {
76 node2 = generateNodeConf {
80 node3 = generateNodeConf {
84 sw1 = generateSwitchConf [ 1 2 4 ];
85 sw2 = generateSwitchConf [ 2 3 5 ];
86 sw3 = generateSwitchConf [ 4 5 6 ];
89 network_nodes = [node1, node2, node3]
90 network_switches = [sw1, sw2, sw3]
93 for n in network_nodes + network_switches:
94 n.wait_for_unit("systemd-networkd-wait-online.service")
96 node1.succeed("ping 10.0.0.2 -w 10 -c 1")
97 node1.succeed("ping 10.0.0.3 -w 10 -c 1")
98 node2.succeed("ping 10.0.0.1 -w 10 -c 1")
99 node2.succeed("ping 10.0.0.3 -w 10 -c 1")
100 node3.succeed("ping 10.0.0.1 -w 10 -c 1")
101 node3.succeed("ping 10.0.0.2 -w 10 -c 1")