[PR #826] [MERGED] Share kernel Wireguard port with raw socket #13046

Closed
opened 2026-08-05 02:07:20 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/826
Author: @mlsmaycon
Created: 4/26/2023
Status: Merged
Merged: 5/3/2023
Merged by: @braginini

Base: mainHead: feature/use-raw-sock-with-bpf-filters


📝 Commits (10+)

  • 15c5af2 Use forked Wireguard-go for custom bind
  • ab7a48d Update GO version in CI/CD to 1.20
  • 40d7e58 Fix lint issues
  • d8eaedb Try to fix go version in github hooks
  • e839d2b fix test
  • 52788fe Follow up netbirdio/wireguard-go
  • 55d7826 Build test with CGO_ENABLED=0
  • 66ebed1 Support shared stun listener with kernel wireguard
  • 24b8ce6 update netlink
  • 0973b4f sync go.sum

📊 Changes

15 files changed (+663 additions, -563 deletions)

View changed files

📝 .github/workflows/golang-test-linux.yml (+8 -1)
📝 client/internal/engine.go (+13 -49)
📝 client/internal/peer/conn.go (+23 -137)
📝 client/internal/peer/conn_test.go (+0 -309)
client/internal/proxy/direct.go (+0 -57)
📝 go.mod (+4 -4)
📝 go.sum (+6 -5)
📝 iface/bind/udp_mux_universal.go (+39 -0)
📝 iface/wg_configurer_nonandroid.go (+1 -1)
sharedsock/filter.go (+11 -0)
sharedsock/filter_linux.go (+47 -0)
sharedsock/filter_nolinux.go (+8 -0)
sharedsock/sock_linux.go (+327 -0)
sharedsock/sock_linux_test.go (+162 -0)
sharedsock/sock_nolinux.go (+14 -0)

📄 Description

Describe your changes

This is initial changes to support shared port between stun (ICE agent) and
the kernel Wireguard

Implement single port mode for execution with kernel Wireguard interfaces using a raw socket listener.

BPF filters ensure that only stun packets hit the raw socket

Removed a lot of the proxy logic and direct mode exchange

now we are doing an extra hole punch to the remote wireguard port for best-effort cases and support to old client's direct mode.

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

🔄 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/netbirdio/netbird/pull/826 **Author:** [@mlsmaycon](https://github.com/mlsmaycon) **Created:** 4/26/2023 **Status:** ✅ Merged **Merged:** 5/3/2023 **Merged by:** [@braginini](https://github.com/braginini) **Base:** `main` ← **Head:** `feature/use-raw-sock-with-bpf-filters` --- ### 📝 Commits (10+) - [`15c5af2`](https://github.com/netbirdio/netbird/commit/15c5af2a919add844be70e2a6711b82bb635934a) Use forked Wireguard-go for custom bind - [`ab7a48d`](https://github.com/netbirdio/netbird/commit/ab7a48d3f8fcb929fb346e4cdb675205ec9a1f65) Update GO version in CI/CD to 1.20 - [`40d7e58`](https://github.com/netbirdio/netbird/commit/40d7e58503dd8eea6187cf17e46e3dc22af3b83f) Fix lint issues - [`d8eaedb`](https://github.com/netbirdio/netbird/commit/d8eaedb19e841c2cd7781aa7893fdf601fc18696) Try to fix go version in github hooks - [`e839d2b`](https://github.com/netbirdio/netbird/commit/e839d2b48d339a7f0ce1a8ec33a71a957b77ce6f) fix test - [`52788fe`](https://github.com/netbirdio/netbird/commit/52788fe6c5aa3d46a426ea3227972350c7f88118) Follow up netbirdio/wireguard-go - [`55d7826`](https://github.com/netbirdio/netbird/commit/55d782637d6d2e8bdee83699f54b5275778df7d8) Build test with CGO_ENABLED=0 - [`66ebed1`](https://github.com/netbirdio/netbird/commit/66ebed1051750a86a8db549ac3f003e046d612cb) Support shared stun listener with kernel wireguard - [`24b8ce6`](https://github.com/netbirdio/netbird/commit/24b8ce6e9651564b67d723260ab5ee34493de491) update netlink - [`0973b4f`](https://github.com/netbirdio/netbird/commit/0973b4ffc31e43d753310669d4b5117634f5918f) sync go.sum ### 📊 Changes **15 files changed** (+663 additions, -563 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/golang-test-linux.yml` (+8 -1) 📝 `client/internal/engine.go` (+13 -49) 📝 `client/internal/peer/conn.go` (+23 -137) 📝 `client/internal/peer/conn_test.go` (+0 -309) ➖ `client/internal/proxy/direct.go` (+0 -57) 📝 `go.mod` (+4 -4) 📝 `go.sum` (+6 -5) 📝 `iface/bind/udp_mux_universal.go` (+39 -0) 📝 `iface/wg_configurer_nonandroid.go` (+1 -1) ➕ `sharedsock/filter.go` (+11 -0) ➕ `sharedsock/filter_linux.go` (+47 -0) ➕ `sharedsock/filter_nolinux.go` (+8 -0) ➕ `sharedsock/sock_linux.go` (+327 -0) ➕ `sharedsock/sock_linux_test.go` (+162 -0) ➕ `sharedsock/sock_nolinux.go` (+14 -0) </details> ### 📄 Description ## Describe your changes This is initial changes to support shared port between stun (ICE agent) and the kernel Wireguard Implement single port mode for execution with kernel Wireguard interfaces using a raw socket listener. BPF filters ensure that only stun packets hit the raw socket Removed a lot of the proxy logic and direct mode exchange now we are doing an extra hole punch to the remote wireguard port for best-effort cases and support to old client's direct mode. ## Issue ticket number and link ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [x] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 02:07:20 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#13046