From 6996096765476edf79dadd828b5a119bef8e22a8 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Wed, 25 Nov 2026 18:06:16 +0000 Subject: [PATCH] nixos: Use BBR for TCP sent from colony and home `estuary`'s port in ColoClue DC6 loses bursts of packets whenever the members switch floods other members' traffic to it. CUBIC treats each burst as congestion and takes 20-30 s to recover, longer than the gap between floods. BBR keeps going. Between `estuary` and `river`, it averaged 899 Mbit/s against CUBIC's 258 Mbit/s downloading from colony, and 185 against 149 Mbit/s uploading to it. Add a `my.network.bbr` option. Congestion control is chosen by the sender, so enable it on the colony boxes that send data off-box (`colony`, `shill` and its `middleman` proxy, `git`, `whale2`), and for uploads on `castle` and the home routers. Forwarded traffic isn't affected, so the routers only gain for their own connections and `estuary` is left alone. BBR paces itself, so the default qdisc stays. Co-Authored-By: Claude Opus 5.5 --- nixos/boxes/colony/default.nix | 2 ++ nixos/boxes/colony/vms/git/default.nix | 2 ++ .../vms/shill/containers/middleman/default.nix | 1 + nixos/boxes/colony/vms/shill/default.nix | 1 + nixos/boxes/colony/vms/whale2/default.nix | 1 + nixos/boxes/home/castle/default.nix | 1 + nixos/boxes/home/routing-common/default.nix | 1 + nixos/modules/network.nix | 18 ++++++++++++++++++ 8 files changed, 27 insertions(+) diff --git a/nixos/boxes/colony/default.nix b/nixos/boxes/colony/default.nix index c1c653f..2b4cb8f 100644 --- a/nixos/boxes/colony/default.nix +++ b/nixos/boxes/colony/default.nix @@ -379,6 +379,8 @@ in my = { #deploy.generate.system.mode = "boot"; + network.bbr = true; + secrets = { key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPIijqzAWF6OxKr4aeCa1TAc5xGn4rdIjVTt0wAPU6uY"; files = { diff --git a/nixos/boxes/colony/vms/git/default.nix b/nixos/boxes/colony/vms/git/default.nix index 1687823..528058b 100644 --- a/nixos/boxes/colony/vms/git/default.nix +++ b/nixos/boxes/colony/vms/git/default.nix @@ -180,6 +180,8 @@ in }; my = { + network.bbr = true; + secrets = { key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP+KINpHLMduBuW96JzfSRDLUzkI+XaCBghu5/wHiW5R"; files = { diff --git a/nixos/boxes/colony/vms/shill/containers/middleman/default.nix b/nixos/boxes/colony/vms/shill/containers/middleman/default.nix index 8b8fcec..bfb514a 100644 --- a/nixos/boxes/colony/vms/shill/containers/middleman/default.nix +++ b/nixos/boxes/colony/vms/shill/containers/middleman/default.nix @@ -36,6 +36,7 @@ in my = { deploy.enable = false; server.enable = true; + network.bbr = true; secrets = { key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAQM9U1e/XcUCyMJITrpAHjAGahpqkZCmtX6pJkYzuks"; diff --git a/nixos/boxes/colony/vms/shill/default.nix b/nixos/boxes/colony/vms/shill/default.nix index 3d03a5b..ddb4c48 100644 --- a/nixos/boxes/colony/vms/shill/default.nix +++ b/nixos/boxes/colony/vms/shill/default.nix @@ -166,6 +166,7 @@ in my = { secrets.key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ6bc1pQCYalLXdB4X+7kFXtkTdFalbH5rchjuYj2ceU"; server.enable = true; + network.bbr = true; firewall = { tcp.allowed = [ 19999 ]; diff --git a/nixos/boxes/colony/vms/whale2/default.nix b/nixos/boxes/colony/vms/whale2/default.nix index 799bdab..e048d78 100644 --- a/nixos/boxes/colony/vms/whale2/default.nix +++ b/nixos/boxes/colony/vms/whale2/default.nix @@ -162,6 +162,7 @@ in my = { secrets.key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDBTIj1jVdknXLNNroMJfgy7S2cSUC/qgFdnaUopEUzZ"; server.enable = true; + network.bbr = true; firewall = { tcp.allowed = [ 19999 ]; diff --git a/nixos/boxes/home/castle/default.nix b/nixos/boxes/home/castle/default.nix index adb153e..d19dc9e 100644 --- a/nixos/boxes/home/castle/default.nix +++ b/nixos/boxes/home/castle/default.nix @@ -221,6 +221,7 @@ in my = { tmproot.size = "24G"; + network.bbr = true; user = { config.extraGroups = [ "input" ]; diff --git a/nixos/boxes/home/routing-common/default.nix b/nixos/boxes/home/routing-common/default.nix index 896bd09..7a12e59 100644 --- a/nixos/boxes/home/routing-common/default.nix +++ b/nixos/boxes/home/routing-common/default.nix @@ -317,6 +317,7 @@ in as211024 = config.age.secrets."l2mesh/as211024.key".path; }; }; + network.bbr = true; firewall = { trustedInterfaces = [ "lan-hi" "lan-lo" ]; udp.allowed = [ 5353 ]; diff --git a/nixos/modules/network.nix b/nixos/modules/network.nix index 80fabb0..4818e3b 100644 --- a/nixos/modules/network.nix +++ b/nixos/modules/network.nix @@ -1,8 +1,16 @@ { lib, pkgs, config, ... }: let inherit (lib) flatten optional mkIf mkDefault mkMerge versionAtLeast; + inherit (lib.my) mkBoolOpt'; + + cfg = config.my.network; in { + options.my.network.bbr = mkBoolOpt' false + ("Whether to use BBR congestion control for TCP connections this box sends. Unlike the default " + + "(CUBIC), BBR doesn't treat packet loss as congestion, so it keeps throughput up on lossy paths. " + + "It has no effect on traffic the box forwards."); + config = mkMerge [ { networking = { @@ -22,6 +30,16 @@ in }; } + (mkIf cfg.bbr { + # BBR paces its own sending, so the default qdisc (fq_codel) stays as it is. A container's + # network namespace copies the host's setting only when it's created, so enable this in + # containers too for it to apply without a restart. + boot = { + kernelModules = [ "tcp_bbr" ]; + kernel.sysctl."net.ipv4.tcp_congestion_control" = "bbr"; + }; + }) + (mkIf config.my.build.isDevVM { networking.interfaces.eth0.useDHCP = mkDefault true; virtualisation = {