diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-07-12 09:33:14 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-07-12 09:33:14 +0000 |
commit | 97ce2ba5161b30a7ced894560b27f002b0535385 (patch) | |
tree | 244bb6aa6bc82309c6e90842d6f9d62dc1d4d15b /sys/net/if.c | |
parent | 4179da4d2baa7241ff4fc7cc39ba603c58a605a0 (diff) |
Directly drop packets filtered by bpf(4) instead of going through the
input handlers.
ok dlg@
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index c04975c0f80..a035c440cdd 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.434 2016/06/10 20:33:29 vgross Exp $ */ +/* $OpenBSD: if.c,v 1.435 2016/07/12 09:33:13 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -618,9 +618,18 @@ if_input(struct ifnet *ifp, struct mbuf_list *ml) #if NBPFILTER > 0 if_bpf = ifp->if_bpf; if (if_bpf) { - MBUF_LIST_FOREACH(ml, m) - if (bpf_mtap_ether(if_bpf, m, BPF_DIRECTION_IN) != 0) - m->m_flags |= M_FILDROP; + struct mbuf_list ml0; + + ml_init(&ml0); + ml_enlist(&ml0, ml); + ml_init(ml); + + while ((m = ml_dequeue(&ml0)) != NULL) { + if (bpf_mtap_ether(if_bpf, m, BPF_DIRECTION_IN)) + m_freem(m); + else + ml_enqueue(ml, m); + } } #endif |