Module Name: src Committed By: riastradh Date: Sun Jul 28 14:48:47 UTC 2024
Modified Files: src/sys/net: if_wg.c Log Message: wg(4): Process all altq'd packets when deleting peer. Can't just drop them because we can only go through all packets on an interface at a time, for all peers -- so we'd either have to drop all peers' packets, or requeue the packets for other peers. Probably not worth the trouble, so let's just wait for all the packets currently queued up to go through first. This requires reordering teardown so that we wg_destroy_all_peers, and thus wg_purge_pending_packets, _before_ we wg_if_detach, because wg_if_detach -> if_detach destroys the lock that IFQ_DEQUEUE uses. PR kern/58477: experimental wg(4) ALTQ support is probably buggy To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 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.106 src/sys/net/if_wg.c:1.107 --- src/sys/net/if_wg.c:1.106 Sun Jul 28 14:48:13 2024 +++ src/sys/net/if_wg.c Sun Jul 28 14:48:47 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.106 2024/07/28 14:48:13 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.107 2024/07/28 14:48:47 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.106 2024/07/28 14:48:13 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.107 2024/07/28 14:48:47 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -3663,6 +3663,9 @@ wg_purge_pending_packets(struct wg_peer m = atomic_swap_ptr(&wgp->wgp_pending, NULL); m_freem(m); +#ifdef ALTQ + wg_start(&wgp->wgp_sc->wg_if); +#endif pktq_barrier(wg_pktq); } @@ -3978,8 +3981,9 @@ wg_clone_create(struct if_clone *ifc, in return 0; fail4: __unused + wg_destroy_all_peers(wg); wg_if_detach(wg); -fail3: wg_destroy_all_peers(wg); +fail3: #ifdef INET6 solock(wg->wg_so6); wg->wg_so6->so_rcv.sb_flags &= ~SB_UPCALL; @@ -4031,8 +4035,8 @@ wg_clone_destroy(struct ifnet *ifp) } #endif - wg_if_detach(wg); wg_destroy_all_peers(wg); + wg_if_detach(wg); #ifdef INET6 solock(wg->wg_so6); wg->wg_so6->so_rcv.sb_flags &= ~SB_UPCALL;