Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

src: Pull up following revision(s) (requested by ryo in ticket #...



details:   https://anonhg.NetBSD.org/src/rev/35cdc9c9411f
branches:  netbsd-8
changeset: 318166:35cdc9c9411f
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Apr 14 10:38:59 2018 +0000
description:
Pull up following revision(s) (requested by ryo in ticket #752):

        sys/net/if_vlan.c: revision 1.125

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 cfab258fe0b4 -r 35cdc9c9411f sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Sat Apr 14 10:34:02 2018 +0000
+++ b/sys/net/if_vlan.c Sat Apr 14 10:38:59 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vlan.c,v 1.97.2.11 2018/01/02 10:20:33 snj Exp $    */
+/*     $NetBSD: if_vlan.c,v 1.97.2.12 2018/04/14 10:38:59 martin 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.97.2.11 2018/01/02 10:20:33 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.97.2.12 2018/04/14 10:38:59 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1419,12 +1419,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
@@ -1610,11 +1608,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