Skip to content

Commit

Permalink
nixos/networkd: add CAKE options
Browse files Browse the repository at this point in the history
  • Loading branch information
apfelkuchen6 committed Mar 16, 2023
1 parent 7a6cae0 commit 7281085
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions nixos/modules/system/boot/networkd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,56 @@ let
"Handle"
])
];

sectionCAKE = checkUnitConfig "CAKE" [
(assertOnlyFields [
"Parent"
"Handle"
"Bandwidth"
"AutoRateIngress"
"OverheadBytes"
"MPUBytes"
"CompensationMode"
"UseRawPacketSize"
"FlowIsolationMode"
"NAT"
"PriorityQueueingPreset"
"FirewallMark"
"Wash"
"SplitGSO"
])
(assertValueOneOf "AutoRateIngress" boolValues)
(assertInt "OverheadBytes")
(assertRange "OverheadBytes" (-64) 256)
(assertInt "MPUBytes")
(assertRange "MPUBytes" 1 256)
(assertValueOneOf "CompensationMode" [ "none" "atm" "ptm" ])
(assertValueOneOf "UseRawPacketSize" boolValues)
(assertValueOneOf "FlowIsolationMode"
[
"none"
"src-host"
"dst-host"
"hosts"
"flows"
"dual-src-host"
"dual-dst-host"
"triple"
])
(assertValueOneOf "NAT" boolValues)
(assertValueOneOf "PriorityQueueingPreset"
[
"besteffort"
"precedence"
"diffserv8"
"diffserv4"
"diffserv3"
])
(assertInt "FirewallMark")
(assertRange "FirewallMark" 1 4294967295)
(assertValueOneOf "Wash" boolValues)
(assertValueOneOf "SplitGSO" boolValues)
];
};
};

Expand Down Expand Up @@ -1996,6 +2046,17 @@ let
'';
};

cakeConfig = mkOption {
default = {};
example = { Bandwidth = "40M"; OverheadBytes = 8; CompensationMode = "ptm"; };
type = types.addCheck (types.attrsOf unitOption) check.network.sectionCAKE;
description = lib.mdDoc ''
Each attribute in this set specifies an option in the
`[CAKE]` section of the unit. See
{manpage}`systemd.network(5)` for details.
'';
};

name = mkOption {
type = types.nullOr types.str;
default = null;
Expand Down Expand Up @@ -2471,6 +2532,10 @@ let
[PFIFOFast]
${attrsToSection def.pfifoFastConfig}
''
+ optionalString (def.cakeConfig != { }) ''
[CAKE]
${attrsToSection def.cakeConfig}
''
+ def.extraConfig;
};

Expand Down

0 comments on commit 7281085

Please sign in to comment.