From 1a86186d1b4f39ddb4dad0169f6555a50d9eda42 Mon Sep 17 00:00:00 2001 From: visa Date: Tue, 15 Feb 2022 08:43:50 +0000 Subject: [PATCH] Use knote_modify_fn() and knote_process_fn() in bpf. OK dlg@ --- sys/net/bpf.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 369ed377f87..ca6dc2e6744 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.214 2022/02/13 23:11:10 bluhm Exp $ */ +/* $OpenBSD: bpf.c,v 1.215 2022/02/15 08:43:50 visa Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -1229,8 +1229,13 @@ filt_bpfrdetach(struct knote *kn) } int -filt_bpfread_common(struct knote *kn, struct bpf_d *d) +filt_bpfread(struct knote *kn, long hint) { + struct bpf_d *d = kn->kn_hook; + + if (hint == NOTE_SUBMIT) /* ignore activation from selwakeup */ + return (0); + MUTEX_ASSERT_LOCKED(&d->bd_mtx); kn->kn_data = d->bd_hlen; @@ -1240,17 +1245,6 @@ filt_bpfread_common(struct knote *kn, struct bpf_d *d) return (kn->kn_data > 0); } -int -filt_bpfread(struct knote *kn, long hint) -{ - struct bpf_d *d = kn->kn_hook; - - if (hint == NOTE_SUBMIT) /* ignore activation from selwakeup */ - return (0); - - return (filt_bpfread_common(kn, d)); -} - int filt_bpfreadmodify(struct kevent *kev, struct knote *kn) { @@ -1258,8 +1252,7 @@ filt_bpfreadmodify(struct kevent *kev, struct knote *kn) int active; mtx_enter(&d->bd_mtx); - knote_assign(kev, kn); - active = filt_bpfread_common(kn, d); + active = knote_modify_fn(kev, kn, filt_bpfread); mtx_leave(&d->bd_mtx); return (active); @@ -1272,12 +1265,7 @@ filt_bpfreadprocess(struct knote *kn, struct kevent *kev) int active; mtx_enter(&d->bd_mtx); - if (kev != NULL && (kn->kn_flags & EV_ONESHOT)) - active = 1; - else - active = filt_bpfread_common(kn, d); - if (active) - knote_submit(kn, kev); + active = knote_process_fn(kn, kev, filt_bpfread); mtx_leave(&d->bd_mtx); return (active); -- 2.20.1