mirror of
https://github.com/amnezia-vpn/amneziawg-linux-kernel-module.git
synced 2026-12-03 19:22:43 +07:00
[PR #271] BFD-like session-layer path-liveness probes #270
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amnezia-vpn/amneziawg-linux-kernel-module#270
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/amnezia-vpn/amneziawg-linux-kernel-module/pull/271
Author: @mvkvl
Created: 10/14/2026
Status: 🔄 Open
Base:
master← Head:pr2-bfd📝 Commits (6)
054f3d3fix: record handshake completion when sending handshake response65e41a5bfd: add probe marker format and peer stats fields811ae6bbfd: send reply and probe via staged packet pathf3418bfbfd: intercept probe and reply in receive pathfe6d455bfd: add WGPEER_A_SEND_PROBE netlink attribute and probe stats55423cccompat: use linux/unaligned.h on kernel 6.12+📊 Changes
9 files changed (+202 additions, -1 deletions)
View changed files
➕
src/bfd.h(+71 -0)📝
src/compat/compat.h(+2 -0)📝
src/netlink.c(+25 -1)📝
src/peer.c(+1 -0)📝
src/peer.h(+7 -0)📝
src/queueing.h(+5 -0)📝
src/receive.c(+27 -0)📝
src/send.c(+53 -0)📝
src/uapi/wireguard.h(+11 -0)📄 Description
Title
bfd: add session-layer path-liveness probes (marker intercept, reply, netlink stats)
Body
Summary
Adds an optional session-layer BFD-style probe mechanism for path-specific
link liveness. A 30-byte marker is embedded in the decrypted data payload;
the peer intercepts it, replies via the already-updated endpoint, and drops
the probe so it never reaches the TUN interface. RTT and last-success
timestamps are exposed via netlink dump for userspace supervision.
Motivation
Kernel WireGuard supervision relies on
last_handshake, Rx counters andoptional ICMP probes. All three have failure modes:
last_handshakefreezes for idle or userspace peers (see PR #1 for theresponder-side half of the fix).
a dead direct path.
A session-layer probe answers from the source endpoint of the decrypted
packet, making the check path-specific and relay-immune.
Design
bfd.h): fixed 30-byte big-endian prefix of thedecrypted data payload. First byte is
0x57('W'), so a valid IPv4/IPv6header (0x45/0x46/0x6x) can never match. Magic is
0x57534246("WSBF").receive.c): inwg_packet_consume_data_done,after the keepalive check and before data delivery, recognise the marker.
PROBE → reply and drop; REPLY → record RTT and success timestamp.
Non-marker packets continue unchanged.
send.c):wg_packet_send_bfd_reply()andwg_packet_send_bfd_probe()build the skb following the keepalive recipe(reserved head room,
is_keepalive=false,skb_reset_network_headerforECN) and stage it. Encryption, endpoint xmit and the rest of the data
path stay untouched. Without a valid keypair the staged packet triggers a
handshake like any other data.
netlink.c,uapi/wireguard.h):WGPEER_A_SEND_PROBE(flag) — SET_DEVICE raises a per-peer requestflag and schedules
bfd_workonhandshake_send_wq. No inline sendwhile holding
device_update_lock.WGPEER_A_BFD_LAST_RTT_NS,WGPEER_A_BFD_LAST_OK_TS,WGPEER_A_BFD_LOSS,WGPEER_A_BFD_SEQ— GET_DEVICE dump reportsper-peer statistics from lock-free atomics.
enum wgpeer_attribute, so existing wireguard-tools ABI values stayuntouched.
peer.h): lock-free atomics for last RTT, lastsuccess timestamp, unanswered-probe counter and last sequence number;
plus a netlink request flag and work item.
Includes handshake fix
This branch also contains the one-line handshake-timestamp fix from PR #1
(
wg_timers_handshake_completeinwg_packet_send_handshake_response),which is a prerequisite for meaningful supervision on responder-only
sessions.
Compatibility
normal data path unchanged.
WGPEER_A_SEND_PROBE.master(4569c4c) on Debian 13(kernel 6.12.x) and Ubuntu 22.04 (kernel 5.15).
Testing
detects death in ~3 s (probe interval 1 s x loss threshold 3).
(path-specificity confirmed).
does not collide with marker (first byte 0x57 vs 0x00).
(50-byte packets).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.