summaryrefslogtreecommitdiffstats
path: root/sys/net/bpf.c
diff options
context:
space:
mode:
authorcsjp <csjp@FreeBSD.org>2005-09-05 23:08:04 +0000
committercsjp <csjp@FreeBSD.org>2005-09-05 23:08:04 +0000
commit17dd22a407f2b37e2d1bbf9e6aad12e5765e1d4b (patch)
treeba396c5fa4107b445e987d9144b13c2dc4eabcd0 /sys/net/bpf.c
parentc6de1a745875dc3f71b0e969b4bc61caf81bdc77 (diff)
downloadFreeBSD-src-17dd22a407f2b37e2d1bbf9e6aad12e5765e1d4b.zip
FreeBSD-src-17dd22a407f2b37e2d1bbf9e6aad12e5765e1d4b.tar.gz
Instead of caching the PID which opened the bpf descriptor, continuously
refresh the PID which has the descriptor open. The PID is refreshed in various operations like ioctl(2), kevent(2) or poll(2). This produces more accurate information about current bpf consumers. While we are here remove the bd_pcomm member of the bpf stats structure because now that we have an accurate PID we can lookup the via the kern.proc.pid sysctl variable. This is the trick that NetBSD decided to use to deal with this issue. Special care needs to be taken when MFC'ing this change, as we have made a change to the bpf stats structure. What will end up happening is we will leave the pcomm structure but just mark it as being un-used. This way we keep the ABI in tact. MFC after: 1 month Discussed with: Rui Paulo < rpaulo at NetBSD dot org >
Diffstat (limited to 'sys/net/bpf.c')
-rw-r--r--sys/net/bpf.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 7747b3e..1ed528b 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -390,7 +390,6 @@ bpfopen(dev, flags, fmt, td)
d->bd_sig = SIGIO;
d->bd_seesent = 1;
d->bd_pid = td->td_proc->p_pid;
- strlcpy(d->bd_pcomm, td->td_proc->p_comm, MAXCOMLEN);
#ifdef MAC
mac_init_bpfdesc(d);
mac_create_bpfdesc(td->td_ucred, d);
@@ -694,6 +693,10 @@ bpfioctl(dev, cmd, addr, flags, td)
struct bpf_d *d = dev->si_drv1;
int error = 0;
+ /*
+ * Refresh PID associated with this descriptor.
+ */
+ d->bd_pid = td->td_proc->p_pid;
BPFD_LOCK(d);
if (d->bd_state == BPF_WAITING)
callout_stop(&d->bd_callout);
@@ -1141,6 +1144,10 @@ bpfpoll(dev, events, td)
if (d->bd_bif == NULL)
return (ENXIO);
+ /*
+ * Refresh PID associated with this descriptor.
+ */
+ d->bd_pid = td->td_proc->p_pid;
revents = events & (POLLOUT | POLLWRNORM);
BPFD_LOCK(d);
if (events & (POLLIN | POLLRDNORM)) {
@@ -1174,6 +1181,10 @@ bpfkqfilter(dev, kn)
if (kn->kn_filter != EVFILT_READ)
return (1);
+ /*
+ * Refresh PID associated with this descriptor.
+ */
+ d->bd_pid = curthread->td_proc->p_pid;
kn->kn_fop = &bpfread_filtops;
kn->kn_hook = d;
knlist_add(&d->bd_sel.si_note, kn, 0);
@@ -1724,7 +1735,6 @@ bpfstats_fill_xbpf(struct xbpf_d *d, struct bpf_d *bd)
d->bd_pid = bd->bd_pid;
strlcpy(d->bd_ifname,
bd->bd_bif->bif_ifp->if_xname, IFNAMSIZ);
- strlcpy(d->bd_pcomm, bd->bd_pcomm, MAXCOMLEN);
d->bd_locked = bd->bd_locked;
}
OpenPOWER on IntegriCloud