IPSEC-GRE: fixes and API update to common types.
[vpp.git] / src / vnet / tcp / tcp_output.c
index 4b38649..518a80d 100644 (file)
@@ -49,10 +49,6 @@ typedef struct
   tcp_connection_t tcp_connection;
 } tcp_tx_trace_t;
 
-#ifndef CLIB_MARCH_VARIANT
-u16 dummy_mtu = 1460;
-#endif /* CLIB_MARCH_VARIANT */
-
 static u8 *
 format_tcp_tx_trace (u8 * s, va_list * args)
 {
@@ -89,7 +85,7 @@ void
 tcp_update_rcv_mss (tcp_connection_t * tc)
 {
   /* TODO find our iface MTU */
-  tc->mss = dummy_mtu - sizeof (tcp_header_t);
+  tc->mss = tcp_main.default_mtu - sizeof (tcp_header_t);
 }
 
 /**
@@ -134,20 +130,19 @@ tcp_initial_window_to_advertise (tcp_connection_t * tc)
   return clib_min (tc->rcv_wnd, TCP_WND_MAX);
 }
 
-static void
+static inline void
 tcp_update_rcv_wnd (tcp_connection_t * tc)
 {
+  u32 available_space, wnd;
   i32 observed_wnd;
-  u32 available_space, max_fifo, wnd;
+
+  ASSERT (tc->rcv_opts.mss < transport_rx_fifo_size (&tc->connection));
 
   /*
    * Figure out how much space we have available
    */
   available_space = transport_max_rx_enqueue (&tc->connection);
-  max_fifo = transport_rx_fifo_size (&tc->connection);
-
-  ASSERT (tc->rcv_opts.mss < max_fifo);
-  if (available_space < tc->rcv_opts.mss && available_space < max_fifo >> 3)
+  if (PREDICT_FALSE (available_space < tc->rcv_opts.mss))
     available_space = 0;
 
   /*
@@ -155,13 +150,11 @@ tcp_update_rcv_wnd (tcp_connection_t * tc)
    * to compute the new window
    */
   observed_wnd = (i32) tc->rcv_wnd - (tc->rcv_nxt - tc->rcv_las);
-  if (observed_wnd < 0)
-    observed_wnd = 0;
 
   /* Bad. Thou shalt not shrink */
-  if (available_space < observed_wnd)
+  if (PREDICT_FALSE ((i32) available_space < observed_wnd))
     {
-      wnd = observed_wnd;
+      wnd = clib_max (observed_wnd, 0);
       TCP_EVT_DBG (TCP_EVT_RCV_WND_SHRUNK, tc, observed_wnd, available_space);
     }
   else
@@ -190,16 +183,6 @@ tcp_window_to_advertise (tcp_connection_t * tc, tcp_state_t state)
     return tcp_initial_window_to_advertise (tc);
 
   tcp_update_rcv_wnd (tc);
-
-  if (tc->rcv_wnd == 0)
-    {
-      tc->flags |= TCP_CONN_SENT_RCV_WND0;
-    }
-  else
-    {
-      tc->flags &= ~TCP_CONN_SENT_RCV_WND0;
-    }
-
   return tc->rcv_wnd >> tc->rcv_wscale;
 }
 
@@ -293,7 +276,7 @@ tcp_make_syn_options (tcp_options_t * opts, u8 wnd_scale)
   u8 len = 0;
 
   opts->flags |= TCP_OPTS_FLAG_MSS;
-  opts->mss = dummy_mtu;       /*XXX discover that */
+  opts->mss = tcp_main.default_mtu;    /*XXX discover that */
   len += TCP_OPTION_LEN_MSS;
 
   opts->flags |= TCP_OPTS_FLAG_WSCALE;
@@ -539,9 +522,6 @@ void
 tcp_make_fin (tcp_connection_t * tc, vlib_buffer_t * b)
 {
   tcp_make_ack_i (tc, b, TCP_STATE_ESTABLISHED, TCP_FLAG_FIN | TCP_FLAG_ACK);
-
-  /* Reset flags, make sure ack is sent */
-  vnet_buffer (b)->tcp.flags &= ~TCP_BUF_FLAG_DUPACK;
 }
 
 /**