TCP_NEW_SYN_RECV的含义是什么?

4

我知道TCP_SYN_RECV,但是TCP_NEW_SYN_RECV是什么意思?它们之间有什么区别?

https://github.com/torvalds/linux/blob/5924bbecd0267d87c24110cbe2041b5075173a25/include/net/tcp_states.h

  enum {
    TCP_ESTABLISHED = 1,
    TCP_SYN_SENT,
    TCP_SYN_RECV,
    TCP_FIN_WAIT1,
    TCP_FIN_WAIT2,
    TCP_TIME_WAIT,
    TCP_CLOSE,
    TCP_CLOSE_WAIT,
    TCP_LAST_ACK,
    TCP_LISTEN,
    TCP_CLOSING,    /* Now a valid state */
    TCP_NEW_SYN_RECV,

    TCP_MAX_STATES  /* Leave at the end! */
};

我看到了下面的代码 "sk->sk_state == TCP_NEW_SYN_RECV",为什么不使用 "sk->sk_state == TCP_SYN_RECV" 代替?

https://github.com/torvalds/linux/blob/8fa3b6f9392bf6d90cb7b908e07bd90166639f0a/net/ipv4/tcp_ipv4.c#L16485

if (sk->sk_state == TCP_NEW_SYN_RECV) {
    struct request_sock *req = inet_reqsk(sk);
    struct sock *nsk;

2
你可以从相应的提交中找到答案。在内核源代码目录下使用 git log -S'TCP_NEW_SYN_RECV' -- path/to/file/of/interest 命令查找添加了 TCP_NEW_SYN_RECV 的提交记录。阅读找到的提交信息以获取新定义及其用法的线索。此外,建议您使用 kernel.org 的主线版本库(这个)而不是 GitHub。 - Sam Protsenko
非常好的答案,我明白了,非常感谢。 - YuFeng Shen
1个回答

1
我找到了这个:
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.

源代码,作者提交:http://git.kernel.org/linus/10feb428a504


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接