From 666014dbf92c1a5d07e1eb0dce0be0852fab62be Mon Sep 17 00:00:00 2001 From: Adam Stephens Date: Thu, 26 Sep 2024 09:23:00 -0400 Subject: [PATCH 1/2] openvswitch: remove legacy kernel module building As of Linux 3.3 the openvswitch kernel module is part of the mainline kernel. --- pkgs/by-name/op/openvswitch/package.nix | 36 +++++++++++-------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/pkgs/by-name/op/openvswitch/package.nix b/pkgs/by-name/op/openvswitch/package.nix index 4502031120c0..3db85c0036a3 100644 --- a/pkgs/by-name/op/openvswitch/package.nix +++ b/pkgs/by-name/op/openvswitch/package.nix @@ -1,40 +1,37 @@ { + withDPDK ? false, + lib, stdenv, - fetchFromGitHub, + autoconf, automake, + dpdk, + fetchFromGitHub, installShellFiles, iproute2, - kernel ? null, libcap_ng, + libpcap, libtool, + makeWrapper, nix-update-script, + nixosTests, + numactl, openssl, perl, pkg-config, procps, python3, - tcpdump, sphinxHook, + tcpdump, util-linux, which, - makeWrapper, - withDPDK ? false, - dpdk, - numactl, - libpcap, }: -let - _kernel = kernel; -in stdenv.mkDerivation rec { pname = if withDPDK then "openvswitch-dpdk" else "openvswitch"; version = "3.4.0"; - kernel = lib.optional (_kernel != null) _kernel.dev; - src = fetchFromGitHub { owner = "openvswitch"; repo = "ovs"; @@ -84,14 +81,11 @@ stdenv.mkDerivation rec { preConfigure = "./boot.sh"; - configureFlags = - [ - "--localstatedir=/var" - "--sharedstatedir=/var" - "--sbindir=$(out)/bin" - ] - ++ (lib.optionals (_kernel != null) [ "--with-linux" ]) - ++ (lib.optionals withDPDK [ "--with-dpdk=shared" ]); + configureFlags = [ + "--localstatedir=/var" + "--sharedstatedir=/var" + "--sbindir=$(out)/bin" + ] ++ (lib.optionals withDPDK [ "--with-dpdk=shared" ]); # Leave /var out of this! installFlags = [ From 52335fc1b08523df1871fff17cad7c7c5b4d2d49 Mon Sep 17 00:00:00 2001 From: Adam Stephens Date: Thu, 26 Sep 2024 09:26:10 -0400 Subject: [PATCH 2/2] openvswitch: init simple bridge test and add incus test --- nixos/tests/all-tests.nix | 1 + nixos/tests/openvswitch.nix | 62 +++++++++++++++++++++++++ pkgs/by-name/op/openvswitch/package.nix | 9 +++- 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 nixos/tests/openvswitch.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 15efe3a06b56..34f8289bde38 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -740,6 +740,7 @@ in { image-contents = handleTest ./image-contents.nix {}; openvscode-server = handleTest ./openvscode-server.nix {}; open-webui = runTest ./open-webui.nix; + openvswitch = runTest ./openvswitch.nix; orangefs = handleTest ./orangefs.nix {}; os-prober = handleTestOn ["x86_64-linux"] ./os-prober.nix {}; osquery = handleTestOn ["x86_64-linux"] ./osquery.nix {}; diff --git a/nixos/tests/openvswitch.nix b/nixos/tests/openvswitch.nix new file mode 100644 index 000000000000..679641717a1f --- /dev/null +++ b/nixos/tests/openvswitch.nix @@ -0,0 +1,62 @@ +{ + name = "openvswitch"; + + nodes = { + node1 = { + virtualisation.vlans = [ 1 ]; + + networking = { + useNetworkd = true; + useDHCP = false; + firewall.enable = false; + + vswitches.vs0 = { + interfaces = { + eth1 = { }; + }; + }; + + }; + + systemd.network.networks."40-vs0" = { + name = "vs0"; + networkConfig.Address = "10.0.0.1/24"; + }; + + }; + + node2 = { + virtualisation.vlans = [ 1 ]; + + networking = { + useNetworkd = true; + useDHCP = false; + firewall.enable = false; + + vswitches.vs0 = { + interfaces = { + eth1 = { }; + }; + }; + + }; + + systemd.network.networks."40-vs0" = { + name = "vs0"; + networkConfig.Address = "10.0.0.2/24"; + }; + }; + }; + + testScript = # python + '' + start_all() + node1.wait_for_unit("ovsdb.service") + node1.wait_for_unit("ovs-vswitchd.service") + node2.wait_for_unit("ovsdb.service") + node2.wait_for_unit("ovs-vswitchd.service") + + node1.succeed("ping -c3 10.0.0.2") + node2.succeed("ping -c3 10.0.0.1") + ''; +} diff --git a/pkgs/by-name/op/openvswitch/package.nix b/pkgs/by-name/op/openvswitch/package.nix index 3db85c0036a3..e6c891b22674 100644 --- a/pkgs/by-name/op/openvswitch/package.nix +++ b/pkgs/by-name/op/openvswitch/package.nix @@ -125,7 +125,14 @@ stdenv.mkDerivation rec { setuptools ]); - passthru.updateScript = nix-update-script { }; + passthru = { + tests = { + default = nixosTests.openvswitch; + incus = nixosTests.incus-lts.openvswitch; + }; + + updateScript = nix-update-script { }; + }; meta = with lib; { changelog = "https://www.openvswitch.org/releases/NEWS-${version}.txt";