From cf584b9c0700bf0b7998b9e801e35ec5f03db0b0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 06:32:12 +0000 Subject: [PATCH] Fix WireGuard RTNETLINK File exists crash loop on S6 service restart Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/caef8dfd-90cd-45ac-a539-6049bb90fd9b Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- qbittorrent/CHANGELOG.md | 3 +++ qbittorrent/config.yaml | 2 +- qbittorrent/rootfs/usr/local/sbin/vpn | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/qbittorrent/CHANGELOG.md b/qbittorrent/CHANGELOG.md index 822d93a32f..5d6843a901 100644 --- a/qbittorrent/CHANGELOG.md +++ b/qbittorrent/CHANGELOG.md @@ -1,4 +1,7 @@ +## 5.2.0-3 (2026-05-12) +- Fix WireGuard "RTNETLINK answers: File exists" crash loop: clean up stale interface and routing rules before re-establishing the tunnel on S6 service restart + ## 5.2.0-2 (2026-05-10) - Fix startup loop on aarch64: drop s6-notifyoncheck wrapper so s6 supervises qbittorrent-nox directly (LSIO arm64 image has no notification-fd, causing EBADF restart loop) diff --git a/qbittorrent/config.yaml b/qbittorrent/config.yaml index 9b987cc09b..78eca23a9f 100644 --- a/qbittorrent/config.yaml +++ b/qbittorrent/config.yaml @@ -143,4 +143,4 @@ schema: slug: qbittorrent udev: true url: https://github.com/alexbelgium/hassio-addons -version: "5.2.0-2" +version: "5.2.0-3" diff --git a/qbittorrent/rootfs/usr/local/sbin/vpn b/qbittorrent/rootfs/usr/local/sbin/vpn index 91a1fa0e02..e27b2e2d2f 100755 --- a/qbittorrent/rootfs/usr/local/sbin/vpn +++ b/qbittorrent/rootfs/usr/local/sbin/vpn @@ -279,6 +279,16 @@ _wireguard_up() { fi done + # Clean up any leftover state from a previous run (e.g., after an S6 service restart). + # Without this, `ip link add` and `ip rule add` fail with "RTNETLINK answers: File exists" + # when the svc-qbittorrent service is restarted while the WireGuard interface is still up. + if ip link show "${config["Interface"]}" > /dev/null 2>&1; then + bashio::log.info "WireGuard interface ${config["Interface"]} already exists. Cleaning up before re-establishing connection." + ip link set "${config["Interface"]}" down 2>/dev/null || true + ip link del "${config["Interface"]}" 2>/dev/null || true + fi + _routing_del 2>/dev/null || true + _cmd "ip link add ${config["Interface"]} type wireguard" || return 1 mapfile -d ',' -t local_ips < <(echo "${config["Address"]}" | tr -d ' ')