diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-01-02 07:53:31 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-01-02 11:00:39 +0530 |
commit | d4ff40f9901198488a5599330ee7b8f110275a6d (patch) | |
tree | 1fd88d14c2f01529b0aaf1899bc907a0d2432277 /modules | |
parent | 96b415ee41aa4580a7771d08e354bf4800e04749 (diff) |
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
Diffstat (limited to 'modules')
-rw-r--r-- | modules/network-interfaces-scripted.nix | 14 |
1 files changed, 9 insertions, 5 deletions
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 |