SCTP: cumulative SACK fix

A bug was found affecting the cumulative sending of SACK messages.
Because the next0 was never assigned to the next_output the SACK message
was never leaving the peer.
Further, two new flags have been added to distinguish when a peer is
AWAITING a SACK message (e.g. DATA is inflight and waiting to be
acknowledged).

Change-Id: Ibb5a98f7e5fed15cdc76710b74195cac031d59ed
Signed-off-by: Marco Varlese <marco.varlese@suse.com>
diff --git a/src/vnet/sctp/sctp.h b/src/vnet/sctp/sctp.h
index 32d3ab9..f0ce594 100644
--- a/src/vnet/sctp/sctp.h
+++ b/src/vnet/sctp/sctp.h
@@ -93,7 +93,9 @@
 {
   SCTP_SUBCONN_STATE_DOWN = 0,
   SCTP_SUBCONN_STATE_UP,
-  SCTP_SUBCONN_STATE_ALLOW_HB
+  SCTP_SUBCONN_STATE_ALLOW_HB,
+  SCTP_SUBCONN_AWAITING_SACK,
+  SCTP_SUBCONN_SACK_RECEIVED
 };
 
 #define SCTP_INITIAL_SSHTRESH 65535
@@ -920,6 +922,8 @@
 always_inline u8
 cwnd_fully_utilized (sctp_connection_t * sctp_conn, u8 idx)
 {
+  if (sctp_conn->sub_conn[idx].cwnd == 0)
+    return 1;
   return 0;
 }
 
@@ -928,6 +932,7 @@
 update_cwnd (sctp_connection_t * sctp_conn)
 {
   u8 i;
+  u32 inflight = sctp_conn->next_tsn - sctp_conn->last_unacked_tsn;
 
   for (i = 0; i < MAX_SCTP_CONNECTIONS; i++)
     {
@@ -960,6 +965,12 @@
 	  sctp_conn->sub_conn[i].cwnd =
 	    clib_min (sctp_conn->sub_conn[i].PMTU, 1);
 	}
+
+      /* Section 6.1; point (D) */
+      if ((inflight + SCTP_RTO_BURST * sctp_conn->sub_conn[i].PMTU) <
+	  sctp_conn->sub_conn[i].cwnd)
+	sctp_conn->sub_conn[i].cwnd =
+	  inflight + SCTP_RTO_BURST * sctp_conn->sub_conn[i].PMTU;
     }
 }