[PR #148] [CLOSED] conn: don't reset the listen port to 0 when IPv6 is unavailable #166

Closed
opened 2026-10-13 21:04:12 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amneziawg-go/pull/148
Author: @wizier
Created: 6/17/2026
Status: ❌ Closed

Base: master ← Head: fix/bind-listen-port-ipv6-disabled


📝 Commits (1)

  • f24f9fe conn: don't reset the listen port to 0 when IPv6 is unavailable

📊 Changes

1 file changed (+5 additions, -1 deletions)

View changed files

📝 conn/bind_std.go (+5 -1)

📄 Description

Problem

StdNetBind.Open binds the udp4 and udp6 sockets into the same port variable:

v4conn, port, err = listenNet("udp4", port)
...
v6conn, port, err = listenNet("udp6", port)

On a host with IPv6 disabled in the kernel (ipv6.disable=1 on the kernel command line, or the ipv6 module blacklisted), the udp6 ListenPacket returns EAFNOSUPPORT. That error is intentionally tolerated, but the assignment has already overwritten the port udp4 successfully bound with 0. Open then returns actualPort == 0 even though the v4 socket is bound and serving traffic.

Because the UAPI get handler only emits listen_port when it is non-zero, the line disappears entirely, so anything that reads the port back (wgctrl, awg show, a control plane reconciling expected vs. live config) sees 0.

Fix

Give the udp6 listener its own port variable and adopt it only when v6 actually bound. A udp6 EAFNOSUPPORT no longer clobbers the live udp4 port.

Note

This code is inherited verbatim from upstream wireguard-go (conn/bind_std.go), so the same bug exists there.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amnezia-vpn/amneziawg-go/pull/148 **Author:** [@wizier](https://github.com/wizier) **Created:** 6/17/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/bind-listen-port-ipv6-disabled` --- ### 📝 Commits (1) - [`f24f9fe`](https://github.com/amnezia-vpn/amneziawg-go/commit/f24f9fea0bfa879febbecc89d1d0954f800dfa20) conn: don't reset the listen port to 0 when IPv6 is unavailable ### 📊 Changes **1 file changed** (+5 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `conn/bind_std.go` (+5 -1) </details> ### 📄 Description ## Problem `StdNetBind.Open` binds the udp4 and udp6 sockets into the same `port` variable: ```go v4conn, port, err = listenNet("udp4", port) ... v6conn, port, err = listenNet("udp6", port) ``` On a host with IPv6 disabled in the kernel (`ipv6.disable=1` on the kernel command line, or the `ipv6` module blacklisted), the udp6 `ListenPacket` returns `EAFNOSUPPORT`. That error is intentionally tolerated, but the assignment has already overwritten the port udp4 successfully bound with `0`. `Open` then returns `actualPort == 0` even though the v4 socket is bound and serving traffic. Because the UAPI `get` handler only emits `listen_port` when it is non-zero, the line disappears entirely, so anything that reads the port back (wgctrl, `awg show`, a control plane reconciling expected vs. live config) sees `0`. ## Fix Give the udp6 listener its own `port` variable and adopt it only when v6 actually bound. A udp6 `EAFNOSUPPORT` no longer clobbers the live udp4 port. ## Note This code is inherited verbatim from upstream wireguard-go (`conn/bind_std.go`), so the same bug exists there. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-13 21:04:12 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amneziawg-go#166
No description provided.