TCP state of TCP_NEW_SYN_RECV

Outline

Previous TCP request control block not independent state, but rather on their parent state control block, i.e. TCP_LISTEN state, the request should now be added to the global control block ehash in one state is required, the state is TCP_SYN_RECV fast open sokets used, so the addition of a new state TCP_NEW_SYN_RECV;

The following intercept kernel git, address: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/log/?qt=grep&q=TCP_NEW_SYN_RECV

TCP_SYN_RECV state is currently used by fast open sockets.

Initial TCP requests (the pseudo sockets created when a SYN is received)
are not yet associated to a state. They are attached to their parent,
and the parent is in TCP_LISTEN state.

This commit adds TCP_NEW_SYN_RECV state, so that we can convert
TCP stack to a different schem gradually.

------------------------
We need to identify request sock when they'll be visible in
global ehash table.

ireq_state is an alias to req.__req_common.skc_state.

Its value is set to TCP_NEW_SYN_RECV

 

Code Analysis

The following code to the server side in the LISTEN state, waiting to receive syn premise;

Receiving SYN

After the server receives a SYN, tcp_conn_request calls to process a connection request, which requests to create a call control block inet_reqsk_alloc seen ireq_state request control block is initialized to TCP_NEW_SYN_RECV;

 1 struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops,
 2                       struct sock *sk_listener,
 3                       bool attach_listener)
 4 {
 5     struct request_sock *req = reqsk_alloc(ops, sk_listener,
 6                            attach_listener);
 7 
 8     if (req) {
 9         struct inet_request_sock *ireq = inet_rsk(req);
10 
11         kmemcheck_annotate_bitfield(ireq, flags);
12         ireq->opt = NULL;
13 #if IS_ENABLED(CONFIG_IPV6)
14         ireq->pktopts = NULL;
15 #endif
16         atomic64_set(&ireq->ir_cookie, 0);
17         ireq->ireq_state = TCP_NEW_SYN_RECV;
18         write_pnet(&ireq->ireq_net, sock_net(sk_listener));
19         ireq->ireq_family = sk_listener->sk_family;
20     }
21 
22     return req;
23 }

 

The part of a detailed analysis of the venue: <first passive open the TCP handshake - receiving SYN>;

 

Receiving an ACK

tcp_v4_rcv TCP_NEW_SYN_RECV function will be processed if the connectivity check is successful, the new required to handle the connection control block, the control block of the new state will be used TCP_SYN_RECV state;

 

The detailed analysis portion venue: <TCP passive open the third handshake - receiving ACK>;

Guess you like

Origin www.cnblogs.com/wanpengcoder/p/11751740.html