History

tcp: add SYN/data info to TCP_INFO

Add a bit TCPI_OPT_SYN_DATA (32) to the socket option TCP_INFO:tcpi_options. It's set if the data in SYN (sent or received) is acked by SYN-ACK. Server or client application can use this information to check Fast Open success rate.

Yuchung Cheng committed 14 years ago

Commit 6f736011 parent e6e71056 files · +8 −1Browse files

Unified · Split

6 files
  1. include/linux/tcp.h +2 −1
  2. include/uapi/linux/tcp.h +1 −0
  3. net/ipv4/tcp.c +2 −0
  4. net/ipv4/tcp_input.c +1 −0
  5. net/ipv4/tcp_ipv4.c +1 −0
  6. net/ipv4/tcp_minisocks.c +1 −0
include/linux/tcp.h+2−1
@@ -191,7 +191,8 @@ struct tcp_sock { · 190 unmodified lines
191191 u8 do_early_retrans:1,/* Enable RFC5827 early-retransmit */
192192 early_retrans_delayed:1, /* Delayed ER timer installed */
193193 syn_data:1, /* SYN includes data */
194− syn_fastopen:1; /* SYN includes Fast Open option */
194+ syn_fastopen:1, /* SYN includes Fast Open option */
195+ syn_data_acked:1;/* data in SYN is acked by SYN-ACK */
195196
196197 /* RTT measurement */
197198 u32 srtt; /* smoothed round trip time << 3 */
include/uapi/linux/tcp.h+1−0
@@ -130,6 +130,7 @@ enum { · 129 unmodified lines
130130 #define TCPI_OPT_WSCALE 4
131131 #define TCPI_OPT_ECN 8 /* ECN was negociated at TCP session init */
132132 #define TCPI_OPT_ECN_SEEN 16 /* we received at least one packet with ECT */
133+#define TCPI_OPT_SYN_DATA 32 /* SYN-ACK acked data in SYN sent or rcvd */
133134
134135 enum tcp_ca_state {
135136 TCP_CA_Open = 0,
net/ipv4/tcp.c+2−0
@@ -2764,6 +2764,8 @@ void tcp_get_info(const struct sock *sk, struct tcp_info *info) · 2763 unmodified lines
27642764 info->tcpi_options |= TCPI_OPT_ECN;
27652765 if (tp->ecn_flags & TCP_ECN_SEEN)
27662766 info->tcpi_options |= TCPI_OPT_ECN_SEEN;
2767+ if (tp->syn_data_acked)
2768+ info->tcpi_options |= TCPI_OPT_SYN_DATA;
27672769
27682770 info->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto);
27692771 info->tcpi_ato = jiffies_to_usecs(icsk->icsk_ack.ato);
net/ipv4/tcp_input.c+1−0
@@ -5646,6 +5646,7 @@ static bool tcp_rcv_fastopen_synack(struct sock *sk, struct sk_buff *synack, · 5645 unmodified lines
56465646 tcp_rearm_rto(sk);
56475647 return true;
56485648 }
5649+ tp->syn_data_acked = tp->syn_data;
56495650 return false;
56505651 }
56515652
net/ipv4/tcp_ipv4.c+1−0
@@ -1461,6 +1461,7 @@ static int tcp_v4_conn_req_fastopen(struct sock *sk, · 1460 unmodified lines
14611461 skb_set_owner_r(skb, child);
14621462 __skb_queue_tail(&child->sk_receive_queue, skb);
14631463 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
1464+ tp->syn_data_acked = 1;
14641465 }
14651466 sk->sk_data_ready(sk, 0);
14661467 bh_unlock_sock(child);
net/ipv4/tcp_minisocks.c+1−0
@@ -510,6 +510,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, · 509 unmodified lines
510510 newtp->rx_opt.mss_clamp = req->mss;
511511 TCP_ECN_openreq_child(newtp, req);
512512 newtp->fastopen_rsk = NULL;
513+ newtp->syn_data_acked = 0;
513514
514515 TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_PASSIVEOPENS);
515516 }