From d63035329e6c7c07bf5cd3c4e06f4b8d2e71653f Mon Sep 17 00:00:00 2001 From: apfelkuchen06 Date: Tue, 28 Feb 2023 00:06:39 +0100 Subject: [PATCH] nixos/networkd: add TokenBucketFilter options --- nixos/modules/system/boot/networkd.nix | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/nixos/modules/system/boot/networkd.nix b/nixos/modules/system/boot/networkd.nix index c52816e876ee..573290133f8b 100644 --- a/nixos/modules/system/boot/networkd.nix +++ b/nixos/modules/system/boot/networkd.nix @@ -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; };