Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Apr 2018 20:13:29 +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-11@freebsd.org
Subject:   svn commit: r332225 - stable/11/sys/netinet
Message-ID:  <201804072013.w37KDTOM083137@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tuexen
Date: Sat Apr  7 20:13:29 2018
New Revision: 332225
URL: https://svnweb.freebsd.org/changeset/base/332225

Log:
  MFC r325788:
  
  Simply the code and use the full buffer for contigous chunk representation.

Modified:
  stable/11/sys/netinet/sctp_input.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netinet/sctp_input.c
==============================================================================
--- stable/11/sys/netinet/sctp_input.c	Sat Apr  7 20:11:56 2018	(r332224)
+++ stable/11/sys/netinet/sctp_input.c	Sat Apr  7 20:13:29 2018	(r332225)
@@ -4527,7 +4527,7 @@ sctp_process_control(struct mbuf *m, int iphlen, int *
 	char msg[SCTP_DIAG_INFO_LEN];
 	uint32_t vtag_in;
 	int num_chunks = 0;	/* number of control chunks processed */
-	uint32_t chk_length;
+	uint32_t chk_length, contiguous;
 	int ret;
 	int abort_no_unlock = 0;
 	int ecne_seen = 0;
@@ -4753,58 +4753,30 @@ process_control_chunks:
 		}
 		SCTP_STAT_INCR_COUNTER64(sctps_incontrolchunks);
 		/*
-		 * INIT-ACK only gets the init ack "header" portion only
-		 * because we don't have to process the peer's COOKIE. All
-		 * others get a complete chunk.
+		 * INIT and INIT-ACK only gets the init ack "header" portion
+		 * only because we don't have to process the peer's COOKIE.
+		 * All others get a complete chunk.
 		 */
-		if ((ch->chunk_type == SCTP_INITIATION_ACK) ||
-		    (ch->chunk_type == SCTP_INITIATION)) {
-			/* get an init-ack chunk */
-			ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset,
-			    sizeof(struct sctp_init_ack_chunk), chunk_buf);
-			if (ch == NULL) {
-				*offset = length;
-				if (stcb != NULL) {
-					SCTP_TCB_UNLOCK(stcb);
-				}
-				return (NULL);
+		switch (ch->chunk_type) {
+		case SCTP_INITIATION:
+			contiguous = sizeof(struct sctp_init_chunk);
+			break;
+		case SCTP_INITIATION_ACK:
+			contiguous = sizeof(struct sctp_init_ack_chunk);
+			break;
+		default:
+			contiguous = min(chk_length, sizeof(chunk_buf));
+			break;
+		}
+		ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset,
+		    contiguous,
+		    chunk_buf);
+		if (ch == NULL) {
+			*offset = length;
+			if (stcb != NULL) {
+				SCTP_TCB_UNLOCK(stcb);
 			}
-		} else {
-			/* For cookies and all other chunks. */
-			if (chk_length > sizeof(chunk_buf)) {
-				/*
-				 * use just the size of the chunk buffer so
-				 * the front part of our chunks fit in
-				 * contiguous space up to the chunk buffer
-				 * size (508 bytes). For chunks that need to
-				 * get more than that they must use the
-				 * sctp_m_getptr() function or other means
-				 * (e.g. know how to parse mbuf chains).
-				 * Cookies do this already.
-				 */
-				ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset,
-				    (sizeof(chunk_buf) - 4),
-				    chunk_buf);
-				if (ch == NULL) {
-					*offset = length;
-					if (stcb != NULL) {
-						SCTP_TCB_UNLOCK(stcb);
-					}
-					return (NULL);
-				}
-			} else {
-				/* We can fit it all */
-				ch = (struct sctp_chunkhdr *)sctp_m_getptr(m, *offset,
-				    chk_length, chunk_buf);
-				if (ch == NULL) {
-					SCTP_PRINTF("sctp_process_control: Can't get the all data....\n");
-					*offset = length;
-					if (stcb != NULL) {
-						SCTP_TCB_UNLOCK(stcb);
-					}
-					return (NULL);
-				}
-			}
+			return (NULL);
 		}
 		num_chunks++;
 		/* Save off the last place we got a control from */
@@ -5401,7 +5373,7 @@ process_control_chunks:
 				}
 				sctp_handle_packet_dropped((struct sctp_pktdrop_chunk *)ch,
 				    stcb, *netp,
-				    min(chk_length, (sizeof(chunk_buf) - 4)));
+				    min(chk_length, contiguous));
 			}
 			break;
 		case SCTP_AUTHENTICATION:



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