From 9a81748f2044ccea5e5083e3c8b38c4f6f79cda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 6 Jan 2013 22:31:13 +0100 Subject: [PATCH] Adding defaultGatewayWindowSize This allows setting the max tcp window size for the route of the default gateway (usually the internet access). It works only for non-DHCP configurations by now. --- modules/tasks/network-interfaces.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index 64cb4a6749e..740c3b83cda 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -5,6 +5,10 @@ with pkgs.lib; let cfg = config.networking; + + windowSize = if cfg.defaultGatewayWindowSize != "" then + "window ${cfg.defaultGatewayWindowSize}" else ""; + interfaces = attrValues cfg.interfaces; hasVirtuals = any (i: i.virtual) interfaces; @@ -135,6 +139,15 @@ in ''; }; + networking.defaultGatewayWindowSize = mkOption { + default = ""; + example = "524288"; + description = '' + The window size of the default gateway. It limits maximal data bursts that TCP peers + are allowed to send to us. + ''; + }; + networking.nameservers = mkOption { default = []; example = ["130.161.158.4" "130.161.33.17"]; @@ -282,7 +295,7 @@ in # Set the default gateway. ${optionalString (cfg.defaultGateway != "") '' # FIXME: get rid of "|| true" (necessary to make it idempotent). - ip route add default via "${cfg.defaultGateway}" || true + ip route add default via "${cfg.defaultGateway}" ${windowSize} || true ''} # Turn on forwarding if any interface has enabled proxy_arp.