kernel/linux/src: let userspace clear a peer's session

When tailscaled learns that a peer restarted (its disco key changed), the
peer has lost its WireGuard keys, but the kernel would keep sending with
the dead session until WireGuard's own timers start a new handshake about
15 seconds later.

Add TSWGPEER_A_CLEAR_SESSION, an NLA_FLAG in the nested WGPEER_A_TSWG
attribute, which forgets the peer's keypairs and any handshake in
progress, as wg_pm_notification does for every peer before suspend, and
resets the handshake rate limit, so that the next packet to the peer is
staged and starts a new handshake right away.

Updates #426

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: Ia9821a47e6c8114bbabd81d8d5a2be528295e74f
This commit is contained in:
Brad Fitzpatrick committed 2026-11-07 05:00:03 +00:00
1 parent fe0c4864e9
commit c32ba694d1
3 files changed
+17

No files matched your search

+1
View File
@@ -27,6 +27,7 @@ const struct nla_policy wireguard_wgallowedip_nl_policy[WGALLOWEDIP_A_FLAGS + 1]
*/
const struct nla_policy tswg_peer_nl_policy[TSWGPEER_A_MAX + 1] = {
[TSWGPEER_A_FLAGS] = NLA_POLICY_MASK(NLA_U32, TSWGPEER_F_NO_ROAM),
[TSWGPEER_A_CLEAR_SESSION] = { .type = NLA_FLAG, },
};
const struct nla_policy wireguard_wgpeer_nl_policy[WGPEER_A_TSWG + 1] = { /* TSWG */