Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Mar 2019 17:08:05 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344979 - head/sys/net
Message-ID:  <201903101708.x2AH85Eo028754@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Sun Mar 10 17:08:05 2019
New Revision: 344979
URL: https://svnweb.freebsd.org/changeset/base/344979

Log:
  Properly handle a case when a first filter returns PFIL_REALLOCED, then
  second one returns PFIL_PASS.

Modified:
  head/sys/net/pfil.c

Modified: head/sys/net/pfil.c
==============================================================================
--- head/sys/net/pfil.c	Sun Mar 10 16:14:42 2019	(r344978)
+++ head/sys/net/pfil.c	Sun Mar 10 17:08:05 2019	(r344979)
@@ -154,7 +154,8 @@ pfil_run_hooks(struct pfil_head *head, pfil_packet_t p
 	struct epoch_tracker et;
 	pfil_chain_t *pch;
 	struct pfil_link *link;
-	pfil_return_t rv, rvi;
+	pfil_return_t rv;
+	bool realloc = false;
 
 	if (PFIL_DIR(flags) == PFIL_IN)
 		pch = &head->head_in;
@@ -167,21 +168,22 @@ pfil_run_hooks(struct pfil_head *head, pfil_packet_t p
 	PFIL_EPOCH_ENTER(et);
 	CK_STAILQ_FOREACH(link, pch, link_chain) {
 		if ((flags & PFIL_MEMPTR) && !(link->link_flags & PFIL_MEMPTR))
-			rvi = pfil_fake_mbuf(link->link_func, p.mem, ifp,
+			rv = pfil_fake_mbuf(link->link_func, p.mem, ifp,
 			    flags, link->link_ruleset, inp);
 		else
-			rvi = (*link->link_func)(p, ifp, flags,
+			rv = (*link->link_func)(p, ifp, flags,
 			    link->link_ruleset, inp);
-		if (rvi == PFIL_DROPPED || rvi == PFIL_CONSUMED) {
-			rv = rvi;
+		if (rv == PFIL_DROPPED || rv == PFIL_CONSUMED)
 			break;
-		} else if (rv == PFIL_REALLOCED) {
+		else if (rv == PFIL_REALLOCED) {
 			flags &= ~(PFIL_MEMPTR | PFIL_LENMASK);
-			rv = rvi;
+			realloc = true;
 		}
 	}
 	PFIL_EPOCH_EXIT(et);
-	return (rvi);
+	if (realloc && rv == PFIL_PASS)
+		rv = PFIL_REALLOCED;
+	return (rv);
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903101708.x2AH85Eo028754>