Author: tuexen
Date: Fri Feb 10 19:52:18 2012
New Revision: 231415
URL: http://svn.freebsd.org/changeset/base/231415

Log:
  MFC r218400:
  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.

Modified:
  stable/8/sys/netinet/sctp_input.c
  stable/8/sys/netinet/sctp_output.c
  stable/8/sys/netinet/sctp_pcb.c
  stable/8/sys/netinet/sctp_structs.h
  stable/8/sys/netinet6/sctp6_usrreq.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_input.c
==============================================================================
--- stable/8/sys/netinet/sctp_input.c   Fri Feb 10 19:49:35 2012        
(r231414)
+++ stable/8/sys/netinet/sctp_input.c   Fri Feb 10 19:52:18 2012        
(r231415)
@@ -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
@@ -5817,6 +5819,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);
@@ -5848,7 +5856,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: stable/8/sys/netinet/sctp_output.c
==============================================================================
--- stable/8/sys/netinet/sctp_output.c  Fri Feb 10 19:49:35 2012        
(r231414)
+++ stable/8/sys/netinet/sctp_output.c  Fri Feb 10 19:52:18 2012        
(r231415)
@@ -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: stable/8/sys/netinet/sctp_pcb.c
==============================================================================
--- stable/8/sys/netinet/sctp_pcb.c     Fri Feb 10 19:49:35 2012        
(r231414)
+++ stable/8/sys/netinet/sctp_pcb.c     Fri Feb 10 19:52:18 2012        
(r231415)
@@ -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: stable/8/sys/netinet/sctp_structs.h
==============================================================================
--- stable/8/sys/netinet/sctp_structs.h Fri Feb 10 19:49:35 2012        
(r231414)
+++ stable/8/sys/netinet/sctp_structs.h Fri Feb 10 19:52:18 2012        
(r231415)
@@ -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: stable/8/sys/netinet6/sctp6_usrreq.c
==============================================================================
--- stable/8/sys/netinet6/sctp6_usrreq.c        Fri Feb 10 19:49:35 2012        
(r231414)
+++ stable/8/sys/netinet6/sctp6_usrreq.c        Fri Feb 10 19:52:18 2012        
(r231415)
@@ -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;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to