SCTP: fix overflow issue with timestamp
[vpp.git] / src / vnet / sctp / sctp_input.c
index ff79840..4f62145 100644 (file)
@@ -851,7 +851,7 @@ sctp_handle_cookie_echo (sctp_header_t * sctp_hdr,
                         sctp_connection_t * sctp_conn, u8 idx,
                         vlib_buffer_t * b0, u16 * next0)
 {
-  u32 now = sctp_time_now ();
+  u64 now = sctp_time_now ();
 
   sctp_cookie_echo_chunk_t *cookie_echo =
     (sctp_cookie_echo_chunk_t *) sctp_hdr;
@@ -864,10 +864,11 @@ sctp_handle_cookie_echo (sctp_header_t * sctp_hdr,
 
   sctp_calculate_rto (sctp_conn, idx);
 
-  u32 creation_time =
-    clib_net_to_host_u32 (cookie_echo->cookie.creation_time);
-  u32 cookie_lifespan =
+  u64 creation_time =
+    clib_net_to_host_u64 (cookie_echo->cookie.creation_time);
+  u64 cookie_lifespan =
     clib_net_to_host_u32 (cookie_echo->cookie.cookie_lifespan);
+
   if (now > creation_time + cookie_lifespan)
     {
       SCTP_DBG ("now (%u) > creation_time (%u) + cookie_lifespan (%u)",
@@ -1060,7 +1061,7 @@ sctp46_rcv_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
               * hence we should never get to the "default" case below.
               */
            default:
-             error0 = SCTP_ERROR_UNKOWN_CHUNK;
+             error0 = SCTP_ERROR_UNKNOWN_CHUNK;
              next0 = sctp_next_drop (is_ip4);
              goto drop;
            }
@@ -1400,7 +1401,7 @@ sctp46_shutdown_phase_inline (vlib_main_t * vm,
               * hence we should never get to the "default" case below.
               */
            default:
-             error0 = SCTP_ERROR_UNKOWN_CHUNK;
+             error0 = SCTP_ERROR_UNKNOWN_CHUNK;
              next0 = sctp_next_drop (is_ip4);
              goto drop;
            }
@@ -1516,6 +1517,11 @@ sctp_handle_sack (sctp_selective_ack_chunk_t * sack_chunk,
   /* Check that the LOCALLY generated tag is being used by the REMOTE peer as the verification tag */
   if (sctp_conn->local_tag != sack_chunk->sctp_hdr.verification_tag)
     {
+      SCTP_ADV_DBG
+       ("sctp_conn->local_tag != sack_chunk->sctp_hdr.verification_tag");
+
+      *next0 = sctp_next_drop (sctp_conn->sub_conn[idx].c_is_ip4);
+
       return SCTP_ERROR_INVALID_TAG;
     }
 
@@ -1709,7 +1715,7 @@ sctp46_listen_process_inline (vlib_main_t * vm,
                 child_conn->sub_conn[SCTP_PRIMARY_PATH_IDX].
                 connection.c_index, sctp_chunk_to_string (chunk_type));
 
-             error0 = SCTP_ERROR_UNKOWN_CHUNK;
+             error0 = SCTP_ERROR_UNKNOWN_CHUNK;
              next0 = sctp_next_drop (is_ip4);
              goto drop;
            }
@@ -1917,7 +1923,7 @@ sctp46_established_phase_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
               * hence we should never get to the "default" case below.
               */
            default:
-             error0 = SCTP_ERROR_UNKOWN_CHUNK;
+             error0 = SCTP_ERROR_UNKNOWN_CHUNK;
              next0 = sctp_next_drop (is_ip4);
              goto done;
            }
@@ -2188,7 +2194,7 @@ sctp46_input_dispatcher (vlib_main_t * vm, vlib_node_runtime_t * node,
              sctp_prepare_operation_error (sctp_conn, SCTP_PRIMARY_PATH_IDX,
                                            b0, UNRECOGNIZED_CHUNK_TYPE);
 
-             error0 = SCTP_ERROR_UNKOWN_CHUNK;
+             error0 = SCTP_ERROR_UNKNOWN_CHUNK;
              next0 = sctp_next_output (is_ip4);
              goto done;
            }