Module Name: src Committed By: riastradh Date: Sun Jul 28 14:37:59 UTC 2024
Modified Files: src/sys/net: if_wg.c Log Message: wg(4): Rework some details of internal session state machine. This way: - There is a clear transition between when a session is being set up, and when it is exposed to the data rx path (wg_handle_msg_data): atomic_store_release to set wgs->wgs_state to INIT_PASSIVE or ESTABLISHED. (The transition INIT_PASSIVE -> ESTABLISHED is immaterial to the data rx path, so that's just atomic_store_relaxed. Similarly the transition to DESTROYING.) - There is a clear transition between when a session is being set up, and when it is exposed to the data tx path (wg_output): atomic_store_release to set wgp->wgp_session_stable to it. - Every path that reinitializes a session must go through wg_destroy_session via wg_put_index_session first. This avoids races between session reuse and the data rx/tx paths. - Add a log message at the time of every state transition. Prompted by: PR kern/55729: net/if_wg/t_misc:wg_rekey test case fails PR kern/56252: wg(4) state machine has race conditions PR kern/58463: if_wg does not work when idle. To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.