Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 May 2013 18:06:51 +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: r250522 - head/sys/netpfil/pf
Message-ID:  <201305111806.r4BI6pqG001879@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Sat May 11 18:06:51 2013
New Revision: 250522
URL: http://svnweb.freebsd.org/changeset/base/250522

Log:
  Return meaningful error code from pf_state_key_attach() and
  pf_state_insert().

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

Modified: head/sys/netpfil/pf/pf.c
==============================================================================
--- head/sys/netpfil/pf/pf.c	Sat May 11 18:03:36 2013	(r250521)
+++ head/sys/netpfil/pf/pf.c	Sat May 11 18:06:51 2013	(r250522)
@@ -915,7 +915,7 @@ keyattach:
 					uma_zfree(V_pf_state_key_z, sk);
 					if (idx == PF_SK_STACK)
 						pf_detach_state(s);
-					return (-1);	/* collision! */
+					return (EEXIST); /* collision! */
 				}
 			}
 			PF_HASHROW_UNLOCK(ih);
@@ -1072,6 +1072,7 @@ pf_state_insert(struct pfi_kif *kif, str
 {
 	struct pf_idhash *ih;
 	struct pf_state *cur;
+	int error;
 
 	KASSERT(TAILQ_EMPTY(&sks->states[0]) && TAILQ_EMPTY(&sks->states[1]),
 	    ("%s: sks not pristine", __func__));
@@ -1090,8 +1091,8 @@ pf_state_insert(struct pfi_kif *kif, str
 		s->creatorid = V_pf_status.hostid;
 	}
 
-	if (pf_state_key_attach(skw, sks, s))
-		return (-1);
+	if ((error = pf_state_key_attach(skw, sks, s)) != 0)
+		return (error);
 
 	ih = &V_pf_idhash[PF_IDHASH(s)];
 	PF_HASHROW_LOCK(ih);
@@ -1108,7 +1109,7 @@ pf_state_insert(struct pfi_kif *kif, str
 			    ntohl(s->creatorid));
 		}
 		pf_detach_state(s);
-		return (-1);
+		return (EEXIST);
 	}
 	LIST_INSERT_HEAD(&ih->states, s, entry);
 	/* One for keys, one for ID hash. */



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