Module Name: src Committed By: tih Date: Fri Mar 16 17:00:35 UTC 2018
Modified Files: src/sys/net: if_vlan.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.124 -r1.125 src/sys/net/if_vlan.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/if_vlan.c diff -u src/sys/net/if_vlan.c:1.124 src/sys/net/if_vlan.c:1.125 --- src/sys/net/if_vlan.c:1.124 Mon Jan 15 16:36:51 2018 +++ src/sys/net/if_vlan.c Fri Mar 16 17:00:35 2018 @@ -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 @@ vlan_transmit(struct ifnet *ifp, struct 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 @@ vlan_input(struct ifnet *ifp, struct mbu 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);