Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 May 2014 12:30:28 +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: r266307 - head/sys/netpfil/pf
Message-ID:  <201405171230.s4HCUSti075153@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Sat May 17 12:30:27 2014
New Revision: 266307
URL: http://svnweb.freebsd.org/changeset/base/266307

Log:
  o In pf_normalize_ip() we don't need mtag in
    !(PFRULE_FRAGCROP|PFRULE_FRAGDROP) case.
  o In the (PFRULE_FRAGCROP|PFRULE_FRAGDROP) case we should allocate mtag
    if we don't find any.
  
  Tested by:	Ian FREISLICH <ianf cloudseed.co.za>

Modified:
  head/sys/netpfil/pf/pf_norm.c

Modified: head/sys/netpfil/pf/pf_norm.c
==============================================================================
--- head/sys/netpfil/pf/pf_norm.c	Sat May 17 11:43:14 2014	(r266306)
+++ head/sys/netpfil/pf/pf_norm.c	Sat May 17 12:30:27 2014	(r266307)
@@ -984,18 +984,6 @@ pf_normalize_ip(struct mbuf **m0, int di
 		if (m == NULL)
 			return (PF_DROP);
 
-		/* use mtag from concatenated mbuf chain */
-		pd->pf_mtag = pf_find_mtag(m);
-#ifdef DIAGNOSTIC
-		if (pd->pf_mtag == NULL) {
-			printf("%s: pf_find_mtag returned NULL(1)\n", __func__);
-			if ((pd->pf_mtag = pf_get_mtag(m)) == NULL) {
-				m_freem(m);
-				*m0 = NULL;
-				goto no_mem;
-			}
-		}
-#endif
 		if (frag != NULL && (frag->fr_flags & PFFRAG_DROP))
 			goto drop;
 
@@ -1004,7 +992,8 @@ pf_normalize_ip(struct mbuf **m0, int di
 		/* non-buffering fragment cache (drops or masks overlaps) */
 		int	nomem = 0;
 
-		if (dir == PF_OUT && pd->pf_mtag->flags & PF_TAG_FRAGCACHE) {
+		if (dir == PF_OUT && pd->pf_mtag &&
+		    pd->pf_mtag->flags & PF_TAG_FRAGCACHE) {
 			/*
 			 * Already passed the fragment cache in the
 			 * input direction.  If we continued, it would
@@ -1033,20 +1022,16 @@ pf_normalize_ip(struct mbuf **m0, int di
 			goto drop;
 		}
 
-		/* use mtag from copied and trimmed mbuf chain */
-		pd->pf_mtag = pf_find_mtag(m);
-#ifdef DIAGNOSTIC
-		if (pd->pf_mtag == NULL) {
-			printf("%s: pf_find_mtag returned NULL(2)\n", __func__);
-			if ((pd->pf_mtag = pf_get_mtag(m)) == NULL) {
+		if (dir == PF_IN) {
+			/* Use mtag from copied and trimmed mbuf chain. */
+			pd->pf_mtag = pf_get_mtag(m);
+			if (pd->pf_mtag == NULL) {
 				m_freem(m);
 				*m0 = NULL;
 				goto no_mem;
 			}
-		}
-#endif
-		if (dir == PF_IN)
 			pd->pf_mtag->flags |= PF_TAG_FRAGCACHE;
+		}
 
 		if (frag != NULL && (frag->fr_flags & PFFRAG_DROP))
 			goto drop;



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