Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Apr 2012 11:10:25 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r234309 - projects/pf/head/sys/contrib/pf/net
Message-ID:  <201204151110.q3FBAPlI080109@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Sun Apr 15 11:10:24 2012
New Revision: 234309
URL: http://svn.freebsd.org/changeset/base/234309

Log:
  In pf_route(), pf_route6():
  - Convert panic to KASSERT.
  - Use __func__ instead of hardcoding function name.

Modified:
  projects/pf/head/sys/contrib/pf/net/pf.c

Modified: projects/pf/head/sys/contrib/pf/net/pf.c
==============================================================================
--- projects/pf/head/sys/contrib/pf/net/pf.c	Sun Apr 15 10:59:00 2012	(r234308)
+++ projects/pf/head/sys/contrib/pf/net/pf.c	Sun Apr 15 11:10:24 2012	(r234309)
@@ -5125,9 +5125,9 @@ pf_route(struct mbuf **m, struct pf_rule
 	struct m_tag		*mtag;
 #endif /* IPSEC */
 
-	if (m == NULL || *m == NULL || r == NULL ||
-	    (dir != PF_IN && dir != PF_OUT) || oifp == NULL)
-		panic("pf_route: invalid parameters");
+	KASSERT(m && *m && r && oifp, ("%s: invalid parameters", __func__));
+	KASSERT(dir == PF_IN || dir == PF_OUT, ("%s: invalid direction",
+	    __func__));
 
 	if (pd->pf_mtag->routed++ > 3) {
 		m0 = *m;
@@ -5146,7 +5146,7 @@ pf_route(struct mbuf **m, struct pf_rule
 
 	if (m0->m_len < sizeof(struct ip)) {
 		DPFPRINTF(PF_DEBUG_URGENT,
-		    ("pf_route: m0->m_len < sizeof(struct ip)\n"));
+		    ("%s: m0->m_len < sizeof(struct ip)\n", __func__));
 		goto bad;
 	}
 
@@ -5174,7 +5174,7 @@ pf_route(struct mbuf **m, struct pf_rule
 	} else {
 		if (TAILQ_EMPTY(&r->rpool.list)) {
 			DPFPRINTF(PF_DEBUG_URGENT,
-			    ("pf_route: TAILQ_EMPTY(&r->rpool.list)\n"));
+			    ("%s: TAILQ_EMPTY(&r->rpool.list)\n", __func__));
 			goto bad;
 		}
 		if (s == NULL) {
@@ -5206,7 +5206,7 @@ pf_route(struct mbuf **m, struct pf_rule
 		PF_LOCK();
 		if (m0->m_len < sizeof(struct ip)) {
 			DPFPRINTF(PF_DEBUG_URGENT,
-			    ("pf_route: m0->m_len < sizeof(struct ip)\n"));
+			    ("%s: m0->m_len < sizeof(struct ip)\n", __func__));
 			goto bad;
 		}
 		ip = mtod(m0, struct ip *);
@@ -5322,9 +5322,9 @@ pf_route6(struct mbuf **m, struct pf_rul
 	struct pf_addr		 naddr;
 	struct pf_src_node	*sn = NULL;
 
-	if (m == NULL || *m == NULL || r == NULL ||
-	    (dir != PF_IN && dir != PF_OUT) || oifp == NULL)
-		panic("pf_route6: invalid parameters");
+	KASSERT(m && *m && r && oifp, ("%s: invalid parameters", __func__));
+	KASSERT(dir == PF_IN || dir == PF_OUT, ("%s: invalid direction",
+	    __func__));
 
 	if (pd->pf_mtag->routed++ > 3) {
 		m0 = *m;
@@ -5343,7 +5343,7 @@ pf_route6(struct mbuf **m, struct pf_rul
 
 	if (m0->m_len < sizeof(struct ip6_hdr)) {
 		DPFPRINTF(PF_DEBUG_URGENT,
-		    ("pf_route6: m0->m_len < sizeof(struct ip6_hdr)\n"));
+		    ("%s: m0->m_len < sizeof(struct ip6_hdr)\n", __func__));
 		goto bad;
 	}
 	ip6 = mtod(m0, struct ip6_hdr *);
@@ -5365,7 +5365,7 @@ pf_route6(struct mbuf **m, struct pf_rul
 
 	if (TAILQ_EMPTY(&r->rpool.list)) {
 		DPFPRINTF(PF_DEBUG_URGENT,
-		    ("pf_route6: TAILQ_EMPTY(&r->rpool.list)\n"));
+		    ("%s: TAILQ_EMPTY(&r->rpool.list)\n", __func__));
 		goto bad;
 	}
 	if (s == NULL) {
@@ -5396,7 +5396,8 @@ pf_route6(struct mbuf **m, struct pf_rul
 		PF_LOCK();
 		if (m0->m_len < sizeof(struct ip6_hdr)) {
 			DPFPRINTF(PF_DEBUG_URGENT,
-			    ("pf_route6: m0->m_len < sizeof(struct ip6_hdr)\n"));
+			    ("%s: m0->m_len < sizeof(struct ip6_hdr)\n",
+			    __func__));
 			goto bad;
 		}
 		ip6 = mtod(m0, struct ip6_hdr *);



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