Author: tuexen
Date: Sun Dec  6 16:17:57 2015
New Revision: 291904
URL: https://svnweb.freebsd.org/changeset/base/291904

Log:
  Fix the allocation of outgoing streams:
  * When processing a cookie, use the number of
    streams announced in the INIT-ACK.
  * When sending an INIT-ACK for an existing
    association, use the value from the association,
    not from the end-point.
  
  MFC after:    1 week

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

Modified: head/sys/netinet/sctp_input.c
==============================================================================
--- head/sys/netinet/sctp_input.c       Sun Dec  6 14:09:31 2015        
(r291903)
+++ head/sys/netinet/sctp_input.c       Sun Dec  6 16:17:57 2015        
(r291904)
@@ -2103,6 +2103,7 @@ sctp_process_cookie_new(struct mbuf *m, 
         */
        stcb = sctp_aloc_assoc(inp, init_src, &error,
            ntohl(initack_cp->init.initiate_tag), vrf_id,
+           ntohs(initack_cp->init.num_outbound_streams),
            (struct thread *)NULL
            );
        if (stcb == NULL) {

Modified: head/sys/netinet/sctp_output.c
==============================================================================
--- head/sys/netinet/sctp_output.c      Sun Dec  6 14:09:31 2015        
(r291903)
+++ head/sys/netinet/sctp_output.c      Sun Dec  6 16:17:57 2015        
(r291904)
@@ -3652,6 +3652,7 @@ sctp_process_cmsgs_for_init(struct sctp_
 #endif
                                                stcb->asoc.strmout[i].stream_no 
= i;
                                                
stcb->asoc.strmout[i].last_msg_incomplete = 0;
+                                               stcb->asoc.strmout[i].state = 
SCTP_STREAM_OPENING;
                                                
stcb->asoc.ss_functions.sctp_ss_init_stream(&stcb->asoc.strmout[i], NULL);
                                        }
                                }
@@ -5841,10 +5842,10 @@ do_a_abort:
        his_limit = ntohs(init_chk->init.num_inbound_streams);
        /* choose what I want */
        if (asoc != NULL) {
-               if (asoc->streamoutcnt > inp->sctp_ep.pre_open_stream_count) {
+               if (asoc->streamoutcnt > asoc->pre_open_streams) {
                        i_want = asoc->streamoutcnt;
                } else {
-                       i_want = inp->sctp_ep.pre_open_stream_count;
+                       i_want = asoc->pre_open_streams;
                }
        } else {
                i_want = inp->sctp_ep.pre_open_stream_count;
@@ -12601,6 +12602,7 @@ sctp_lower_sosend(struct socket *so,
                        }
 #endif
                        stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id,
+                           inp->sctp_ep.pre_open_stream_count,
                            p
                            );
                        if (stcb == NULL) {

Modified: head/sys/netinet/sctp_pcb.c
==============================================================================
--- head/sys/netinet/sctp_pcb.c Sun Dec  6 14:09:31 2015        (r291903)
+++ head/sys/netinet/sctp_pcb.c Sun Dec  6 16:17:57 2015        (r291904)
@@ -4160,6 +4160,7 @@ try_again:
 struct sctp_tcb *
 sctp_aloc_assoc(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
     int *error, uint32_t override_tag, uint32_t vrf_id,
+    uint16_t o_streams,
     struct thread *p
 )
 {
@@ -4318,7 +4319,7 @@ sctp_aloc_assoc(struct sctp_inpcb *inp, 
        /* setup back pointer's */
        stcb->sctp_ep = inp;
        stcb->sctp_socket = inp->sctp_socket;
-       if ((err = sctp_init_asoc(inp, stcb, override_tag, vrf_id))) {
+       if ((err = sctp_init_asoc(inp, stcb, override_tag, vrf_id, o_streams))) 
{
                /* failed */
                SCTP_TCB_LOCK_DESTROY(stcb);
                SCTP_TCB_SEND_LOCK_DESTROY(stcb);

Modified: head/sys/netinet/sctp_pcb.h
==============================================================================
--- head/sys/netinet/sctp_pcb.h Sun Dec  6 14:09:31 2015        (r291903)
+++ head/sys/netinet/sctp_pcb.h Sun Dec  6 16:17:57 2015        (r291904)
@@ -584,7 +584,7 @@ void sctp_inpcb_free(struct sctp_inpcb *
 
 struct sctp_tcb *
 sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
-    int *, uint32_t, uint32_t, struct thread *);
+    int *, uint32_t, uint32_t, uint16_t, struct thread *);
 
 int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int);
 

Modified: head/sys/netinet/sctp_usrreq.c
==============================================================================
--- head/sys/netinet/sctp_usrreq.c      Sun Dec  6 14:09:31 2015        
(r291903)
+++ head/sys/netinet/sctp_usrreq.c      Sun Dec  6 16:17:57 2015        
(r291904)
@@ -1501,6 +1501,7 @@ sctp_do_connect_x(struct socket *so, str
 
        /* We are GOOD to go */
        stcb = sctp_aloc_assoc(inp, sa, &error, 0, vrf_id,
+           inp->sctp_ep.pre_open_stream_count,
            (struct thread *)p
            );
        if (stcb == NULL) {
@@ -6929,7 +6930,7 @@ sctp_connect(struct socket *so, struct s
        }
        vrf_id = inp->def_vrf_id;
        /* We are GOOD to go */
-       stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, p);
+       stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, 
inp->sctp_ep.pre_open_stream_count, p);
        if (stcb == NULL) {
                /* Gak! no memory */
                goto out_now;

Modified: head/sys/netinet/sctputil.c
==============================================================================
--- head/sys/netinet/sctputil.c Sun Dec  6 14:09:31 2015        (r291903)
+++ head/sys/netinet/sctputil.c Sun Dec  6 16:17:57 2015        (r291904)
@@ -938,7 +938,7 @@ sctp_map_assoc_state(int kernel_state)
 
 int
 sctp_init_asoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
-    uint32_t override_tag, uint32_t vrf_id)
+    uint32_t override_tag, uint32_t vrf_id, uint16_t o_strms)
 {
        struct sctp_association *asoc;
 
@@ -1100,7 +1100,7 @@ sctp_init_asoc(struct sctp_inpcb *inp, s
         * that we request by default.
         */
        asoc->strm_realoutsize = asoc->streamoutcnt = asoc->pre_open_streams =
-           inp->sctp_ep.pre_open_stream_count;
+           o_strms;
        SCTP_MALLOC(asoc->strmout, struct sctp_stream_out *,
            asoc->streamoutcnt * sizeof(struct sctp_stream_out),
            SCTP_M_STRMO);

Modified: head/sys/netinet/sctputil.h
==============================================================================
--- head/sys/netinet/sctputil.h Sun Dec  6 14:09:31 2015        (r291903)
+++ head/sys/netinet/sctputil.h Sun Dec  6 16:17:57 2015        (r291904)
@@ -83,7 +83,7 @@ uint32_t sctp_select_initial_TSN(struct 
 
 uint32_t sctp_select_a_tag(struct sctp_inpcb *, uint16_t lport, uint16_t 
rport, int);
 
-int sctp_init_asoc(struct sctp_inpcb *, struct sctp_tcb *, uint32_t, uint32_t);
+int sctp_init_asoc(struct sctp_inpcb *, struct sctp_tcb *, uint32_t, uint32_t, 
uint16_t);
 
 void sctp_fill_random_store(struct sctp_pcb *);
 

Modified: head/sys/netinet6/sctp6_usrreq.c
==============================================================================
--- head/sys/netinet6/sctp6_usrreq.c    Sun Dec  6 14:09:31 2015        
(r291903)
+++ head/sys/netinet6/sctp6_usrreq.c    Sun Dec  6 16:17:57 2015        
(r291904)
@@ -946,7 +946,7 @@ sctp6_connect(struct socket *so, struct 
                return (EALREADY);
        }
        /* We are GOOD to go */
-       stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, p);
+       stcb = sctp_aloc_assoc(inp, addr, &error, 0, vrf_id, 
inp->sctp_ep.pre_open_stream_count, p);
        SCTP_ASOC_CREATE_UNLOCK(inp);
        if (stcb == NULL) {
                /* Gak! no memory */
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to