svn commit: r188590 - head/sys/netinet

Randall Stewart rrs at FreeBSD.org
Fri Feb 13 10:44:31 PST 2009


Author: rrs
Date: Fri Feb 13 18:44:30 2009
New Revision: 188590
URL: http://svn.freebsd.org/changeset/base/188590

Log:
  Have the jail code use the error returned to pass not constant
  errors.
  Obtained from:	jamie at freebsd.org

Modified:
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_pcb.c
==============================================================================
--- head/sys/netinet/sctp_pcb.c	Fri Feb 13 18:31:35 2009	(r188589)
+++ head/sys/netinet/sctp_pcb.c	Fri Feb 13 18:44:30 2009	(r188590)
@@ -2649,9 +2649,9 @@ sctp_inpcb_bind(struct socket *so, struc
 				 * will transmute the ip address to the
 				 * proper value.
 				 */
-				if (p && prison_local_ip4(p->td_ucred, &sin->sin_addr) != 0) {
-					SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
-					return (EINVAL);
+				if (p && (error = prison_local_ip4(p->td_ucred, &sin->sin_addr)) != 0) {
+					SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
+					return (error);
 				}
 				if (sin->sin_addr.s_addr != INADDR_ANY) {
 					bindall = 0;
@@ -2680,10 +2680,10 @@ sctp_inpcb_bind(struct socket *so, struc
 				 * will transmute the ipv6 address to the
 				 * proper value.
 				 */
-				if (p && prison_local_ip6(p->td_ucred, &sin6->sin6_addr,
-				    (SCTP_IPV6_V6ONLY(inp) != 0)) != 0) {
-					SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
-					return (EINVAL);
+				if (p && (error = prison_local_ip6(p->td_ucred, &sin6->sin6_addr,
+				    (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) {
+					SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, error);
+					return (error);
 				}
 				if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
 					bindall = 0;

Modified: head/sys/netinet/sctp_usrreq.c
==============================================================================
--- head/sys/netinet/sctp_usrreq.c	Fri Feb 13 18:31:35 2009	(r188589)
+++ head/sys/netinet/sctp_usrreq.c	Fri Feb 13 18:44:30 2009	(r188590)
@@ -4088,9 +4088,8 @@ sctp_setopt(struct socket *so, int optna
 					error = EINVAL;
 					break;
 				}
-				if (td != NULL && prison_local_ip4(td->td_ucred, &(((struct sockaddr_in *)(addrs->addr))->sin_addr))) {
-					SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, EADDRNOTAVAIL);
-					error = EADDRNOTAVAIL;
+				if (td != NULL && (error = prison_local_ip4(td->td_ucred, &(((struct sockaddr_in *)(addrs->addr))->sin_addr)))) {
+					SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, error);
 					break;
 				}
 #ifdef INET6
@@ -4101,10 +4100,9 @@ sctp_setopt(struct socket *so, int optna
 					error = EINVAL;
 					break;
 				}
-				if (td != NULL && prison_local_ip6(td->td_ucred, &(((struct sockaddr_in6 *)(addrs->addr))->sin6_addr),
-				    (SCTP_IPV6_V6ONLY(inp) != 0)) != 0) {
-					SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, EADDRNOTAVAIL);
-					error = EADDRNOTAVAIL;
+				if (td != NULL && (error = prison_local_ip6(td->td_ucred, &(((struct sockaddr_in6 *)(addrs->addr))->sin6_addr),
+				    (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) {
+					SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, error);
 					break;
 				}
 #endif
@@ -4133,9 +4131,8 @@ sctp_setopt(struct socket *so, int optna
 					error = EINVAL;
 					break;
 				}
-				if (td != NULL && prison_local_ip4(td->td_ucred, &(((struct sockaddr_in *)(addrs->addr))->sin_addr))) {
-					SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, EADDRNOTAVAIL);
-					error = EADDRNOTAVAIL;
+				if (td != NULL && (error = prison_local_ip4(td->td_ucred, &(((struct sockaddr_in *)(addrs->addr))->sin_addr)))) {
+					SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, error);
 					break;
 				}
 #ifdef INET6
@@ -4146,10 +4143,9 @@ sctp_setopt(struct socket *so, int optna
 					error = EINVAL;
 					break;
 				}
-				if (td != NULL && prison_local_ip6(td->td_ucred, &(((struct sockaddr_in6 *)(addrs->addr))->sin6_addr),
-				    (SCTP_IPV6_V6ONLY(inp) != 0)) != 0) {
-					SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, EADDRNOTAVAIL);
-					error = EADDRNOTAVAIL;
+				if (td != NULL && (error = prison_local_ip6(td->td_ucred, &(((struct sockaddr_in6 *)(addrs->addr))->sin6_addr),
+				    (SCTP_IPV6_V6ONLY(inp) != 0))) != 0) {
+					SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_USRREQ, error);
 					break;
 				}
 #endif
@@ -4256,9 +4252,9 @@ sctp_connect(struct socket *so, struct s
 			return (EINVAL);
 		}
 		sin6p = (struct sockaddr_in6 *)addr;
-		if (p != NULL && prison_remote_ip6(p->td_ucred, &sin6p->sin6_addr) != 0) {
-			SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
-			return (EINVAL);
+		if (p != NULL && (error = prison_remote_ip6(p->td_ucred, &sin6p->sin6_addr)) != 0) {
+			SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
+			return (error);
 		}
 	} else
 #endif
@@ -4270,9 +4266,9 @@ sctp_connect(struct socket *so, struct s
 			return (EINVAL);
 		}
 		sinp = (struct sockaddr_in *)addr;
-		if (p != NULL && prison_remote_ip4(p->td_ucred, &sinp->sin_addr) != 0) {
-			SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
-			return (EINVAL);
+		if (p != NULL && (error = prison_remote_ip4(p->td_ucred, &sinp->sin_addr)) != 0) {
+			SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, error);
+			return (error);
 		}
 	} else {
 		SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EAFNOSUPPORT);


More information about the svn-src-head mailing list