From 0b1322d1c68903390c45ed6496dd896e1f93cf3e Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Fri, 12 Jun 2026 22:41:45 +0000 Subject: [PATCH] fix(packaging): ship the UDP socket-buffer sysctl in the .deb and .rpm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The host requests a 32 MB SO_SNDBUF, but the kernel clamps it to net.core.wmem_max (~416 KB on a stock box) — so high-bitrate frames overflow the socket buffer and the host drops a large fraction of packets on send (measured 28.5% loss / 54k dropped at 1 Gbps to a clean LAN client on a fresh Bazzite box). scripts/99-punktfunk-net.conf fixes it (32 MB caps) but the packages never installed it. Ship it to /usr/lib/sysctl.d/ (auto-applied at boot by systemd-sysctl) and apply it in the deb/rpm postinst. This is the dominant cause of the sub-Gbps ceiling on an untuned host. Co-Authored-By: Claude Opus 4.8 (1M context) --- packaging/debian/build-deb.sh | 5 +++++ packaging/rpm/punktfunk.spec | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/packaging/debian/build-deb.sh b/packaging/debian/build-deb.sh index 6414105..3c5a5de 100755 --- a/packaging/debian/build-deb.sh +++ b/packaging/debian/build-deb.sh @@ -37,6 +37,9 @@ SHAREDIR="$STAGE/usr/share/$PKG" # --- file layout (matches the RPM %install) ---------------------------------- install -Dm0755 "$BIN" "$STAGE/usr/bin/$PKG" install -Dm0644 scripts/60-punktfunk.rules "$STAGE/usr/lib/udev/rules.d/60-punktfunk.rules" +# UDP socket-buffer tuning (32 MB) — without it the kernel clamps the host's SO_SNDBUF to ~416 KB +# and high-bitrate frames overflow it (send-side packet loss). systemd-sysctl applies it at boot. +install -Dm0644 scripts/99-punktfunk-net.conf "$STAGE/usr/lib/sysctl.d/99-punktfunk-net.conf" install -Dm0644 scripts/punktfunk-host.service "$STAGE/usr/lib/systemd/user/punktfunk-host.service" install -Dm0755 scripts/headless/run-headless-kde.sh "$SHAREDIR/headless/run-headless-kde.sh" install -Dm0755 scripts/headless/run-headless-sway.sh "$SHAREDIR/headless/run-headless-sway.sh" @@ -133,6 +136,8 @@ if [ "$1" = "configure" ]; then # Pick up the /dev/uinput rule without a reboot (best-effort, no-op in containers). udevadm control --reload-rules 2>/dev/null || true udevadm trigger --subsystem-match=misc 2>/dev/null || true + # Apply the UDP socket-buffer tuning now (also auto-applied at boot by systemd-sysctl). + sysctl -p /usr/lib/sysctl.d/99-punktfunk-net.conf >/dev/null 2>&1 || true echo "punktfunk-host installed. Add yourself to the 'input' group for virtual gamepads:" echo " sudo usermod -aG input \"\$USER\" # then re-login" echo "Config: mkdir -p ~/.config/punktfunk && cp /usr/share/punktfunk-host/host.env.example ~/.config/punktfunk/host.env" diff --git a/packaging/rpm/punktfunk.spec b/packaging/rpm/punktfunk.spec index aaf57fa..8ab60da 100644 --- a/packaging/rpm/punktfunk.spec +++ b/packaging/rpm/punktfunk.spec @@ -112,6 +112,10 @@ install -Dm0755 target/release/punktfunk-host %{buildroot}%{_bindir}/punktfunk-h # udev rule — /dev/uinput access for virtual gamepads (input group). install -Dm0644 scripts/60-punktfunk.rules %{buildroot}%{_udevrulesdir}/60-punktfunk.rules +# UDP socket-buffer tuning (32 MB) — without it the kernel clamps the host's SO_SNDBUF to ~416 KB +# and high-bitrate frames overflow it (send-side loss). systemd-sysctl applies it at boot. +install -Dm0644 scripts/99-punktfunk-net.conf %{buildroot}%{_prefix}/lib/sysctl.d/99-punktfunk-net.conf + # systemd *user* unit (the host runs in the graphical session, not as root). install -Dm0644 scripts/punktfunk-host.service %{buildroot}%{_userunitdir}/punktfunk-host.service @@ -128,6 +132,7 @@ install -Dm0644 docs/api/openapi.json %{buildroot}%{_datadir}/% %doc README.md docs/implementation-plan.md packaging/README.md %{_bindir}/punktfunk-host %{_udevrulesdir}/60-punktfunk.rules +%{_prefix}/lib/sysctl.d/99-punktfunk-net.conf %{_userunitdir}/punktfunk-host.service %dir %{_datadir}/%{name} %{_datadir}/%{name}/* @@ -136,6 +141,9 @@ install -Dm0644 docs/api/openapi.json %{buildroot}%{_datadir}/% # Reload udev so /dev/uinput picks up the new rule without a reboot (best-effort). udevadm control --reload-rules 2>/dev/null || : udevadm trigger --subsystem-match=misc 2>/dev/null || : +# Apply the UDP socket-buffer tuning (also auto-applied at boot by systemd-sysctl; on rpm-ostree +# it takes effect on the next boot into the layered deployment). +sysctl -p %{_prefix}/lib/sysctl.d/99-punktfunk-net.conf >/dev/null 2>&1 || : echo "punktfunk installed. Add yourself to the 'input' group (sudo usermod -aG input \$USER)" echo "then enable the host: systemctl --user enable --now punktfunk-host" echo "Config: cp %{_datadir}/%{name}/host.env.bazzite ~/.config/punktfunk/host.env"