git: 7a72e88781ae - main - kqueue: handle copy for netmap filters

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 18 Oct 2025 05:14:17 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=7a72e88781ae294aae6b97e1972cb19b2a670412

commit 7a72e88781ae294aae6b97e1972cb19b2a670412
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-08-23 14:42:19 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-10-18 05:12:36 +0000

    kqueue: handle copy for netmap filters
    
    Reviewed by:    markj
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 weeks
    Differential revision:  https://reviews.freebsd.org/D52045
---
 sys/dev/netmap/netmap_freebsd.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c
index ac267a66d669..9fb4370129f3 100644
--- a/sys/dev/netmap/netmap_freebsd.c
+++ b/sys/dev/netmap/netmap_freebsd.c
@@ -1407,19 +1407,34 @@ netmap_knwrite(struct knote *kn, long hint)
 	return netmap_knrw(kn, hint, POLLOUT);
 }
 
+static int
+netmap_kncopy(struct knote *kn, struct proc *p1)
+{
+	struct netmap_priv_d *priv;
+	struct nm_selinfo *si;
+
+	priv = kn->kn_hook;
+	si = priv->np_si[kn->kn_filter == EVFILT_WRITE ? NR_TX : NR_RX];
+	NMG_LOCK();
+	si->kqueue_users++;
+	NMG_UNLOCK();
+	return (0);
+}
+
 static const struct filterops netmap_rfiltops = {
 	.f_isfd = 1,
 	.f_detach = netmap_knrdetach,
 	.f_event = netmap_knread,
+	.f_copy = netmap_kncopy,
 };
 
 static const struct filterops netmap_wfiltops = {
 	.f_isfd = 1,
 	.f_detach = netmap_knwdetach,
 	.f_event = netmap_knwrite,
+	.f_copy = netmap_kncopy,
 };
 
-
 /*
  * This is called when a thread invokes kevent() to record
  * a change in the configuration of the kqueue().