Module Name: src Committed By: riastradh Date: Mon Jul 29 19:47:00 UTC 2024
Modified Files: src/sys/net: if_wg.c Log Message: wg(4): When a session is established, send first packet directly. Like we would do with the keepalive packet, if we had to send that instead -- no need to defer it to the pktq. Keep it simple. Post-fix tidying for: 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.127 -r1.128 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.
Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.127 src/sys/net/if_wg.c:1.128 --- src/sys/net/if_wg.c:1.127 Mon Jul 29 19:46:25 2024 +++ src/sys/net/if_wg.c Mon Jul 29 19:46:59 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.127 2024/07/29 19:46:25 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.128 2024/07/29 19:46:59 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki <ozaki.ry...@gmail.com> @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.127 2024/07/29 19:46:25 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.128 2024/07/29 19:46:59 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -2083,15 +2083,8 @@ wg_swap_sessions(struct wg_softc *wg, st */ if ((m = atomic_swap_ptr(&wgp->wgp_pending, NULL)) != NULL) { membar_acquire(); /* matches membar_release in wgintr */ - kpreempt_disable(); - const uint32_t h = curcpu()->ci_index; // pktq_rps_hash(m) - M_SETCTX(m, wgp); - if (__predict_false(!pktq_enqueue(wg_pktq, m, h))) { - WGLOG(LOG_ERR, "%s: pktq full, dropping\n", - if_name(&wg->wg_if)); - m_freem(m); - } - kpreempt_enable(); + wg_send_data_msg(wgp, wgs, m); /* consumes m */ + m = NULL; } else if (wgs->wgs_is_initiator) { wg_send_keepalive_msg(wgp, wgs); }