From 42c39955505ea190778ba65078be50559edcc1d9 Mon Sep 17 00:00:00 2001 From: dlg Date: Sat, 20 Feb 2021 04:39:16 +0000 Subject: [PATCH] let tun use bpf_mtap for handling input packets. tun (not tap) input packets are written from userland in the same format that it's bpf dlt is expecting, so we can push the packet straight into bpf with bpf_mtap. this is more correct that using bpf_mtap_ether for tun. --- sys/net/if_tun.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 98572336439..bb5e27116bc 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.229 2021/01/19 19:39:58 mvs Exp $ */ +/* $OpenBSD: if_tun.c,v 1.230 2021/02/20 04:39:16 dlg Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -239,6 +239,9 @@ tun_create(struct if_clone *ifc, int unit, int flags) if_counters_alloc(ifp); if ((flags & TUN_LAYER2) == 0) { +#if NBPFILTER > 0 + ifp->if_bpf_mtap = bpf_mtap; +#endif ifp->if_input = tun_input; ifp->if_output = tun_output; ifp->if_mtu = ETHERMTU; -- 2.20.1