From cc769a56f308a52589e2c8d07ed5837334649b81 Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Sat, 13 Feb 2021 13:13:41 +0100 Subject: [PATCH] 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: I404c79585336ebaf3bc1761b54ee2433f0841324 --- bgpwtf/machines/modules/eoip.nix | 75 ---------------------------- bgpwtf/machines/modules/gretap.nix | 62 +++++++++++++++++++++++ bgpwtf/machines/tests/edge01-waw.nix | 31 ++++-------- 3 files changed, 71 insertions(+), 97 deletions(-) delete mode 100644 bgpwtf/machines/modules/eoip.nix create mode 100644 bgpwtf/machines/modules/gretap.nix diff --git a/bgpwtf/machines/modules/eoip.nix b/bgpwtf/machines/modules/eoip.nix deleted file mode 100644 index 5ce04f39..00000000 --- a/bgpwtf/machines/modules/eoip.nix +++ /dev/null @@ -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; -} diff --git a/bgpwtf/machines/modules/gretap.nix b/bgpwtf/machines/modules/gretap.nix new file mode 100644 index 00000000..f4e1a7b2 --- /dev/null +++ b/bgpwtf/machines/modules/gretap.nix @@ -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; +} diff --git a/bgpwtf/machines/tests/edge01-waw.nix b/bgpwtf/machines/tests/edge01-waw.nix index 535418f1..1d724e1c 100644 --- a/bgpwtf/machines/tests/edge01-waw.nix +++ b/bgpwtf/machines/tests/edge01-waw.nix @@ -5,9 +5,9 @@ # - bgpspeaker, which simulates bgp upstreams # - customs, which simulates customs.hackerspace.pl. # -# We use EoIP to build up virtual ethernet links between the machines, and -# to run VLANs on that. We don't just use plain 'vlans' from NixOS tests as -# we actually want to run 802.1q ourselves from the edge01 config. +# We use GRETap to build up virtual ethernet links between the machines, and to +# run VLANs on that. We don't just use plain 'vlans' from NixOS tests as we +# actually want to run 802.1q ourselves from the edge01 config. # # Everything else is pretty much straightforward. Bring up everything, ping # stuff. We don't really test much else than internet routing. @@ -31,19 +31,15 @@ in { config, pkgs, ... }: { virtualisation.memorySize = 1024; virtualisation.vlans = [ 1 ]; imports = [ - ../modules/eoip.nix + ../modules/gretap.nix ]; - hscloud.eoip.interfaces."nnet" = { + hscloud.gretap.interfaces."nnet" = { parent = "eth1"; localV4 = "192.168.1.3"; remoteV4 = "192.168.1.2"; id = 100; }; - networking.interfaces."nnet" = { - virtual = true; - virtualType = "tap"; - }; networking.vlans = { "vl-globalmix" = { interface = "nnet"; id = 466; }; }; @@ -142,27 +138,20 @@ test = import "${pkgsSrc}/nixos/tests/make-test-python.nix" ({ pkgs, libs, ... } dut = { config, pkgs, ... }: { imports = [ ../edge01.waw.bgp.wtf.nix - ../modules/eoip.nix + ../modules/gretap.nix ]; virtualisation.memorySize = 1024; virtualisation.vlans = [ 1 2 ]; - hscloud.eoip.interfaces = { + hscloud.gretap.interfaces = { "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; }; "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 "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 = { blkdev = "/anchor.img"; ram = 32; @@ -180,7 +169,7 @@ test = import "${pkgsSrc}/nixos/tests/make-test-python.nix" ({ pkgs, libs, ... } customs = { config, pkgs, ... }: { imports = [ - ../modules/eoip.nix + ../modules/gretap.nix ]; environment.systemPackages = with pkgs; [ 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.defaultGateway6 = "2a0d:eb00:2137:1::2"; networking.interfaces."edge" = { - virtual = true; - virtualType = "tap"; ipv4.addresses = [{ address = "185.236.240.5"; prefixLength = 31; }]; ipv6.addresses = [{ address = "2a0d:eb00:2137:1::3"; prefixLength = 127; }]; }; - hscloud.eoip.interfaces."edge" = { + hscloud.gretap.interfaces."edge" = { parent = "eth2"; localV4 = "192.168.2.1"; remoteV4 = "192.168.2.2";