summaryrefslogtreecommitdiffstats
path: root/sys/net/bpf.h
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2012-04-06 06:53:58 +0000
committermelifaro <melifaro@FreeBSD.org>2012-04-06 06:53:58 +0000
commit8b1d10268c8ffd28f6c4b0da1e3906b139fc94cf (patch)
treeead0d5369047c56ec667d8a937da41d4682a0ed6 /sys/net/bpf.h
parentb6974119420223f65336e5d64d2782bff6a82731 (diff)
downloadFreeBSD-src-8b1d10268c8ffd28f6c4b0da1e3906b139fc94cf.zip
FreeBSD-src-8b1d10268c8ffd28f6c4b0da1e3906b139fc94cf.tar.gz
- Improve BPF locking model.
Interface locks and descriptor locks are converted from mutex(9) to rwlock(9). This greately improves performance: in most common case we need to acquire 1 reader lock instead of 2 mutexes. - Remove filter(descriptor) (reader) lock in bpf_mtap[2] This was suggested by glebius@. We protect filter by requesting interface writer lock on filter change. - Cover struct bpf_if under BPF_INTERNAL define. This permits including bpf.h without including rwlock stuff. However, this is is temporary solution, struct bpf_if should be made opaque for any external caller. Found by: Dmitrij Tejblum <tejblum@yandex-team.ru> Sponsored by: Yandex LLC Reviewed by: glebius (previous version) Reviewed by: silence on -net@ Approved by: (mentor) MFC after: 3 weeks
Diffstat (limited to 'sys/net/bpf.h')
-rw-r--r--sys/net/bpf.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/net/bpf.h b/sys/net/bpf.h
index d4c369d..a347453 100644
--- a/sys/net/bpf.h
+++ b/sys/net/bpf.h
@@ -1092,14 +1092,19 @@ SYSCTL_DECL(_net_bpf);
/*
* Descriptor associated with each attached hardware interface.
+ * FIXME: this structure is exposed to external callers to speed up
+ * bpf_peers_present() call. However we cover all fields not needed by
+ * this function via BPF_INTERNAL define
*/
struct bpf_if {
LIST_ENTRY(bpf_if) bif_next; /* list of all interfaces */
LIST_HEAD(, bpf_d) bif_dlist; /* descriptor list */
+#ifdef BPF_INTERNAL
u_int bif_dlt; /* link layer type */
u_int bif_hdrlen; /* length of link header */
struct ifnet *bif_ifp; /* corresponding interface */
- struct mtx bif_mtx; /* mutex for interface */
+ struct rwlock bif_lock; /* interface lock */
+#endif
};
void bpf_bufheld(struct bpf_d *d);
OpenPOWER on IntegriCloud