summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorRémy Grünblatt <42433779+rgrunbla@users.noreply.github.com>2023-10-29 18:27:16 +0100
committerGitHub <noreply@github.com>2023-10-29 18:27:16 +0100
commitc9e3cc43c7baea00c41a4aa24a5e31a08fbfb894 (patch)
tree4fc7e30099bcdd06da12cd0e1400ea5336b49810 /nixos/modules/system
parent5cea7ee4527d3bbe2ba9675f9fb24c69d22c044d (diff)
downloadnixpkgs-c9e3cc43c7baea00c41a4aa24a5e31a08fbfb894.tar
nixpkgs-c9e3cc43c7baea00c41a4aa24a5e31a08fbfb894.tar.gz
nixpkgs-c9e3cc43c7baea00c41a4aa24a5e31a08fbfb894.tar.bz2
nixpkgs-c9e3cc43c7baea00c41a4aa24a5e31a08fbfb894.tar.lz
nixpkgs-c9e3cc43c7baea00c41a4aa24a5e31a08fbfb894.tar.xz
nixpkgs-c9e3cc43c7baea00c41a4aa24a5e31a08fbfb894.tar.zst
nixpkgs-c9e3cc43c7baea00c41a4aa24a5e31a08fbfb894.zip
nixos: fix iproute2 invocations (#263976)
When using iproute2's ip binary, you can omit the dev parameter, e.g. ip link set up eth0 instead of ip link set up dev eth0.

This breaks if for some reason your device is named e.g. he, hel, … because it is interpreted as ip link set up help.

I just encountered this bug using networking.bridges trying to create an interface named he.

I used a grep on nixpkgs to try to find iproute2 invocations using variables without the dev keyword, and found a few, and fixed them by providing the dev keyword.

I merely fixed what I found, but the use of abbreviated commands makes it a bit hard to be sure everything has been found (e.g. ip l set … up instead of ip link set … up).
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/initrd-network.nix6
1 files changed, 3 insertions, 3 deletions
diff --git a/nixos/modules/system/boot/initrd-network.nix b/nixos/modules/system/boot/initrd-network.nix
index 5bf38b6fa20..5696cae8e65 100644
--- a/nixos/modules/system/boot/initrd-network.nix
+++ b/nixos/modules/system/boot/initrd-network.nix
@@ -138,7 +138,7 @@ in
         # Bring up all interfaces.
         for iface in ${dhcpIfShellExpr}; do
           echo "bringing up network interface $iface..."
-          ip link set "$iface" up && ifaces="$ifaces $iface"
+          ip link set dev "$iface" up && ifaces="$ifaces $iface"
         done
 
         # Acquire DHCP leases.
@@ -152,8 +152,8 @@ in
 
     boot.initrd.postMountCommands = mkIf cfg.flushBeforeStage2 ''
       for iface in $ifaces; do
-        ip address flush "$iface"
-        ip link set "$iface" down
+        ip address flush dev "$iface"
+        ip link set dev "$iface" down
       done
     '';