1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-25 03:17:13 +00:00
nixpkgs/nixos/tests/babeld.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

211 lines
5.2 KiB
Nix
Raw Normal View History

2019-11-05 14:21:04 +00:00
import ./make-test-python.nix (
2019-10-12 00:30:55 +01:00
{ pkgs, lib, ... }:
{
2019-10-12 00:30:55 +01:00
name = "babeld";
meta = with pkgs.lib.maintainers; {
2019-10-12 00:30:55 +01:00
maintainers = [ hexa ];
};
2019-10-12 00:30:55 +01:00
nodes = {
client =
{ pkgs, lib, ... }:
{
virtualisation.vlans = [ 10 ];
2019-10-12 00:30:55 +01:00
networking = {
useDHCP = false;
interfaces."eth1" = {
ipv4.addresses = lib.mkForce [
{
address = "192.168.10.2";
prefixLength = 24;
}
];
ipv4.routes = lib.mkForce [
{
address = "0.0.0.0";
prefixLength = 0;
via = "192.168.10.1";
}
];
ipv6.addresses = lib.mkForce [
{
address = "2001:db8:10::2";
prefixLength = 64;
}
];
ipv6.routes = lib.mkForce [
{
address = "::";
prefixLength = 0;
via = "2001:db8:10::1";
}
];
};
2019-10-12 00:30:55 +01:00
};
};
2019-11-05 14:21:04 +00:00
local_router =
{ pkgs, lib, ... }:
{
2019-10-12 00:30:55 +01:00
virtualisation.vlans = [
10
20
];
2019-10-12 00:30:55 +01:00
networking = {
useDHCP = false;
firewall.enable = false;
2019-10-12 00:30:55 +01:00
interfaces."eth1" = {
ipv4.addresses = lib.mkForce [
{
address = "192.168.10.1";
prefixLength = 24;
}
];
ipv6.addresses = lib.mkForce [
{
address = "2001:db8:10::1";
prefixLength = 64;
}
];
};
2019-10-12 00:30:55 +01:00
interfaces."eth2" = {
ipv4.addresses = lib.mkForce [
{
2019-10-12 00:30:55 +01:00
address = "192.168.20.1";
prefixLength = 24;
}
];
ipv6.addresses = lib.mkForce [
{
2019-10-12 00:30:55 +01:00
address = "2001:db8:20::1";
prefixLength = 64;
}
];
};
2019-10-12 00:30:55 +01:00
};
services.babeld = {
enable = true;
interfaces.eth2 = {
hello-interval = 1;
type = "wired";
};
extraConfig = ''
local-port-readwrite 33123
import-table 254 # main
export-table 254 # main
in ip 192.168.10.0/24 deny
in ip 192.168.20.0/24 deny
in ip 2001:db8:10::/64 deny
in ip 2001:db8:20::/64 deny
in ip 192.168.30.0/24 allow
in ip 2001:db8:30::/64 allow
in deny
redistribute local proto 2
redistribute local deny
'';
};
2019-10-12 00:30:55 +01:00
};
2019-11-05 14:21:04 +00:00
remote_router =
{ pkgs, lib, ... }:
2019-10-12 00:30:55 +01:00
{
virtualisation.vlans = [
20
30
];
2019-10-12 00:30:55 +01:00
networking = {
useDHCP = false;
firewall.enable = false;
2019-10-12 00:30:55 +01:00
interfaces."eth1" = {
ipv4.addresses = lib.mkForce [
{
address = "192.168.20.2";
prefixLength = 24;
}
];
ipv6.addresses = lib.mkForce [
{
address = "2001:db8:20::2";
prefixLength = 64;
}
];
};
2019-10-12 00:30:55 +01:00
interfaces."eth2" = {
ipv4.addresses = lib.mkForce [
{
2019-10-12 00:30:55 +01:00
address = "192.168.30.1";
prefixLength = 24;
}
];
ipv6.addresses = lib.mkForce [
{
2019-10-12 00:30:55 +01:00
address = "2001:db8:30::1";
prefixLength = 64;
}
];
};
2019-10-12 00:30:55 +01:00
};
services.babeld = {
enable = true;
interfaces.eth1 = {
hello-interval = 1;
type = "wired";
};
extraConfig = ''
local-port-readwrite 33123
import-table 254 # main
export-table 254 # main
in ip 192.168.20.0/24 deny
in ip 192.168.30.0/24 deny
in ip 2001:db8:20::/64 deny
in ip 2001:db8:30::/64 deny
in ip 192.168.10.0/24 allow
in ip 2001:db8:10::/64 allow
in deny
redistribute local proto 2
redistribute local deny
'';
};
2019-10-12 00:30:55 +01:00
};
};
testScript = ''
2019-11-05 14:21:04 +00:00
start_all()
2019-10-12 00:30:55 +01:00
2019-11-05 14:21:04 +00:00
local_router.wait_for_unit("babeld.service")
remote_router.wait_for_unit("babeld.service")
2019-10-12 00:30:55 +01:00
2019-11-05 14:21:04 +00:00
local_router.wait_until_succeeds("ip route get 192.168.30.1")
local_router.wait_until_succeeds("ip route get 2001:db8:30::1")
2019-10-12 00:30:55 +01:00
2019-11-05 14:21:04 +00:00
remote_router.wait_until_succeeds("ip route get 192.168.10.1")
remote_router.wait_until_succeeds("ip route get 2001:db8:10::1")
2019-10-12 00:30:55 +01:00
2019-11-05 14:21:04 +00:00
client.succeed("ping -c1 192.168.30.1")
client.succeed("ping -c1 2001:db8:30::1")
2019-10-12 00:30:55 +01:00
2019-11-05 14:21:04 +00:00
remote_router.succeed("ping -c1 192.168.10.2")
remote_router.succeed("ping -c1 2001:db8:10::2")
2019-10-12 00:30:55 +01:00
'';
}
)