Merge pull request #45722 from lopsided98/networkd-fix-range
nixos/networkd: fix range assertions on 32 bit Nix
This commit is contained in:
commit
f7abb71555
@ -30,10 +30,14 @@ let
|
|||||||
(assertValueOneOf "UDPSegmentationOffload" boolValues)
|
(assertValueOneOf "UDPSegmentationOffload" boolValues)
|
||||||
(assertValueOneOf "GenericReceiveOffload" boolValues)
|
(assertValueOneOf "GenericReceiveOffload" boolValues)
|
||||||
(assertValueOneOf "LargeReceiveOffload" boolValues)
|
(assertValueOneOf "LargeReceiveOffload" boolValues)
|
||||||
(assertRange "RxChannels" 1 4294967295)
|
(assertInt "RxChannels")
|
||||||
(assertRange "TxChannels" 1 4294967295)
|
(assertMinimum "RxChannels" 1)
|
||||||
(assertRange "OtherChannels" 1 4294967295)
|
(assertInt "TxChannels")
|
||||||
(assertRange "CombinedChannels" 1 4294967295)
|
(assertMinimum "TxChannels" 1)
|
||||||
|
(assertInt "OtherChannels")
|
||||||
|
(assertMinimum "OtherChannels" 1)
|
||||||
|
(assertInt "CombinedChannels")
|
||||||
|
(assertMinimum "CombinedChannels" 1)
|
||||||
];
|
];
|
||||||
|
|
||||||
checkNetdev = checkUnitConfig "Netdev" [
|
checkNetdev = checkUnitConfig "Netdev" [
|
||||||
@ -226,7 +230,8 @@ let
|
|||||||
(assertValueOneOf "UseTimezone" boolValues)
|
(assertValueOneOf "UseTimezone" boolValues)
|
||||||
(assertValueOneOf "CriticalConnection" boolValues)
|
(assertValueOneOf "CriticalConnection" boolValues)
|
||||||
(assertValueOneOf "RequestBroadcast" boolValues)
|
(assertValueOneOf "RequestBroadcast" boolValues)
|
||||||
(assertRange "RouteTable" 0 4294967295)
|
(assertInt "RouteTable")
|
||||||
|
(assertMinimum "RouteTable" 0)
|
||||||
(assertValueOneOf "RapidCommit" boolValues)
|
(assertValueOneOf "RapidCommit" boolValues)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -73,11 +73,19 @@ in rec {
|
|||||||
optional (attr ? ${name} && !(min <= attr.${name} && max >= attr.${name}))
|
optional (attr ? ${name} && !(min <= attr.${name} && max >= attr.${name}))
|
||||||
"Systemd ${group} field `${name}' is outside the range [${toString min},${toString max}]";
|
"Systemd ${group} field `${name}' is outside the range [${toString min},${toString max}]";
|
||||||
|
|
||||||
|
assertMinimum = name: min: group: attr:
|
||||||
|
optional (attr ? ${name} && attr.${name} < min)
|
||||||
|
"Systemd ${group} field `${name}' must be greater than or equal to ${toString min}";
|
||||||
|
|
||||||
assertOnlyFields = fields: group: attr:
|
assertOnlyFields = fields: group: attr:
|
||||||
let badFields = filter (name: ! elem name fields) (attrNames attr); in
|
let badFields = filter (name: ! elem name fields) (attrNames attr); in
|
||||||
optional (badFields != [ ])
|
optional (badFields != [ ])
|
||||||
"Systemd ${group} has extra fields [${concatStringsSep " " badFields}].";
|
"Systemd ${group} has extra fields [${concatStringsSep " " badFields}].";
|
||||||
|
|
||||||
|
assertInt = name: group: attr:
|
||||||
|
optional (attr ? ${name} && !isInt attr.${name})
|
||||||
|
"Systemd ${group} field `${name}' is not an integer";
|
||||||
|
|
||||||
checkUnitConfig = group: checks: attrs: let
|
checkUnitConfig = group: checks: attrs: let
|
||||||
# We're applied at the top-level type (attrsOf unitOption), so the actual
|
# We're applied at the top-level type (attrsOf unitOption), so the actual
|
||||||
# unit options might contain attributes from mkOverride that we need to
|
# unit options might contain attributes from mkOverride that we need to
|
||||||
|
Loading…
Reference in New Issue
Block a user