nixos/networkd: add TokenBucketFilter options

This commit is contained in:
apfelkuchen06 2023-02-28 00:06:39 +01:00
parent 55cd970d73
commit d63035329e

View file

@ -1119,6 +1119,20 @@ let
(assertInt "PacketLimit")
(assertRange "PacketLimit" 0 4294967294)
];
sectionTokenBucketFilter = checkUnitConfig "TokenBucketFilter" [
(assertOnlyFields [
"Parent"
"Handle"
"LatencySec"
"LimitBytes"
"BurstBytes"
"Rate"
"MPUBytes"
"PeakRate"
"MTUBytes"
])
];
};
};
@ -1809,6 +1823,17 @@ let
'';
};
tokenBucketFilterConfig = mkOption {
default = {};
example = { Parent = "ingress"; Rate = "100k"; };
type = types.addCheck (types.attrsOf unitOption) check.network.sectionTokenBucketFilter;
description = lib.mdDoc ''
Each attribute in this set specifies an option in the
`[TokenBucketFilter]` section of the unit. See
{manpage}`systemd.network(5)` for details.
'';
};
name = mkOption {
type = types.nullOr types.str;
default = null;
@ -2248,6 +2273,10 @@ let
[NetworkEmulator]
${attrsToSection def.networkEmulatorConfig}
''
+ optionalString (def.tokenBucketFilterConfig != { }) ''
[TokenBucketFilter]
${attrsToSection def.tockenBucketFilterConfig}
''
+ def.extraConfig;
};