X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ftcp%2Ftcp.c;h=8a09b565ffa06e2ab7bb79f89887b07046b4d21a;hb=e5d34919b;hp=4a0ffc137e5c1ae792aa8827ce9da44d46250b8b;hpb=70f879d2852dfc042ad0911a4a6e4a1714c0eb83;p=vpp.git diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c index 4a0ffc137e5..8a09b565ffa 100644 --- a/src/vnet/tcp/tcp.c +++ b/src/vnet/tcp/tcp.c @@ -707,6 +707,51 @@ tcp_connection_init_vars (tcp_connection_t * tc) tc->start_ts = tcp_time_now_us (tc->c_thread_index); } +void +tcp_init_w_buffer (tcp_connection_t * tc, vlib_buffer_t * b, u8 is_ip4) +{ + tcp_header_t *th = tcp_buffer_hdr (b); + + tc->c_lcl_port = th->dst_port; + tc->c_rmt_port = th->src_port; + tc->c_is_ip4 = is_ip4; + + if (is_ip4) + { + ip4_header_t *ip4 = vlib_buffer_get_current (b); + tc->c_lcl_ip4.as_u32 = ip4->dst_address.as_u32; + tc->c_rmt_ip4.as_u32 = ip4->src_address.as_u32; + } + else + { + ip6_header_t *ip6 = vlib_buffer_get_current (b); + clib_memcpy_fast (&tc->c_lcl_ip6, &ip6->dst_address, + sizeof (ip6_address_t)); + clib_memcpy_fast (&tc->c_rmt_ip6, &ip6->src_address, + sizeof (ip6_address_t)); + } + + tc->irs = vnet_buffer (b)->tcp.seq_number; + tc->rcv_nxt = vnet_buffer (b)->tcp.seq_number + 1; + tc->rcv_las = tc->rcv_nxt; + tc->sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX]; + tc->snd_wl1 = vnet_buffer (b)->tcp.seq_number; + tc->snd_wl2 = vnet_buffer (b)->tcp.ack_number; + + /* RFC1323: TSval timestamps sent on {SYN} and {SYN,ACK} + * segments are used to initialize PAWS. */ + if (tcp_opts_tstamp (&tc->rcv_opts)) + { + tc->tsval_recent = tc->rcv_opts.tsval; + tc->tsval_recent_age = tcp_time_now (); + } + + if (tcp_opts_wscale (&tc->rcv_opts)) + tc->snd_wscale = tc->rcv_opts.wscale; + + tc->snd_wnd = clib_net_to_host_u16 (th->window) << tc->snd_wscale; +} + static int tcp_alloc_custom_local_endpoint (tcp_main_t * tm, ip46_address_t * lcl_addr, u16 * lcl_port, u8 is_ip4) @@ -1281,14 +1326,7 @@ tcp_session_send_params (transport_connection_t * trans_conn, /* This still works if fast retransmit is on */ sp->tx_offset = tc->snd_nxt - tc->snd_una; - sp->flags = 0; - if (!tc->snd_wnd) - { - if (tcp_timer_is_active (tc, TCP_TIMER_PERSIST)) - sp->flags = TRANSPORT_SND_F_DESCHED; - else - sp->flags = TRANSPORT_SND_F_POSTPONE; - } + sp->flags = sp->snd_space ? 0 : TRANSPORT_SND_F_DESCHED; return 0; } @@ -1540,6 +1578,13 @@ tcp_connection_tx_pacer_reset (tcp_connection_t * tc, u32 window, srtt * CLIB_US_TIME_FREQ); } +void +tcp_reschedule (tcp_connection_t * tc) +{ + if (tcp_in_cong_recovery (tc) || tcp_snd_space_inline (tc)) + transport_connection_reschedule (&tc->connection); +} + static void tcp_expired_timers_dispatch (u32 * expired_timers) {