Module Name: src Committed By: riastradh Date: Mon Jul 29 02:33:27 UTC 2024
Modified Files: src/sys/net: if_wg.c Log Message: wg(4): Queue pending packet in FIFO order, not LIFO order. Sometimes the session takes a seconds to establish, for whatever reason. It is better if the pending packet, which we queue up to send as soon as we get the responder's handshake response, is the most recent packet, rather than the first packet. That way, we don't wind up with a weird multi-second-delayed ping, followed by a bunch of dropped, followed by normal ping timings, or wind up sending the first TCP SYN instead of the most recent, or what have you. Senders need to be prepared to retransmit anyway if packets are dropped. PR kern/58508: experimental wg(4) queues LIFO, not FIFO, pending first handshake To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 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.114 src/sys/net/if_wg.c:1.115 --- src/sys/net/if_wg.c:1.114 Mon Jul 29 02:29:11 2024 +++ src/sys/net/if_wg.c Mon Jul 29 02:33:27 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.114 2024/07/29 02:29:11 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.115 2024/07/29 02:33:27 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.114 2024/07/29 02:29:11 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.115 2024/07/29 02:33:27 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -4213,8 +4213,7 @@ wg_output(struct ifnet *ifp, struct mbuf * attempt continue. We could queue more data packets * but it's not clear that's worthwhile. */ - if (atomic_cas_ptr(&wgp->wgp_pending, NULL, m) == NULL) { - m = NULL; /* consume */ + if ((m = atomic_swap_ptr(&wgp->wgp_pending, m)) == NULL) { WG_TRACE("queued first packet; init handshake"); wg_schedule_peer_task(wgp, WGP_TASK_SEND_INIT_MESSAGE); } else {