From c3f3fd11c697217e2fbd5e78b9a38039240d046f Mon Sep 17 00:00:00 2001
From: Evangelos Foutras <evangelos@foutrelis.com>
Date: Mon, 17 Apr 2017 17:03:42 +0300
Subject: [PATCH] common: allow configuring tcp congestion control

Also set it to BBR on soyuz because it seems to greatly increase my
download speeds from mirror.pkgbuild.com; example download results:

   CUBIC: 60.75M in 28s (2.18 MB/s)
     BBR: 60.75M in 12s (5.12 MB/s)

BBR gets to my line's max rate very fast while CUBIC struggles and only
very slowly scales up. Not sure if my ISP is to blame but seeing as BBR
works so well, we might as well use it.
---
 host_vars/soyuz.archlinux.org | 2 +-
 roles/common/tasks/main.yml   | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/host_vars/soyuz.archlinux.org b/host_vars/soyuz.archlinux.org
index 8826089be..d87360870 100644
--- a/host_vars/soyuz.archlinux.org
+++ b/host_vars/soyuz.archlinux.org
@@ -6,5 +6,5 @@ ipv6_address: "2a01:4f8:173:1654::1"
 ipv6_netmask: "/128"
 ipv4_gateway: "138.201.206.65"
 ipv6_gateway: "fe80::1"
+tcp_congestion_control: "bbr"
 filesystem: btrfs
-
diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml
index 3b5aa2bc8..5dd45a9df 100644
--- a/roles/common/tasks/main.yml
+++ b/roles/common/tasks/main.yml
@@ -35,6 +35,13 @@
   notify:
     - restart networkd
 
+- name: configure tcp congestion control algorithm
+  sysctl:
+    name: net.ipv4.tcp_congestion_control
+    value: "{{tcp_congestion_control}}"
+    sysctl_file: /etc/sysctl.d/local.conf
+  when: tcp_congestion_control is defined
+
 - name: configure journald
   template: src={{item}}.j2 dest=/etc/systemd/{{item}} owner=root group=root mode=644
   with_items:
-- 
GitLab