svn commit: r218400 - in head/sys: netinet netinet6

Michael Tuexen tuexen at FreeBSD.org
Mon Feb 7 15:04:23 UTC 2011


Author: tuexen
Date: Mon Feb  7 15:04:23 2011
New Revision: 218400
URL: http://svn.freebsd.org/changeset/base/218400

Log:
  Fix bugs related to M_FLOWID:
  * Store the flowid when receiving an SCTP/IPv6 packet.
  * Store the flowid when receiving an SCTP packet with wrong CRC.
  * Initilize flowid correctly.
  * Put test code under INVARIANTS.
  MFC after: 3 months.

Modified:
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_structs.h
  head/sys/netinet6/sctp6_usrreq.c

Modified: head/sys/netinet/sctp_input.c
==============================================================================
--- head/sys/netinet/sctp_input.c	Mon Feb  7 14:58:29 2011	(r218399)
+++ head/sys/netinet/sctp_input.c	Mon Feb  7 15:04:23 2011	(r218400)
@@ -2617,7 +2617,9 @@ sctp_handle_cookie_echo(struct mbuf *m, 
 	}
 	if ((*netp != NULL) && (m->m_flags & M_FLOWID)) {
 		(*netp)->flowid = m->m_pkthdr.flowid;
+#ifdef INVARIANTS
 		(*netp)->flowidset = 1;
+#endif
 	}
 	/*
 	 * Ok, we built an association so confirm the address we sent the
@@ -5815,6 +5817,12 @@ sctp_input_with_port(struct mbuf *i_pak,
 			}
 			net->port = port;
 		}
+		if ((net != NULL) && (m->m_flags & M_FLOWID)) {
+			net->flowid = m->m_pkthdr.flowid;
+#ifdef INVARIANTS
+			net->flowidset = 1;
+#endif
+		}
 		if ((inp) && (stcb)) {
 			sctp_send_packet_dropped(stcb, net, m, iphlen, 1);
 			sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_INPUT_ERROR, SCTP_SO_NOT_LOCKED);
@@ -5846,7 +5854,9 @@ sctp_skip_csum_4:
 	}
 	if ((net != NULL) && (m->m_flags & M_FLOWID)) {
 		net->flowid = m->m_pkthdr.flowid;
+#ifdef INVARIANTS
 		net->flowidset = 1;
+#endif
 	}
 	/* inp's ref-count increased && stcb locked */
 	if (inp == NULL) {

Modified: head/sys/netinet/sctp_output.c
==============================================================================
--- head/sys/netinet/sctp_output.c	Mon Feb  7 14:58:29 2011	(r218399)
+++ head/sys/netinet/sctp_output.c	Mon Feb  7 15:04:23 2011	(r218400)
@@ -3485,12 +3485,11 @@ sctp_lowlevel_chunk_output(struct sctp_i
 		SCTP_BUF_NEXT(newm) = m;
 		m = newm;
 		if (net != NULL) {
+#ifdef INVARIANTS
 			if (net->flowidset == 0) {
-				net->flowid = stcb->asoc.my_vtag ^
-				    ntohs(stcb->rport) ^
-				    ntohs(stcb->sctp_ep->sctp_lport);
-				net->flowidset = 1;
+				panic("Flow ID not set");
 			}
+#endif
 			m->m_pkthdr.flowid = net->flowid;
 			m->m_flags |= M_FLOWID;
 		} else {
@@ -3821,12 +3820,11 @@ sctp_lowlevel_chunk_output(struct sctp_i
 		SCTP_BUF_NEXT(newm) = m;
 		m = newm;
 		if (net != NULL) {
+#ifdef INVARIANTS
 			if (net->flowidset == 0) {
-				net->flowid = stcb->asoc.my_vtag ^
-				    ntohs(stcb->rport) ^
-				    ntohs(stcb->sctp_ep->sctp_lport);
-				net->flowidset = 1;
+				panic("Flow ID not set");
 			}
+#endif
 			m->m_pkthdr.flowid = net->flowid;
 			m->m_flags |= M_FLOWID;
 		} else {

Modified: head/sys/netinet/sctp_pcb.c
==============================================================================
--- head/sys/netinet/sctp_pcb.c	Mon Feb  7 14:58:29 2011	(r218399)
+++ head/sys/netinet/sctp_pcb.c	Mon Feb  7 15:04:23 2011	(r218400)
@@ -3962,6 +3962,13 @@ sctp_add_remote_addr(struct sctp_tcb *st
 	net->find_pseudo_cumack = 1;
 	net->find_rtx_pseudo_cumack = 1;
 	net->src_addr_selected = 0;
+	/* Choose an initial flowid. */
+	net->flowid = stcb->asoc.my_vtag ^
+	    ntohs(stcb->rport) ^
+	    ntohs(stcb->sctp_ep->sctp_lport);
+#ifdef INVARIANTS
+	net->flowidset = 1;
+#endif
 	netfirst = TAILQ_FIRST(&stcb->asoc.nets);
 	if (net->ro.ro_rt == NULL) {
 		/* Since we have no route put it at the back */
@@ -4035,11 +4042,6 @@ sctp_add_remote_addr(struct sctp_tcb *st
 		TAILQ_INSERT_HEAD(&stcb->asoc.nets,
 		    stcb->asoc.primary_destination, sctp_next);
 	}
-	/* Choose an initial flowid. */
-	net->flowid = stcb->asoc.my_vtag ^
-	    ntohs(stcb->rport) ^
-	    ntohs(stcb->sctp_ep->sctp_lport);
-	net->flowidset = 1;
 	return (0);
 }
 

Modified: head/sys/netinet/sctp_structs.h
==============================================================================
--- head/sys/netinet/sctp_structs.h	Mon Feb  7 14:58:29 2011	(r218399)
+++ head/sys/netinet/sctp_structs.h	Mon Feb  7 15:04:23 2011	(r218400)
@@ -351,7 +351,9 @@ struct sctp_nets {
 	/* JRS - struct used in HTCP algorithm */
 	struct htcp htcp_ca;
 	uint32_t flowid;
+#ifdef INVARIANTS
 	uint8_t flowidset;
+#endif
 };
 
 

Modified: head/sys/netinet6/sctp6_usrreq.c
==============================================================================
--- head/sys/netinet6/sctp6_usrreq.c	Mon Feb  7 14:58:29 2011	(r218399)
+++ head/sys/netinet6/sctp6_usrreq.c	Mon Feb  7 15:04:23 2011	(r218400)
@@ -170,6 +170,12 @@ sctp6_input(struct mbuf **i_pak, int *of
 			}
 			net->port = port;
 		}
+		if ((net != NULL) && (m->m_flags & M_FLOWID)) {
+			net->flowid = m->m_pkthdr.flowid;
+#ifdef INVARIANTS
+			net->flowidset = 1;
+#endif
+		}
 		/* in6p's ref-count increased && stcb locked */
 		if ((in6p) && (stcb)) {
 			sctp_send_packet_dropped(stcb, net, m, iphlen, 1);
@@ -198,6 +204,12 @@ sctp_skip_csum:
 		}
 		net->port = port;
 	}
+	if ((net != NULL) && (m->m_flags & M_FLOWID)) {
+		net->flowid = m->m_pkthdr.flowid;
+#ifdef INVARIANTS
+		net->flowidset = 1;
+#endif
+	}
 	/* in6p's ref-count increased */
 	if (in6p == NULL) {
 		struct sctp_init_chunk *init_chk, chunk_buf;


More information about the svn-src-head mailing list