Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Use seltrue_filtops rather than rolling our own with...
details: https://anonhg.NetBSD.org/src/rev/67478996d513
branches: trunk
changeset: 1023803:67478996d513
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sun Sep 26 15:58:33 2021 +0000
description:
Use seltrue_filtops rather than rolling our own with filt_seltrue.
diffstat:
sys/net/if_tap.c | 28 +++++++++++-----------------
sys/net/if_tun.c | 19 +++++--------------
2 files changed, 16 insertions(+), 31 deletions(-)
diffs (123 lines):
diff -r 7f46d6460f40 -r 67478996d513 sys/net/if_tap.c
--- a/sys/net/if_tap.c Sun Sep 26 15:52:40 2021 +0000
+++ b/sys/net/if_tap.c Sun Sep 26 15:58:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tap.c,v 1.123 2021/09/26 01:16:10 thorpej Exp $ */
+/* $NetBSD: if_tap.c,v 1.124 2021/09/26 15:58:33 thorpej Exp $ */
/*
* Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.123 2021/09/26 01:16:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.124 2021/09/26 15:58:33 thorpej Exp $");
#if defined(_KERNEL_OPT)
@@ -1175,13 +1175,6 @@
.f_event = tap_kqread,
};
-static struct filterops tap_seltrue_filterops = {
- .f_flags = FILTEROP_ISFD,
- .f_attach = NULL,
- .f_detach = tap_kqdetach,
- .f_event = filt_seltrue,
-};
-
static int
tap_cdev_kqfilter(dev_t dev, struct knote *kn)
{
@@ -1204,24 +1197,25 @@
if (sc == NULL)
return ENXIO;
- KERNEL_LOCK(1, NULL);
switch(kn->kn_filter) {
case EVFILT_READ:
kn->kn_fop = &tap_read_filterops;
+ kn->kn_hook = sc;
+ KERNEL_LOCK(1, NULL);
+ mutex_spin_enter(&sc->sc_lock);
+ selrecord_knote(&sc->sc_rsel, kn);
+ mutex_spin_exit(&sc->sc_lock);
+ KERNEL_UNLOCK_ONE(NULL);
break;
+
case EVFILT_WRITE:
- kn->kn_fop = &tap_seltrue_filterops;
+ kn->kn_fop = &seltrue_filtops;
break;
+
default:
- KERNEL_UNLOCK_ONE(NULL);
return EINVAL;
}
- kn->kn_hook = sc;
- mutex_spin_enter(&sc->sc_lock);
- selrecord_knote(&sc->sc_rsel, kn);
- mutex_spin_exit(&sc->sc_lock);
- KERNEL_UNLOCK_ONE(NULL);
return 0;
}
diff -r 7f46d6460f40 -r 67478996d513 sys/net/if_tun.c
--- a/sys/net/if_tun.c Sun Sep 26 15:52:40 2021 +0000
+++ b/sys/net/if_tun.c Sun Sep 26 15:58:33 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tun.c,v 1.163 2021/09/26 01:16:10 thorpej Exp $ */
+/* $NetBSD: if_tun.c,v 1.164 2021/09/26 15:58:33 thorpej Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo%cs.nott.ac.uk@localhost>
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.163 2021/09/26 01:16:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.164 2021/09/26 15:58:33 thorpej Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1088,13 +1088,6 @@
.f_event = filt_tunread,
};
-static const struct filterops tun_seltrue_filtops = {
- .f_flags = FILTEROP_ISFD,
- .f_attach = NULL,
- .f_detach = filt_tunrdetach,
- .f_event = filt_seltrue,
-};
-
int
tunkqfilter(dev_t dev, struct knote *kn)
{
@@ -1108,10 +1101,12 @@
switch (kn->kn_filter) {
case EVFILT_READ:
kn->kn_fop = &tunread_filtops;
+ kn->kn_hook = tp;
+ selrecord_knote(&tp->tun_rsel, kn);
break;
case EVFILT_WRITE:
- kn->kn_fop = &tun_seltrue_filtops;
+ kn->kn_fop = &seltrue_filtops;
break;
default:
@@ -1119,10 +1114,6 @@
goto out;
}
- kn->kn_hook = tp;
-
- selrecord_knote(&tp->tun_rsel, kn);
-
out:
mutex_exit(&tp->tun_lock);
out_nolock:
Home |
Main Index |
Thread Index |
Old Index