summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorWilliam A. Kennington III <william@wkennington.com>2014-11-29 22:34:50 -0800
committerWilliam A. Kennington III <william@wkennington.com>2014-11-29 22:35:03 -0800
commit7ecb084b77ae7f4ae66f844ae23f22e7ceea0879 (patch)
tree9ddff3657cce77068c41abaf5c54815f5e8c1601 /nixos/modules
parent017e6b72c123833c609dd45fcd523849d876da53 (diff)
downloadnixlib-7ecb084b77ae7f4ae66f844ae23f22e7ceea0879.tar
nixlib-7ecb084b77ae7f4ae66f844ae23f22e7ceea0879.tar.gz
nixlib-7ecb084b77ae7f4ae66f844ae23f22e7ceea0879.tar.bz2
nixlib-7ecb084b77ae7f4ae66f844ae23f22e7ceea0879.tar.lz
nixlib-7ecb084b77ae7f4ae66f844ae23f22e7ceea0879.tar.xz
nixlib-7ecb084b77ae7f4ae66f844ae23f22e7ceea0879.tar.zst
nixlib-7ecb084b77ae7f4ae66f844ae23f22e7ceea0879.zip
nixos/networking: More fixes
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/system/boot/systemd.nix1
-rw-r--r--nixos/modules/tasks/network-interfaces-scripted.nix11
-rw-r--r--nixos/modules/tasks/network-interfaces.nix14
3 files changed, 18 insertions, 8 deletions
diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix
index 89029a098e96..97cbc507e032 100644
--- a/nixos/modules/system/boot/systemd.nix
+++ b/nixos/modules/system/boot/systemd.nix
@@ -1026,6 +1026,7 @@ in
 
     systemd.services.systemd-networkd = {
       wantedBy = [ "multi-user.target" ];
+      before = [ "network-interfaces.target" ];
       restartTriggers = [ config.environment.etc."systemd/network".source ];
     };
 
diff --git a/nixos/modules/tasks/network-interfaces-scripted.nix b/nixos/modules/tasks/network-interfaces-scripted.nix
index 30fcb3a80104..12be812c71cb 100644
--- a/nixos/modules/tasks/network-interfaces-scripted.nix
+++ b/nixos/modules/tasks/network-interfaces-scripted.nix
@@ -33,8 +33,8 @@ let
       done
       [ "$UPDATED" -eq "1" ] && break
     done
-    ip link set "${i}" down || true
-    ip link del "${i}" || true
+    ip link set "${i}" down 2>/dev/null || true
+    ip link del "${i}" 2>/dev/null || true
   '';
 
 in
@@ -43,12 +43,6 @@ in
 
   config = mkIf (!cfg.useNetworkd) {
 
-    systemd.targets."network-interfaces" =
-      { description = "All Network Interfaces";
-        wantedBy = [ "network.target" ];
-        unitConfig.X-StopOnReconfiguration = true;
-      };
-
     systemd.services =
       let
 
@@ -240,6 +234,7 @@ in
               # Bring up the bond and enslave the specified interfaces
               ip link set "${n}" up
               ${flip concatMapStrings v.interfaces (i: ''
+                ip link set "${i}" down
                 ip link set "${i}" master "${n}"
               '')}
             '';
diff --git a/nixos/modules/tasks/network-interfaces.nix b/nixos/modules/tasks/network-interfaces.nix
index 0ee2c9d2d00d..81228ea55a95 100644
--- a/nixos/modules/tasks/network-interfaces.nix
+++ b/nixos/modules/tasks/network-interfaces.nix
@@ -11,6 +11,11 @@ let
   hasSits = cfg.sits != { };
   hasBonds = cfg.bonds != { };
 
+  slaves = concatMap (i: i.interfaces) (attrValues cfg.bonds)
+    ++ concatMap (i: i.interfaces) (attrValues cfg.bridges);
+
+  slaveIfs = map (i: cfg.interfaces.${i}) slaves;
+
   # We must escape interfaces due to the systemd interpretation
   subsystemDevice = interface:
     "sys-subsystem-net-devices-${escapeSystemdPath interface}.device";
@@ -589,6 +594,9 @@ in
       (flip map interfaces (i: {
         assertion = i.subnetMask == null;
         message = "The networking.interfaces.${i.name}.subnetMask option is defunct. Use prefixLength instead.";
+      })) ++ (flip map slaveIfs (i: {
+        assertion = i.ip4 == [ ] && i.ipAddress == null && i.ip6 == [ ] && i.ipv6Address == null;
+        message = "The networking.interfaces.${i.name} must not have any defined ips when it is a slave.";
       })) ++ [
         {
           assertion = cfg.hostId == null || (stringLength cfg.hostId == 8 && isHexString cfg.hostId);
@@ -657,6 +665,12 @@ in
         pkgs.openresolv
       ];
 
+    systemd.targets."network-interfaces" =
+      { description = "All Network Interfaces";
+        wantedBy = [ "network.target" ];
+        unitConfig.X-StopOnReconfiguration = true;
+      };
+
     systemd.services = {
       network-local-commands = {
         description = "Extra networking commands.";