From 4ed9c19c04faf7bbf893cdd178014066e9eec5f5 Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Wed, 3 Jan 2024 16:44:25 +0100
Subject: [PATCH] dropbear: increase default receive window size

Increasing the receive window size improves throughout on higher-latency
links such as WAN connections. The current default of 24KB caps out at
around 500 KB/s.

Increasing the receive buffer to 256KB increases the throughput to at
least 11 MB/s.

Signed-off-by: David Bauer <mail@david-bauer.net>
---
 ...increase-default-receive-window-size.patch | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 patches/openwrt/0008-dropbear-increase-default-receive-window-size.patch

diff --git a/patches/openwrt/0008-dropbear-increase-default-receive-window-size.patch b/patches/openwrt/0008-dropbear-increase-default-receive-window-size.patch
new file mode 100644
index 00000000..6617b719
--- /dev/null
+++ b/patches/openwrt/0008-dropbear-increase-default-receive-window-size.patch
@@ -0,0 +1,31 @@
+From: David Bauer <mail@david-bauer.net>
+Date: Thu, 28 Dec 2023 23:16:02 +0100
+Subject: dropbear: increase default receive window size
+
+Increasing the receive window size improves throughout on higher-latency
+links such as WAN connections. The current default of 24KB caps out at
+around 500 KB/s.
+
+Increasing the receive buffer to 256KB increases the throughput to at
+least 11 MB/s.
+
+Signed-off-by: David Bauer <mail@david-bauer.net>
+(cherry picked from commit f95eecfb21ff08662e022accd30e8254028ff63b)
+
+diff --git a/package/network/services/dropbear/files/dropbear.init b/package/network/services/dropbear/files/dropbear.init
+index b82e967cbcedc4564dba6cfccc1383f7b7fa499f..a40b5f7baeea0f3a1e258f1a74aba0eb1ca3adcb 100755
+--- a/package/network/services/dropbear/files/dropbear.init
++++ b/package/network/services/dropbear/files/dropbear.init
+@@ -155,6 +155,12 @@ dropbear_instance()
+ 	PIDCOUNT="$(( ${PIDCOUNT} + 1))"
+ 	local pid_file="/var/run/${NAME}.${PIDCOUNT}.pid"
+ 
++	# Increase default receive window size to increase
++	# throughput on high latency links
++	if [ "${RecvWindowSize}" -eq "0" ]; then
++		RecvWindowSize="262144"
++	fi
++
+ 	procd_open_instance
+ 	procd_set_param command "$PROG" -F -P "$pid_file"
+ 	[ "${PasswordAuth}" -eq 0 ] && procd_append_param command -s
-- 
GitLab