From f6a290932e773b7412978f29fc50c6a8f3dce222 Mon Sep 17 00:00:00 2001 From: Philippe Schaaf Date: Thu, 21 Jul 2022 11:38:03 +0200 Subject: [PATCH 1/3] use vde switch in hubmode by default Within a dual VM test-setup a strange behaviour was observed. The two VMs are connected via one vde_switch instance (instancevirtualisation.vlans = [ 1 ]; IMO a bad attribute name for switch instances, has nothing to do with VLANs in sense of 802.1Q). A ping on the base interface (eth1) works, but not on VLAN subinterfaces (vlan1@eth1). A tcpdump of eth1 includes the ARP requests tagged with the subinterfaces VLAN ID, but responses seems not to pass the vde_switch. This works fine if performed on the base interface. Putting the vde_switch in hub mode results in flooding traffic to all vde_switch ports. This results in a expected behaviour and a ping on a VLAN subinterface works as expected. Signed-off-by: Philippe Schaaf --- nixos/lib/test-driver/test_driver/vlan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/lib/test-driver/test_driver/vlan.py b/nixos/lib/test-driver/test_driver/vlan.py index e5c8f07b4edf..4d4debedc407 100644 --- a/nixos/lib/test-driver/test_driver/vlan.py +++ b/nixos/lib/test-driver/test_driver/vlan.py @@ -33,7 +33,7 @@ class VLan: pty_master, pty_slave = pty.openpty() self.process = subprocess.Popen( - ["vde_switch", "-s", self.socket_dir, "--dirmode", "0700"], + ["vde_switch", "-s", self.socket_dir, "--dirmode", "0700", "--hub"], stdin=pty_slave, stdout=subprocess.PIPE, stderr=subprocess.PIPE, @@ -50,7 +50,7 @@ class VLan: if not (self.socket_dir / "ctl").exists(): rootlog.error("cannot start vde_switch") - rootlog.info(f"running vlan (pid {self.pid})") + rootlog.info(f"running vlan (pid {self.pid}; ctl {self.socket_dir})") def __del__(self) -> None: rootlog.info(f"kill vlan (pid {self.pid})") From df52d556bba6ff989a6d91e180053512ba5be417 Mon Sep 17 00:00:00 2001 From: Philippe Schaaf Date: Thu, 21 Jul 2022 15:32:53 +0200 Subject: [PATCH 2/3] wip: add vlan-ping test Signed-off-by: Philippe Schaaf --- nixos/tests/networking.nix | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/nixos/tests/networking.nix b/nixos/tests/networking.nix index a00ff165d42f..71b82b871270 100644 --- a/nixos/tests/networking.nix +++ b/nixos/tests/networking.nix @@ -682,6 +682,46 @@ let client2.succeed("ip addr show dev vlan >&2") ''; }; + vlan-ping = let + baseIP = number: "10.10.10.${number}"; + vlanIP = number: "10.1.1.${number}"; + baseInterface = "eth1"; + vlanInterface = "vlan42"; + node = number: {pkgs, ... }: with pkgs.lib; { + virtualisation.vlans = [ 1 ]; + networking = { + #useNetworkd = networkd; + useDHCP = false; + vlans.${vlanInterface} = { id = 42; interface = baseInterface; }; + interfaces.${baseInterface}.ipv4.addresses = mkOverride 0 [{ address = baseIP number; prefixLength = 24; }]; + interfaces.${vlanInterface}.ipv4.addresses = mkOverride 0 [{ address = vlanIP number; prefixLength = 24; }]; + }; + }; + + serverNodeNum = "1"; + clientNodeNum = "2"; + + in { + name = "vlan-ping"; + nodes.server = node serverNodeNum; + nodes.client = node clientNodeNum; + testScript = { ... }: + '' + start_all() + + with subtest("Wait for networking to be configured"): + server.wait_for_unit("network.target") + client.wait_for_unit("network.target") + + with subtest("Test ping on base interface in setup"): + client.succeed("ping -I ${baseInterface} -c 1 ${baseIP serverNodeNum}") + server.succeed("ping -I ${baseInterface} -c 1 ${baseIP clientNodeNum}") + + with subtest("Test ping on vlan subinterface in setup"): + client.succeed("ping -I ${vlanInterface} -c 1 ${vlanIP serverNodeNum}") + server.succeed("ping -I ${vlanInterface} -c 1 ${vlanIP clientNodeNum}") + ''; + }; virtual = { name = "Virtual"; nodes.machine = { From 5ae6580474d0c0eba6441ca554d5a81e120a73a4 Mon Sep 17 00:00:00 2001 From: Philippe Schaaf Date: Thu, 21 Jul 2022 16:34:09 +0200 Subject: [PATCH 3/3] add hub mode comment Signed-off-by: Philippe Schaaf --- nixos/lib/test-driver/test_driver/vlan.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nixos/lib/test-driver/test_driver/vlan.py b/nixos/lib/test-driver/test_driver/vlan.py index 4d4debedc407..f2a7f250d1d2 100644 --- a/nixos/lib/test-driver/test_driver/vlan.py +++ b/nixos/lib/test-driver/test_driver/vlan.py @@ -32,6 +32,10 @@ class VLan: rootlog.info("start vlan") pty_master, pty_slave = pty.openpty() + # The --hub is required for the scenario determined by + # nixos/tests/networking.nix vlan-ping. + # VLAN Tagged traffic (802.1Q) seams to be blocked if a vde_switch is + # used without the hub mode (flood packets to all ports). self.process = subprocess.Popen( ["vde_switch", "-s", self.socket_dir, "--dirmode", "0700", "--hub"], stdin=pty_slave,