Module Name:    src
Committed By:   yamt
Date:           Sat Nov 19 08:53:06 UTC 2022

Modified Files:
        src/sys/net: bpf.c

Log Message:
bpf: refresh bd_pid in a few more places as well

This made "netstat -B" show hostapd and wpa_supplicant for me.

kingcrab# netstat -B
Active BPF peers
PID     Int     Recv     Drop     Capt     Flags  Bufsize  Comm
433     urtwn0  102      0        2        I-RSH  524288   hostapd
211     urtwn0  102      0        4        I-RS-  32768    dhcpd
670     bwfm0   295      0        2        I-RSH  524288   wpa_supplicant
kingcrab#


To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.248 src/sys/net/bpf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/bpf.c
diff -u src/sys/net/bpf.c:1.247 src/sys/net/bpf.c:1.248
--- src/sys/net/bpf.c:1.247	Sat Sep  3 10:03:20 2022
+++ src/sys/net/bpf.c	Sat Nov 19 08:53:06 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.247 2022/09/03 10:03:20 riastradh Exp $	*/
+/*	$NetBSD: bpf.c,v 1.248 2022/11/19 08:53:06 yamt Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.247 2022/09/03 10:03:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.248 2022/11/19 08:53:06 yamt Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -682,6 +682,11 @@ bpf_read(struct file *fp, off_t *offp, s
 	int timed_out;
 	int error;
 
+	/*
+	 * Refresh the PID associated with this bpf file.
+	 */
+	d->bd_pid = curproc->p_pid;
+
 	getnanotime(&d->bd_atime);
 	/*
 	 * Restrict application to use a buffer the same size as
@@ -817,6 +822,11 @@ bpf_write(struct file *fp, off_t *offp, 
 	struct psref psref;
 	int bound;
 
+	/*
+	 * Refresh the PID associated with this bpf file.
+	 */
+	d->bd_pid = curproc->p_pid;
+
 	m = NULL;	/* XXX gcc */
 
 	bound = curlwp_bind();
@@ -1569,6 +1579,11 @@ filt_bpfread(struct knote *kn, long hint
 	struct bpf_d *d = kn->kn_hook;
 	int rv;
 
+	/*
+	 * Refresh the PID associated with this bpf file.
+	 */
+	d->bd_pid = curproc->p_pid;
+
 	mutex_enter(d->bd_buf_mtx);
 	kn->kn_data = d->bd_hlen;
 	if (d->bd_immediate)

Reply via email to