And then rebuild and install a new kernel:
KK=`sysctl -n kern.osversion | cut -d# -f1`
cd /usr/src/sys/arch/`machine`/compile/$KK
make obj
make config
make
make install
return (error);
}
@@ -554,7 +560,9 @@ bpf_wakeup(struct bpf_d *d)
* by the KERNEL_LOCK() we have to delay the wakeup to
* another context to keep the hot path KERNEL_LOCK()-free.
*/
- task_add(systq, &d->bd_wake_task);
+ bpf_get(d);
+ if (!task_add(systq, &d->bd_wake_task))
+ bpf_put(d);
}
int
@@ -1577,6 +1593,25 @@ bpf_d_smr(void *smr)
bpf_prog_smr(bd->bd_wfilter);
free(bd, M_DEVBUF, sizeof(*bd));
+}
+
+void
+bpf_get(struct bpf_d *bd)
+{
+ atomic_inc_int(&bd->bd_ref);
+}
+
+/*
+ * Free buffers currently in use by a descriptor
+ * when the reference count drops to zero.
+ */
+void
+bpf_put(struct bpf_d *bd)
+{
+ if (atomic_dec_int_nv(&bd->bd_ref) > 0)
+ return;
+
+ smr_call(&bd->bd_smr, bpf_d_smr, bd);
}
void *
Index: sys/net/bpfdesc.h
===================================================================
RCS file: /cvs/src/sys/net/bpfdesc.h,v
retrieving revision 1.38
diff -u -p -r1.38 bpfdesc.h
--- sys/net/bpfdesc.h 18 May 2019 12:59:32 -0000 1.38
+++ sys/net/bpfdesc.h 24 Oct 2019 18:58:05 -0000
@@ -93,6 +93,7 @@ struct bpf_d {
pid_t bd_pgid; /* process or group id for signal */
uid_t bd_siguid; /* uid for process that set pgid */
uid_t bd_sigeuid; /* euid for process that set pgid */
+ u_int bd_ref; /* reference count */
struct selinfo bd_sel; /* bsd select info */
int bd_unit; /* logical unit number */
LIST_ENTRY(bpf_d) bd_list; /* descriptor list */