Merge pull request #257510 from ign0tus/fix/wake-on-lan-policy

Fix: WakeOnLan policy
This commit is contained in:
Florian Klink 2023-10-04 11:36:16 +03:00 committed by GitHub
commit 42f2e2dadd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 2 deletions

View file

@ -80,6 +80,10 @@ in rec {
optional (attr ? ${name} && !elem attr.${name} values)
"Systemd ${group} field `${name}' cannot have value `${toString attr.${name}}'.";
assertValuesSomeOfOr = name: values: default: group: attr:
optional (attr ? ${name} && !(all (x: elem x values) (splitString " " attr.${name}) || attr.${name} == default))
"Systemd ${group} field `${name}' cannot have value `${toString attr.${name}}'.";
assertHasField = name: group: attr:
optional (!(attr ? ${name}))
"Systemd ${group} field `${name}' must exist.";

View file

@ -83,7 +83,7 @@ let
(assertByteFormat "BitsPerSecond")
(assertValueOneOf "Duplex" ["half" "full"])
(assertValueOneOf "AutoNegotiation" boolValues)
(assertValueOneOf "WakeOnLan" ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon" "off"])
(assertValuesSomeOfOr "WakeOnLan" ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon"] "off")
(assertValueOneOf "Port" ["tp" "aui" "bnc" "mii" "fibre"])
(assertValueOneOf "ReceiveChecksumOffload" boolValues)
(assertValueOneOf "TransmitChecksumOffload" boolValues)

View file

@ -62,7 +62,7 @@ let
} // optionalAttrs (i.mtu != null) {
MTUBytes = toString i.mtu;
} // optionalAttrs (i.wakeOnLan.enable == true) {
WakeOnLan = "magic";
WakeOnLan = concatStringsSep " " i.wakeOnLan.policy;
};
};
in listToAttrs (map createNetworkLink interfaces);

View file

@ -327,6 +327,24 @@ let
default = false;
description = lib.mdDoc "Whether to enable wol on this interface.";
};
policy = mkOption {
type = with types; listOf (
enum ["phy" "unicast" "multicast" "broadcast" "arp" "magic" "secureon"]
);
default = ["magic"];
description = lib.mdDoc ''
The [Wake-on-LAN policy](https://www.freedesktop.org/software/systemd/man/systemd.link.html#WakeOnLan=)
to set for the device.
The options are
- `phy`: Wake on PHY activity
- `unicast`: Wake on unicast messages
- `multicast`: Wake on multicast messages
- `broadcast`: Wake on broadcast messages
- `arp`: Wake on ARP
- `magic`: Wake on receipt of a magic packet
'';
};
};
};