Skip to content

device: return an error instead of panicking when updating an existing peer - #499

Open
miguelcorderopamphile wants to merge 1 commit into
cloudflare:masterfrom
miguelcorderopamphile:fix/peer-update-error
Open

miguelcorderopamphile wants to merge 1 commit into
cloudflare:masterfrom
miguelcorderopamphile:fix/peer-update-error

Conversation

@miguelcorderopamphile

Copy link
Copy Markdown

Fixes #498.

What

update_peer panicked when the UAPI set=1 request included a peer that already exists. The panic runs inside the device event handler (UAPI listener + anonymous UDP socket), so the daemon kept running but stopped processing network traffic until restarted.

This PR returns a bool from update_peer (false when the peer already exists) and the UAPI returns EOPNOTSUPP to the caller, keeping the device alive and matching the guidance in the original panic message ("Remove and add again instead").

Verification

  • cargo test -p boringtun --lib: 10 passed.
  • Live test with the daemon release build:
    • Before: second set=1 for the same peer -> no response, get=1 times out, UDP path stops answering (200 -> 0 cookie replies under the same flood).
    • After: second set=1 -> errno=95 (EOPNOTSUPP), get=1 returns the peer list, UDP path keeps answering (200 cookie replies).

…g peer

A routine UAPI set request that includes a peer which already exists (for
example re-applying a configuration or changing an endpoint) hits a panic in
update_peer ("Modifying existing peers is not yet supported"). The panic
kills the thread that services the UAPI listener and the anonymous UDP
socket, so the daemon stops processing all network traffic until it is
restarted (verified live: the UDP path stops answering after the panic).

Return a bool from update_peer (false when the peer already exists) and have
the UAPI return EOPNOTSUPP to the caller, keeping the device alive and
matching the guidance in the original panic message ("Remove and add again
instead").

Verified live with the daemon release build: before, the second set request
panicked and the daemon stopped processing packets; after, the request
returns errno=95, get=1 keeps working, and the UDP path keeps processing.

Signed-off-by: Miguel Cordero Pamphile <miguelcorderopamphile@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

device: UAPI panics (and stops processing traffic) when updating an existing peer

1 participant