From 5a4dc2128ecd469ea09415d8461ea0601e2b0500 Mon Sep 17 00:00:00 2001 From: SEIAROTg Date: Sat, 4 Mar 2023 17:51:35 +0000 Subject: [PATCH] nixos/wireguard: fix mtu after switching netns. mtu is set after switching netns and thus the new netns should be used. --- nixos/modules/services/networking/wireguard.nix | 2 +- nixos/tests/wireguard/namespaces.nix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/wireguard.nix b/nixos/modules/services/networking/wireguard.nix index b08f1015e8b8..8b025228cc1f 100644 --- a/nixos/modules/services/networking/wireguard.nix +++ b/nixos/modules/services/networking/wireguard.nix @@ -461,7 +461,7 @@ let ${ipPreMove} link add dev "${name}" type wireguard ${optionalString (values.interfaceNamespace != null && values.interfaceNamespace != values.socketNamespace) ''${ipPreMove} link set "${name}" netns "${ns}"''} - ${optionalString (values.mtu != null) ''${ipPreMove} link set "${name}" mtu ${toString values.mtu}''} + ${optionalString (values.mtu != null) ''${ipPostMove} link set "${name}" mtu ${toString values.mtu}''} ${concatMapStringsSep "\n" (ip: ''${ipPostMove} address add "${ip}" dev "${name}"'' diff --git a/nixos/tests/wireguard/namespaces.nix b/nixos/tests/wireguard/namespaces.nix index 1790c45bb1f6..d0eb009e1107 100644 --- a/nixos/tests/wireguard/namespaces.nix +++ b/nixos/tests/wireguard/namespaces.nix @@ -39,6 +39,7 @@ import ../make-test-python.nix ({ pkgs, lib, kernelPackages ? null, ... } : { preSetup = '' ip netns add ${interfaceNamespace} ''; + mtu = 1280; inherit interfaceNamespace; }; };