-/* $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 $ */
/*
#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>
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);
void
bpf_get(struct bpf_d *bd)
{
- atomic_inc_int(&bd->bd_ref);
+ refcnt_take(&bd->bd_refcnt);
}
/*
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);
-/* $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 $ */
/*
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 */