summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2004-09-12 09:35:51 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2004-09-12 09:35:51 +0000
commitbc5b690c37af1b5be2e0be9893cc0869c8668c19 (patch)
treed6b2d48283a659596d25aafe670b9a83764d2d55 /sys/net
parent02a688e0818c2d4a0b5a42469d08f98ea877c205 (diff)
Return the most common data link type instead of the first match for an
interface. Where the most common DLT is the one with the smallest id. This fixes tcpdump for atw(4) that attaches multiple bpf hooks. Tested: millert@, Sigfred Haversen, otto@, mcbride@, sturm@, krw@, Steve Shockley OK millert@ deraadt@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/bpf.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 82406c22ab6..d51e491f3ed 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.51 2004/06/22 04:58:27 canacar Exp $ */
+/* $OpenBSD: bpf.c,v 1.52 2004/09/12 09:35:50 claudio Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -945,7 +945,7 @@ bpf_setif(d, ifr)
struct bpf_d *d;
struct ifreq *ifr;
{
- struct bpf_if *bp;
+ struct bpf_if *bp, *candidate = NULL;
int s, error;
/*
@@ -959,6 +959,13 @@ bpf_setif(d, ifr)
continue;
/*
* We found the requested interface.
+ */
+ if (candidate == NULL || candidate->bif_dlt > bp->bif_dlt)
+ candidate = bp;
+ }
+
+ if (candidate != NULL) {
+ /*
* Allocate the packet buffers if we need to.
* If we're already attached to requested interface,
* just flush the buffer.
@@ -969,14 +976,14 @@ bpf_setif(d, ifr)
return (error);
}
s = splimp();
- if (bp != d->bd_bif) {
+ if (candidate != d->bd_bif) {
if (d->bd_bif)
/*
* Detach if attached to something else.
*/
bpf_detachd(d);
- bpf_attachd(d, bp);
+ bpf_attachd(d, candidate);
}
bpf_reset_d(d);
splx(s);