Merge pull request #182324 from snpschaaf/testdriver-vde-hub-mode

use vde switch in hubmode by default
This commit is contained in:
Jacek Galowicz 2022-07-21 17:48:15 +02:00 committed by GitHub
commit 8429701cbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 2 deletions

View File

@ -32,8 +32,12 @@ 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"],
["vde_switch", "-s", self.socket_dir, "--dirmode", "0700", "--hub"],
stdin=pty_slave,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@ -50,7 +54,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})")

View File

@ -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 = {