forked from hswaw/hscloud
bgpwtf: move tests from eoip to gretap
This removes our dependency on a userspace EoIP implementation that is mildly broken, and that doesn't build correctly on new gcc versions. Change-Id: I404c79585336ebaf3bc1761b54ee2433f0841324master
parent
32d3eaac01
commit
cc769a56f3
|
@ -1,75 +0,0 @@
|
||||||
# A small Ethernet-over-IP service implementation.
|
|
||||||
# Yes, that's the Mikrotik EoIP implementation. This one is somewhat sketchy
|
|
||||||
# (notably, it pumps huge zero-padded frames into tap), so doesn't use it for
|
|
||||||
# production. We currently only use it in the edge01.waw test framework to
|
|
||||||
# bring vlans across test VMs.
|
|
||||||
|
|
||||||
{ config, pkgs, lib, ... }:
|
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
eoip = pkgs.stdenv.mkDerivation {
|
|
||||||
pname = "eoip";
|
|
||||||
version = "20180119";
|
|
||||||
nativeBuildInputs = with pkgs; [ cmake ];
|
|
||||||
src = pkgs.fetchFromGitHub {
|
|
||||||
owner = "amphineko";
|
|
||||||
repo = "eoiptapd";
|
|
||||||
rev = "5573a905bcbc001b503308665f098e82f451dc33";
|
|
||||||
sha256 = "0np9dzcw5w6jarzdv2yh3mbzz0wgw10sjqyi6pxan4ipr75v1b8s";
|
|
||||||
};
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
cp eoiptapd $out/bin/eoiptapd
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
cfg = config.hscloud.eoip;
|
|
||||||
|
|
||||||
in {
|
|
||||||
options.hscloud.eoip = {
|
|
||||||
interfaces = mkOption {
|
|
||||||
type = with types; attrsOf (submodule {
|
|
||||||
options = {
|
|
||||||
localV4 = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "Local outer IPv4 address";
|
|
||||||
};
|
|
||||||
remoteV4 = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "Remote outer IPv4 address";
|
|
||||||
};
|
|
||||||
id = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
description = "Tunnel ID";
|
|
||||||
};
|
|
||||||
parent = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "Parent/outer device";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
});
|
|
||||||
description = ''
|
|
||||||
EoIP interfaces to create.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config.systemd.services = mapAttrs' (name: value: nameValuePair "${name}-eoip" {
|
|
||||||
wantedBy = [ "network.target" ];
|
|
||||||
wants = [
|
|
||||||
"${name}-netdev.service"
|
|
||||||
"network-addresses-${value.parent}.service"
|
|
||||||
];
|
|
||||||
after = [
|
|
||||||
"network-addresses-${value.parent}.service"
|
|
||||||
];
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "simple";
|
|
||||||
ExecStart = "${eoip}/bin/eoiptapd -i ${name} -l ${value.localV4} -r ${value.remoteV4} -t ${toString value.id}";
|
|
||||||
Restart = "always";
|
|
||||||
RestartSec = "1";
|
|
||||||
};
|
|
||||||
}) cfg.interfaces;
|
|
||||||
}
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
# Support for GRETap interfaces in NixOS' scripted networking.
|
||||||
|
#
|
||||||
|
# We currently only use it in the edge01.waw test framework to bring vlans
|
||||||
|
# across test VMs.
|
||||||
|
|
||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.hscloud.gretap;
|
||||||
|
|
||||||
|
in {
|
||||||
|
options.hscloud.gretap = {
|
||||||
|
interfaces = mkOption {
|
||||||
|
type = with types; attrsOf (submodule {
|
||||||
|
options = {
|
||||||
|
localV4 = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Local outer IPv4 address";
|
||||||
|
};
|
||||||
|
remoteV4 = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Remote outer IPv4 address";
|
||||||
|
};
|
||||||
|
id = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
description = "Tunnel ID";
|
||||||
|
};
|
||||||
|
parent = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Parent/outer device";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
description = ''
|
||||||
|
GRETap interfaces to create.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config.boot.kernelModules = [ "fou" ];
|
||||||
|
config.systemd.services = mapAttrs' (name: value: nameValuePair "${name}-gretap" {
|
||||||
|
wants = [
|
||||||
|
"${name}-netdev.service"
|
||||||
|
"network-addresses-${value.parent}.service"
|
||||||
|
];
|
||||||
|
after = [
|
||||||
|
"network-addresses-${value.parent}.service"
|
||||||
|
];
|
||||||
|
before = [
|
||||||
|
"network-addresses-${name}.service"
|
||||||
|
];
|
||||||
|
wantedBy = [
|
||||||
|
"network-addresses-${name}.service"
|
||||||
|
];
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
ExecStart = "${pkgs.iproute}/bin/ip link add name ${name} type gretap remote ${value.remoteV4} local ${value.localV4} key ${toString value.id}";
|
||||||
|
};
|
||||||
|
}) cfg.interfaces;
|
||||||
|
}
|
|
@ -5,9 +5,9 @@
|
||||||
# - bgpspeaker, which simulates bgp upstreams
|
# - bgpspeaker, which simulates bgp upstreams
|
||||||
# - customs, which simulates customs.hackerspace.pl.
|
# - customs, which simulates customs.hackerspace.pl.
|
||||||
#
|
#
|
||||||
# We use EoIP to build up virtual ethernet links between the machines, and
|
# We use GRETap to build up virtual ethernet links between the machines, and to
|
||||||
# to run VLANs on that. We don't just use plain 'vlans' from NixOS tests as
|
# run VLANs on that. We don't just use plain 'vlans' from NixOS tests as we
|
||||||
# we actually want to run 802.1q ourselves from the edge01 config.
|
# actually want to run 802.1q ourselves from the edge01 config.
|
||||||
#
|
#
|
||||||
# Everything else is pretty much straightforward. Bring up everything, ping
|
# Everything else is pretty much straightforward. Bring up everything, ping
|
||||||
# stuff. We don't really test much else than internet routing.
|
# stuff. We don't really test much else than internet routing.
|
||||||
|
@ -31,19 +31,15 @@ in { config, pkgs, ... }: {
|
||||||
virtualisation.memorySize = 1024;
|
virtualisation.memorySize = 1024;
|
||||||
virtualisation.vlans = [ 1 ];
|
virtualisation.vlans = [ 1 ];
|
||||||
imports = [
|
imports = [
|
||||||
../modules/eoip.nix
|
../modules/gretap.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
hscloud.eoip.interfaces."nnet" = {
|
hscloud.gretap.interfaces."nnet" = {
|
||||||
parent = "eth1";
|
parent = "eth1";
|
||||||
localV4 = "192.168.1.3";
|
localV4 = "192.168.1.3";
|
||||||
remoteV4 = "192.168.1.2";
|
remoteV4 = "192.168.1.2";
|
||||||
id = 100;
|
id = 100;
|
||||||
};
|
};
|
||||||
networking.interfaces."nnet" = {
|
|
||||||
virtual = true;
|
|
||||||
virtualType = "tap";
|
|
||||||
};
|
|
||||||
networking.vlans = {
|
networking.vlans = {
|
||||||
"vl-globalmix" = { interface = "nnet"; id = 466; };
|
"vl-globalmix" = { interface = "nnet"; id = 466; };
|
||||||
};
|
};
|
||||||
|
@ -142,27 +138,20 @@ test = import "${pkgsSrc}/nixos/tests/make-test-python.nix" ({ pkgs, libs, ... }
|
||||||
dut = { config, pkgs, ... }: {
|
dut = { config, pkgs, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
../edge01.waw.bgp.wtf.nix
|
../edge01.waw.bgp.wtf.nix
|
||||||
../modules/eoip.nix
|
../modules/gretap.nix
|
||||||
];
|
];
|
||||||
virtualisation.memorySize = 1024;
|
virtualisation.memorySize = 1024;
|
||||||
virtualisation.vlans = [
|
virtualisation.vlans = [
|
||||||
1 2
|
1 2
|
||||||
];
|
];
|
||||||
|
|
||||||
hscloud.eoip.interfaces = {
|
hscloud.gretap.interfaces = {
|
||||||
"e1-nnet" = { parent = "eth1"; localV4 = "192.168.1.2"; remoteV4 = "192.168.1.3"; id = 100; };
|
"e1-nnet" = { parent = "eth1"; localV4 = "192.168.1.2"; remoteV4 = "192.168.1.3"; id = 100; };
|
||||||
"e2-customs" = { parent = "eth2"; localV4 = "192.168.2.2"; remoteV4 = "192.168.2.1"; id = 200; };
|
"e2-customs" = { parent = "eth2"; localV4 = "192.168.2.2"; remoteV4 = "192.168.2.1"; id = 200; };
|
||||||
"e3-mgmt" = { parent = "eth2"; localV4 = "192.168.2.2"; remoteV4 = "192.168.2.111"; id = 300; }; # not connected
|
"e3-mgmt" = { parent = "eth2"; localV4 = "192.168.2.2"; remoteV4 = "192.168.2.111"; id = 300; }; # not connected
|
||||||
"e4-oob" = { parent = "eth2"; localV4 = "192.168.2.2"; remoteV4 = "192.168.2.112"; id = 400; }; # not connected
|
"e4-oob" = { parent = "eth2"; localV4 = "192.168.2.2"; remoteV4 = "192.168.2.112"; id = 400; }; # not connected
|
||||||
"e7-dcsw" = { parent = "eth2"; localV4 = "192.168.2.2"; remoteV4 = "192.168.2.113"; id = 500; }; # not connected
|
"e7-dcsw" = { parent = "eth2"; localV4 = "192.168.2.2"; remoteV4 = "192.168.2.113"; id = 500; }; # not connected
|
||||||
};
|
};
|
||||||
networking.interfaces = {
|
|
||||||
"e1-nnet" = { virtual = true; virtualType = "tap"; };
|
|
||||||
"e2-customs" = { virtual = true; virtualType = "tap"; };
|
|
||||||
"e3-mgmt" = { virtual = true; virtualType = "tap"; };
|
|
||||||
"e4-oob" = { virtual = true; virtualType = "tap"; };
|
|
||||||
"e7-dcsw" = { virtual = true; virtualType = "tap"; };
|
|
||||||
};
|
|
||||||
hscloud.anchorvm = {
|
hscloud.anchorvm = {
|
||||||
blkdev = "/anchor.img";
|
blkdev = "/anchor.img";
|
||||||
ram = 32;
|
ram = 32;
|
||||||
|
@ -180,7 +169,7 @@ test = import "${pkgsSrc}/nixos/tests/make-test-python.nix" ({ pkgs, libs, ... }
|
||||||
|
|
||||||
customs = { config, pkgs, ... }: {
|
customs = { config, pkgs, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
../modules/eoip.nix
|
../modules/gretap.nix
|
||||||
];
|
];
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
tcpdump htop dstat file dhcpcd
|
tcpdump htop dstat file dhcpcd
|
||||||
|
@ -194,12 +183,10 @@ test = import "${pkgsSrc}/nixos/tests/make-test-python.nix" ({ pkgs, libs, ... }
|
||||||
networking.defaultGateway = "185.236.240.4";
|
networking.defaultGateway = "185.236.240.4";
|
||||||
networking.defaultGateway6 = "2a0d:eb00:2137:1::2";
|
networking.defaultGateway6 = "2a0d:eb00:2137:1::2";
|
||||||
networking.interfaces."edge" = {
|
networking.interfaces."edge" = {
|
||||||
virtual = true;
|
|
||||||
virtualType = "tap";
|
|
||||||
ipv4.addresses = [{ address = "185.236.240.5"; prefixLength = 31; }];
|
ipv4.addresses = [{ address = "185.236.240.5"; prefixLength = 31; }];
|
||||||
ipv6.addresses = [{ address = "2a0d:eb00:2137:1::3"; prefixLength = 127; }];
|
ipv6.addresses = [{ address = "2a0d:eb00:2137:1::3"; prefixLength = 127; }];
|
||||||
};
|
};
|
||||||
hscloud.eoip.interfaces."edge" = {
|
hscloud.gretap.interfaces."edge" = {
|
||||||
parent = "eth2";
|
parent = "eth2";
|
||||||
localV4 = "192.168.2.1";
|
localV4 = "192.168.2.1";
|
||||||
remoteV4 = "192.168.2.2";
|
remoteV4 = "192.168.2.2";
|
||||||
|
|
Loading…
Reference in New Issue