summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/net/bpf.c9
-rw-r--r--sys/net/bpfdesc.h4
2 files changed, 7 insertions, 6 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index ca6dc2e6744..f882923b376 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.215 2022/02/15 08:43:50 visa Exp $ */
+/* $OpenBSD: bpf.c,v 1.216 2022/03/17 14:22:03 visa Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -55,6 +55,7 @@
#include <sys/sysctl.h>
#include <sys/rwlock.h>
#include <sys/atomic.h>
+#include <sys/refcnt.h>
#include <sys/smr.h>
#include <sys/specdev.h>
#include <sys/selinfo.h>
@@ -398,7 +399,7 @@ bpfopen(dev_t dev, int flag, int mode, struct proc *p)
bd->bd_rtout = 0; /* no timeout by default */
- bpf_get(bd);
+ refcnt_init(&bd->bd_refcnt);
LIST_INSERT_HEAD(&bpf_d_list, bd, bd_list);
return (0);
@@ -1645,7 +1646,7 @@ bpf_d_smr(void *smr)
void
bpf_get(struct bpf_d *bd)
{
- atomic_inc_int(&bd->bd_ref);
+ refcnt_take(&bd->bd_refcnt);
}
/*
@@ -1655,7 +1656,7 @@ bpf_get(struct bpf_d *bd)
void
bpf_put(struct bpf_d *bd)
{
- if (atomic_dec_int_nv(&bd->bd_ref) > 0)
+ if (refcnt_rele(&bd->bd_refcnt) == 0)
return;
smr_call(&bd->bd_smr, bpf_d_smr, bd);
diff --git a/sys/net/bpfdesc.h b/sys/net/bpfdesc.h
index f7508998487..8e03b3e3c01 100644
--- a/sys/net/bpfdesc.h
+++ b/sys/net/bpfdesc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpfdesc.h,v 1.45 2021/01/21 12:33:14 dlg Exp $ */
+/* $OpenBSD: bpfdesc.h,v 1.46 2022/03/17 14:22:03 visa Exp $ */
/* $NetBSD: bpfdesc.h,v 1.11 1995/09/27 18:30:42 thorpej Exp $ */
/*
@@ -98,7 +98,7 @@ struct bpf_d {
int bd_sig; /* signal to send upon packet reception */
struct sigio_ref
bd_sigio; /* async I/O registration */
- u_int bd_ref; /* reference count */
+ struct refcnt bd_refcnt; /* reference count */
struct selinfo bd_sel; /* bsd select info */
int bd_unit; /* logical unit number */
LIST_ENTRY(bpf_d) bd_list; /* descriptor list */