From c1d06d9501f26f7c16fe4136b6b8dcb7f473a6d1 Mon Sep 17 00:00:00 2001 From: bt90 Date: Fri, 5 Mar 2021 08:08:29 +0100 Subject: [PATCH] build: Package sysctl configuration to raise UDP buffer size on Linux (#7417) * Provide a sysctl config to raise max UDP buffer size * Add sysctl config to deb * Check if `deb-systemd-invoke` is available Co-authored-by: otbutz --- build.go | 1 + etc/linux-sysctl/30-syncthing.conf | 3 +++ etc/linux-sysctl/README.md | 21 +++++++++++++++++++++ script/post-upgrade | 5 +++++ 4 files changed, 30 insertions(+) create mode 100644 etc/linux-sysctl/30-syncthing.conf create mode 100644 etc/linux-sysctl/README.md diff --git a/build.go b/build.go index 3b18c61e6..b38e1cd58 100644 --- a/build.go +++ b/build.go @@ -115,6 +115,7 @@ var targets = map[string]target{ {src: "etc/linux-systemd/system/syncthing@.service", dst: "deb/lib/systemd/system/syncthing@.service", perm: 0644}, {src: "etc/linux-systemd/system/syncthing-resume.service", dst: "deb/lib/systemd/system/syncthing-resume.service", perm: 0644}, {src: "etc/linux-systemd/user/syncthing.service", dst: "deb/usr/lib/systemd/user/syncthing.service", perm: 0644}, + {src: "etc/linux-sysctl/30-syncthing.conf", dst: "deb/usr/lib/sysctl.d/30-syncthing.conf", perm: 0644}, {src: "etc/firewall-ufw/syncthing", dst: "deb/etc/ufw/applications.d/syncthing", perm: 0644}, {src: "etc/linux-desktop/syncthing-start.desktop", dst: "deb/usr/share/applications/syncthing-start.desktop", perm: 0644}, {src: "etc/linux-desktop/syncthing-ui.desktop", dst: "deb/usr/share/applications/syncthing-ui.desktop", perm: 0644}, diff --git a/etc/linux-sysctl/30-syncthing.conf b/etc/linux-sysctl/30-syncthing.conf new file mode 100644 index 000000000..9c7787409 --- /dev/null +++ b/etc/linux-sysctl/30-syncthing.conf @@ -0,0 +1,3 @@ +# Increase maximum receive socket buffer size to 2MiB for QUIC connections +# see https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size +net.core.rmem_max = 2097152 diff --git a/etc/linux-sysctl/README.md b/etc/linux-sysctl/README.md new file mode 100644 index 000000000..0c0e06dfe --- /dev/null +++ b/etc/linux-sysctl/README.md @@ -0,0 +1,21 @@ +sysctl configuration to raise UDP buffer size +=================== +Installation +----------- +**Please note:** When you installed syncthing using the official deb package, you can skip the copying. + +Copy the file `30-syncthing.conf` to `/etc/sysctl.d/` (root permissions required). + +In a terminal run +``` +sudo sysctl -q --system +``` +to apply the sysctl changes. + + +Verification +---------- +You can verify that the new limit is active using +``` +sysctl net.core.rmem_max +``` diff --git a/script/post-upgrade b/script/post-upgrade index 6be37d5bb..5fb8ad187 100644 --- a/script/post-upgrade +++ b/script/post-upgrade @@ -1,3 +1,8 @@ #!/bin/sh +if command -v deb-systemd-invoke > /dev/null; then + deb-systemd-invoke restart procps.service +else + sysctl -q --system +fi pkill -HUP -x syncthing || true