From d4ff40f9901198488a5599330ee7b8f110275a6d Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Tue, 2 Jan 2024 07:53:31 +0530 Subject: modules/network-interfaces: fix implicit dependency on device the bug causes a hard dependency on an underlying device which might not be valid for all interfaces, also broke the example for networking.sits. this is due to calling hasAttr first and checking for null afterwards, it was introduced in commit 76a3c30 and this fix doesn't break the functionality of that commit --- modules/network-interfaces-scripted.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'modules/network-interfaces-scripted.nix') diff --git a/modules/network-interfaces-scripted.nix b/modules/network-interfaces-scripted.nix index 95ba037..2f2d282 100644 --- a/modules/network-interfaces-scripted.nix +++ b/modules/network-interfaces-scripted.nix @@ -70,7 +70,8 @@ let deviceDependency = dev: # Use systemd service if we manage device creation, else # trust udev when not in a container - if (hasAttr dev (filterAttrs (k: v: v.virtual) cfg.interfaces)) || + if (dev == null || dev == "lo") then [] + else if (hasAttr dev (filterAttrs (k: v: v.virtual) cfg.interfaces)) || (hasAttr dev cfg.bridges) || (hasAttr dev cfg.bonds) || (hasAttr dev cfg.macvlans) || @@ -78,7 +79,7 @@ let (hasAttr dev cfg.vlans) || (hasAttr dev cfg.vswitches) then [ "${dev}-netdev.service" ] - else optional (dev != null && dev != "lo" && !config.boot.isContainer) (subsystemDevice dev); + else optional (!config.boot.isContainer) (subsystemDevice dev); hasDefaultGatewaySet = (cfg.defaultGateway != null && cfg.defaultGateway.address != "") || (cfg.enableIPv6 && cfg.defaultGateway6 != null && cfg.defaultGateway6.address != ""); @@ -501,11 +502,14 @@ let }); createSitDevice = n: v: nameValuePair "${n}-netdev" + (let + deps = deviceDependency v.dev; + in { description = "6-to-4 Tunnel Interface ${n}"; wantedBy = [ "network-setup.service" (subsystemDevice n) ]; - bindsTo = optionals (v.dev != null) (deviceDependency v.dev); + bindsTo = deps; partOf = [ "network-setup.service" ]; - after = [ "network-pre.target" ] ++ optionals (v.dev != null) (deviceDependency v.dev); + after = [ "network-pre.target" ] ++ deps; before = [ "network-setup.service" ]; serviceConfig.Type = "oneshot"; serviceConfig.RemainAfterExit = true; @@ -528,7 +532,7 @@ let postStop = '' ip link delete dev "${n}" || true ''; - }; + }); createGreDevice = n: v: nameValuePair "${n}-netdev" (let -- cgit v1.2.3