Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Feb 2012 23:34:07 +0000 (UTC)
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r231476 - stable/8/sys/netinet
Message-ID:  <201202102334.q1ANY7dJ002134@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Fri Feb 10 23:34:07 2012
New Revision: 231476
URL: http://svn.freebsd.org/changeset/base/231476

Log:
  MFC r227320:
  When loading addresses from INITs, always use the correct
  local address.

Modified:
  stable/8/sys/netinet/sctp_pcb.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/boot/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/e1000/   (props changed)

Modified: stable/8/sys/netinet/sctp_pcb.c
==============================================================================
--- stable/8/sys/netinet/sctp_pcb.c	Fri Feb 10 23:32:04 2012	(r231475)
+++ stable/8/sys/netinet/sctp_pcb.c	Fri Feb 10 23:34:07 2012	(r231476)
@@ -6181,54 +6181,65 @@ sctp_load_addresses_from_init(struct sct
 	sin6.sin6_len = sizeof(struct sockaddr_in6);
 	sin6.sin6_port = stcb->rport;
 #endif
-	if (altsa == NULL) {
-		iph = mtod(m, struct ip *);
-		switch (iph->ip_v) {
+	iph = mtod(m, struct ip *);
+	switch (iph->ip_v) {
 #ifdef INET
-		case IPVERSION:
-			{
-				/* its IPv4 */
-				struct sockaddr_in *sin_2;
-
-				sin_2 = (struct sockaddr_in *)(local_sa);
-				memset(sin_2, 0, sizeof(sin));
-				sin_2->sin_family = AF_INET;
-				sin_2->sin_len = sizeof(sin);
-				sin_2->sin_port = sh->dest_port;
-				sin_2->sin_addr.s_addr = iph->ip_dst.s_addr;
+	case IPVERSION:
+		{
+			/* its IPv4 */
+			struct sockaddr_in *sin_2;
+
+			sin_2 = (struct sockaddr_in *)(local_sa);
+			memset(sin_2, 0, sizeof(sin));
+			sin_2->sin_family = AF_INET;
+			sin_2->sin_len = sizeof(sin);
+			sin_2->sin_port = sh->dest_port;
+			sin_2->sin_addr.s_addr = iph->ip_dst.s_addr;
+			if (altsa) {
+				/*
+				 * For cookies we use the src address NOT
+				 * from the packet but from the original
+				 * INIT.
+				 */
+				sa = altsa;
+			} else {
 				sin.sin_addr = iph->ip_src;
 				sa = (struct sockaddr *)&sin;
-				break;
 			}
+			break;
+		}
 #endif
 #ifdef INET6
-		case IPV6_VERSION >> 4:
-			{
-				/* its IPv6 */
-				struct ip6_hdr *ip6;
-				struct sockaddr_in6 *sin6_2;
-
-				ip6 = mtod(m, struct ip6_hdr *);
-				sin6_2 = (struct sockaddr_in6 *)(local_sa);
-				memset(sin6_2, 0, sizeof(sin6));
-				sin6_2->sin6_family = AF_INET6;
-				sin6_2->sin6_len = sizeof(struct sockaddr_in6);
-				sin6_2->sin6_port = sh->dest_port;
+	case IPV6_VERSION >> 4:
+		{
+			/* its IPv6 */
+			struct ip6_hdr *ip6;
+			struct sockaddr_in6 *sin6_2;
+
+			ip6 = mtod(m, struct ip6_hdr *);
+			sin6_2 = (struct sockaddr_in6 *)(local_sa);
+			memset(sin6_2, 0, sizeof(sin6));
+			sin6_2->sin6_family = AF_INET6;
+			sin6_2->sin6_len = sizeof(struct sockaddr_in6);
+			sin6_2->sin6_port = sh->dest_port;
+			sin6_2->sin6_addr = ip6->ip6_dst;
+			if (altsa) {
+				/*
+				 * For cookies we use the src address NOT
+				 * from the packet but from the original
+				 * INIT.
+				 */
+				sa = altsa;
+			} else {
 				sin6.sin6_addr = ip6->ip6_src;
 				sa = (struct sockaddr *)&sin6;
-				break;
 			}
-#endif
-		default:
-			return (-1);
 			break;
 		}
-	} else {
-		/*
-		 * For cookies we use the src address NOT from the packet
-		 * but from the original INIT
-		 */
-		sa = altsa;
+#endif
+	default:
+		return (-1);
+		break;
 	}
 	/* Turn off ECN until we get through all params */
 	ecn_allowed = 0;



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