Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 May 2012 09:51:44 +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-9@freebsd.org
Subject:   svn commit: r235431 - stable/9/sys/netinet
Message-ID:  <201205140951.q4E9piUf025531@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Mon May 14 09:51:43 2012
New Revision: 235431
URL: http://svn.freebsd.org/changeset/base/235431

Log:
  MFC r235282:
  Only provide the supported features in the SCTP_ASSOC_CHANGE notif
  if the state is SCTP_COMM_UP or SCTP_RESTART.
  While there, do some cleanups.

Modified:
  stable/9/sys/netinet/sctputil.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/netinet/sctputil.c
==============================================================================
--- stable/9/sys/netinet/sctputil.c	Mon May 14 09:48:39 2012	(r235430)
+++ stable/9/sys/netinet/sctputil.c	Mon May 14 09:51:43 2012	(r235431)
@@ -2592,8 +2592,8 @@ sctp_pad_lastmbuf(struct mbuf *m, int pa
 }
 
 static void
-sctp_notify_assoc_change(uint32_t event, struct sctp_tcb *stcb,
-    uint32_t error, int so_locked
+sctp_notify_assoc_change(uint16_t state, struct sctp_tcb *stcb,
+    uint16_t error, int so_locked
 #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
     SCTP_UNUSED
 #endif
@@ -2602,6 +2602,7 @@ sctp_notify_assoc_change(uint32_t event,
 	struct mbuf *m_notify;
 	struct sctp_assoc_change *sac;
 	struct sctp_queued_to_read *control;
+	size_t len;
 	unsigned int i;
 
 #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
@@ -2615,7 +2616,7 @@ sctp_notify_assoc_change(uint32_t event,
 	 */
 	if (((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
 	    (stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) &&
-	    ((event == SCTP_COMM_LOST) || (event == SCTP_CANT_STR_ASSOC))) {
+	    ((state == SCTP_COMM_LOST) || (state == SCTP_CANT_STR_ASSOC))) {
 		if (SCTP_GET_STATE(&stcb->asoc) == SCTP_STATE_COOKIE_WAIT) {
 			SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, ECONNREFUSED);
 			stcb->sctp_socket->so_error = ECONNREFUSED;
@@ -2651,7 +2652,11 @@ sctp_notify_assoc_change(uint32_t event,
 		/* event not enabled */
 		return;
 	}
-	m_notify = sctp_get_mbuf_for_msg(sizeof(struct sctp_assoc_change), 0, M_DONTWAIT, 1, MT_DATA);
+	len = sizeof(struct sctp_assoc_change);
+	if ((state == SCTP_COMM_UP) || (state == SCTP_RESTART)) {
+		len += SCTP_ASSOC_SUPPORTS_MAX;
+	}
+	m_notify = sctp_get_mbuf_for_msg(len, 0, M_DONTWAIT, 1, MT_DATA);
 	if (m_notify == NULL)
 		/* no space left */
 		return;
@@ -2661,27 +2666,29 @@ sctp_notify_assoc_change(uint32_t event,
 	sac->sac_type = SCTP_ASSOC_CHANGE;
 	sac->sac_flags = 0;
 	sac->sac_length = sizeof(struct sctp_assoc_change);
-	sac->sac_state = event;
+	sac->sac_state = state;
 	sac->sac_error = error;
 	/* XXX verify these stream counts */
 	sac->sac_outbound_streams = stcb->asoc.streamoutcnt;
 	sac->sac_inbound_streams = stcb->asoc.streamincnt;
 	sac->sac_assoc_id = sctp_get_associd(stcb);
-	i = 0;
-	if (stcb->asoc.peer_supports_prsctp) {
-		sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_PR;
-	}
-	if (stcb->asoc.peer_supports_auth) {
-		sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_AUTH;
-	}
-	if (stcb->asoc.peer_supports_asconf) {
-		sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_ASCONF;
-	}
-	sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_MULTIBUF;
-	if (stcb->asoc.peer_supports_strreset) {
-		sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_RE_CONFIG;
+	if ((state == SCTP_COMM_UP) || (state == SCTP_RESTART)) {
+		i = 0;
+		if (stcb->asoc.peer_supports_prsctp) {
+			sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_PR;
+		}
+		if (stcb->asoc.peer_supports_auth) {
+			sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_AUTH;
+		}
+		if (stcb->asoc.peer_supports_asconf) {
+			sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_ASCONF;
+		}
+		sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_MULTIBUF;
+		if (stcb->asoc.peer_supports_strreset) {
+			sac->sac_info[i++] = SCTP_ASSOC_SUPPORTS_RE_CONFIG;
+		}
+		sac->sac_length += i;
 	}
-	sac->sac_length += i;
 	SCTP_BUF_LEN(m_notify) = sac->sac_length;
 	SCTP_BUF_NEXT(m_notify) = NULL;
 	control = sctp_build_readq_entry(stcb, stcb->asoc.primary_destination,
@@ -2700,7 +2707,7 @@ sctp_notify_assoc_change(uint32_t event,
 	    control,
 	    &stcb->sctp_socket->so_rcv, 1, SCTP_READ_LOCK_NOT_HELD,
 	    so_locked);
-	if (event == SCTP_COMM_LOST) {
+	if (state == SCTP_COMM_LOST) {
 		/* Wake up any sleeper */
 #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING)
 		so = SCTP_INP_SO(stcb->sctp_ep);



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