Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Fix the handling of the state returned from pfil_run...
details: https://anonhg.NetBSD.org/src/rev/4bd967f731f7
branches: trunk
changeset: 360557:4bd967f731f7
user: tih <tih%NetBSD.org@localhost>
date: Fri Mar 16 17:00:35 2018 +0000
description:
Fix the handling of the state returned from pfil_run_hooks().
pfil_run_hooks() invokes any registered packet filters on the packet
being handled. It may return a (non-zero) errno, indicating that a
filter has decided that the packet should be discarded, and has freed
the mbuf. While a non-error (0) return usually means that the packet
should be processed normally, a filter may still free the mbuf if the
packet is a fragment, and the filter is holding it for reassembly and
future evaluation. Therefore, there must be separate tests for the
return value and for a possible discarded packet. (See pfil(9).)
OK: christos, martin
diffstat:
sys/net/if_vlan.c | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diffs (49 lines):
diff -r 38945ad08410 -r 4bd967f731f7 sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Fri Mar 16 12:48:54 2018 +0000
+++ b/sys/net/if_vlan.c Fri Mar 16 17:00:35 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vlan.c,v 1.124 2018/01/15 16:36:51 maxv Exp $ */
+/* $NetBSD: if_vlan.c,v 1.125 2018/03/16 17:00:35 tih Exp $ */
/*
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.124 2018/01/15 16:36:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.125 2018/03/16 17:00:35 tih Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1432,12 +1432,10 @@
bpf_mtap(ifp, m);
- if (pfil_run_hooks(ifp->if_pfil, &m, ifp, PFIL_OUT) != 0) {
- if (m != NULL)
- m_freem(m);
- error = 0;
+ if ((error = pfil_run_hooks(ifp->if_pfil, &m, ifp, PFIL_OUT)) != 0)
goto out;
- }
+ if (m == NULL)
+ goto out;
/*
* If the parent can insert the tag itself, just mark
@@ -1609,11 +1607,10 @@
m_set_rcvif(m, &ifv->ifv_if);
ifv->ifv_if.if_ipackets++;
- if (pfil_run_hooks(ifp->if_pfil, &m, ifp, PFIL_IN) != 0) {
- if (m != NULL)
- m_freem(m);
+ if (pfil_run_hooks(ifp->if_pfil, &m, ifp, PFIL_IN) != 0)
goto out;
- }
+ if (m == NULL)
+ goto out;
m->m_flags &= ~M_PROMISC;
if_input(&ifv->ifv_if, m);
Home |
Main Index |
Thread Index |
Old Index