Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/net Pull up following revision(s) (requested by tih i...
details: https://anonhg.NetBSD.org/src/rev/7ce1f1a4a830
branches: netbsd-8
changeset: 434753:7ce1f1a4a830
user: martin <martin%NetBSD.org@localhost>
date: Sat Mar 17 11:26:44 2018 +0000
description:
Pull up following revision(s) (requested by tih in ticket #638):
sys/net/if_tun.c: revision 1.143
Add packet filtering to tun(4) interfaces.
Calls to pfil_run_hooks() were missing in if_tun.c. This meant that
filtering configuration could be added to e.g. /etc/npf.conf, but
would be ignored, because the filter never saw the packets. This
change adds the required calls.
While here, correct the return value from tun_output(): it's been
returning 0 regardless of any error condition present, but will now
correctly propagate such information upward.
Thanks to maxv for guidance!
OK: christos, martin
diffstat:
sys/net/if_tun.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diffs (56 lines):
diff -r 329f6159a069 -r 7ce1f1a4a830 sys/net/if_tun.c
--- a/sys/net/if_tun.c Sat Mar 17 11:23:18 2018 +0000
+++ b/sys/net/if_tun.c Sat Mar 17 11:26:44 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_tun.c,v 1.139.2.2 2018/01/02 10:20:33 snj Exp $ */
+/* $NetBSD: if_tun.c,v 1.139.2.3 2018/03/17 11:26:44 martin Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo%cs.nott.ac.uk@localhost>
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.139.2.2 2018/01/02 10:20:33 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.139.2.3 2018/03/17 11:26:44 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -555,6 +555,11 @@
bpf_mtap_af(ifp, dst->sa_family, m0);
+ if ((error = pfil_run_hooks(ifp->if_pfil, &m0, ifp, PFIL_OUT)) != 0)
+ goto out;
+ if (m0 == NULL)
+ goto out;
+
switch(dst->sa_family) {
#ifdef INET6
case AF_INET6:
@@ -624,10 +629,10 @@
mutex_exit(&tp->tun_lock);
out:
- if (error && m0) {
+ if (error && m0)
m_freem(m0);
- }
- return 0;
+
+ return error;
}
static void
@@ -941,6 +946,11 @@
bpf_mtap_af(ifp, dst.sa_family, top);
+ if ((error = pfil_run_hooks(ifp->if_pfil, &top, ifp, PFIL_IN)) != 0)
+ goto out0;
+ if (top == NULL)
+ goto out0;
+
mutex_enter(&tp->tun_lock);
if ((tp->tun_flags & TUN_INITED) == 0) {
/* Interface was destroyed */
Home |
Main Index |
Thread Index |
Old Index