Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jul 2012 20:59:31 +0000 (UTC)
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r238122 - head/sys/netinet
Message-ID:  <201207042059.q64KxV4j032420@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Wed Jul  4 20:59:30 2012
New Revision: 238122
URL: http://svn.freebsd.org/changeset/base/238122

Log:
  Use consistent method to determine IPV4_OUTPUT/IPV6_OUTPUT.
  
  MFC after: 3 days

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==============================================================================
--- head/sys/netinet/sctp_output.c	Wed Jul  4 20:29:16 2012	(r238121)
+++ head/sys/netinet/sctp_output.c	Wed Jul  4 20:59:30 2012	(r238122)
@@ -10971,8 +10971,9 @@ sctp_send_resp_msg(struct sockaddr *src,
 		return;
 	}
 	SCTP_ATTACH_CHAIN(o_pak, mout, len);
+	switch (dst->sa_family) {
 #ifdef INET
-	if (ip != NULL) {
+	case AF_INET:
 		if (port) {
 			if (V_udp_cksum) {
 				udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP));
@@ -11006,10 +11007,10 @@ sctp_send_resp_msg(struct sockaddr *src,
 		}
 #endif
 		SCTP_IP_OUTPUT(ret, o_pak, NULL, NULL, vrf_id);
-	}
+		break;
 #endif
 #ifdef INET6
-	if (ip6 != NULL) {
+	case AF_INET6:
 		ip6->ip6_plen = len - sizeof(struct ip6_hdr);
 		if (port) {
 #if defined(SCTP_WITH_NO_CSUM)
@@ -11036,8 +11037,15 @@ sctp_send_resp_msg(struct sockaddr *src,
 		}
 #endif
 		SCTP_IP6_OUTPUT(ret, o_pak, NULL, NULL, NULL, vrf_id);
-	}
+		break;
 #endif
+	default:
+		SCTPDBG(SCTP_DEBUG_OUTPUT1, "Unknown protocol (TSNH) type %d\n",
+		    dst->sa_family);
+		sctp_m_freem(mout);
+		SCTP_LTRACE_ERR_RET_PKT(mout, NULL, NULL, NULL, SCTP_FROM_SCTP_OUTPUT, EFAULT);
+		return;
+	}
 	SCTP_STAT_INCR(sctps_sendpackets);
 	SCTP_STAT_INCR_COUNTER64(sctps_outpackets);
 	SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks);



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