summary refs log tree commit diff
path: root/nixos/modules/tasks
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2014-10-07 23:06:35 -0700
committerWilliam A. Kennington III <william@wkennington.com>2014-10-07 23:07:10 -0700
commit362699376a7b9ca77919b89574b1d8acfbe57e48 (patch)
treebac1329bf604bd669dd938cdbe7ac54cafb52adf /nixos/modules/tasks
parent71605beba1391a2fd10872406e8a49397d1bdc6b (diff)
downloadnixlib-362699376a7b9ca77919b89574b1d8acfbe57e48.tar
nixlib-362699376a7b9ca77919b89574b1d8acfbe57e48.tar.gz
nixlib-362699376a7b9ca77919b89574b1d8acfbe57e48.tar.bz2
nixlib-362699376a7b9ca77919b89574b1d8acfbe57e48.tar.lz
nixlib-362699376a7b9ca77919b89574b1d8acfbe57e48.tar.xz
nixlib-362699376a7b9ca77919b89574b1d8acfbe57e48.tar.zst
nixlib-362699376a7b9ca77919b89574b1d8acfbe57e48.zip
nixos/network-interfaces: Bond interface configuration must wait for the bond device service
Also fixes some formatting and removal of slave devices.
Diffstat (limited to 'nixos/modules/tasks')
-rw-r--r--nixos/modules/tasks/network-interfaces.nix23
1 files changed, 12 insertions, 11 deletions
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index 6f6000cf3397..22b52f77b145 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -773,29 +773,28 @@ in
             wantedBy = [ "network.target" (subsystemDevice n) ];
             bindsTo = deps;
             after = deps;
+            before = [ "${n}-cfg.service" ];
             serviceConfig.Type = "oneshot";
             serviceConfig.RemainAfterExit = true;
             path = [ pkgs.ifenslave pkgs.iproute ];
             script = ''
-              # Remove Dead Interfaces
-              ip link set "${n}" down >/dev/null 2>&1 || true
-              ifenslave -d "${n}" >/dev/null 2>&1 || true
-              ip link del "${n}" >/dev/null 2>&1 || true
-
               ip link add name "${n}" type bond
 
               # !!! There must be a better way to wait for the interface
               while [ ! -d /sys/class/net/${n} ]; do sleep 0.1; done;
 
+              # Ensure the link is down so that we can set options
+              ip link set "${n}" down
+
               # Set the miimon and mode options
               ${optionalString (v.miimon != null)
-                "echo ${toString v.miimon} > /sys/class/net/${n}/bonding/miimon"}
+                "echo \"${toString v.miimon}\" >/sys/class/net/${n}/bonding/miimon"}
               ${optionalString (v.mode != null)
-                "echo \"${v.mode}\" > /sys/class/net/${n}/bonding/mode"}
+                "echo \"${v.mode}\" >/sys/class/net/${n}/bonding/mode"}
               ${optionalString (v.lacp_rate != null)
-                "echo \"${v.lacp_rate}\" > /sys/class/net/${n}/bonding/lacp_rate"}
+                "echo \"${v.lacp_rate}\" >/sys/class/net/${n}/bonding/lacp_rate"}
               ${optionalString (v.xmit_hash_policy != null)
-                "echo \"${v.xmit_hash_policy}\" > /sys/class/net/${n}/bonding/xmit_hash_policy"}
+                "echo \"${v.xmit_hash_policy}\" >/sys/class/net/${n}/bonding/xmit_hash_policy"}
 
               # Bring up the bond and enslave the specified interfaces
               ip link set "${n}" up
@@ -804,8 +803,10 @@ in
               '')}
             '';
             postStop = ''
-              ip link set "${n}" down >dev/null 2>&1 || true
-              ifenslave -d "${n}" >/dev/null 2>&1 || true
+              ${flip concatMapStrings v.interfaces (i: ''
+                ifenslave -d "${n}" "${i}" >/dev/null 2>&1 || true
+              '')}
+              ip link set "${n}" down >/dev/null 2>&1 || true
               ip link del "${n}" >/dev/null 2>&1 || true
             '';
           });