diff options
author | Yafang Shao <laoar.shao@gmail.com> | 2018-04-22 15:50:04 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-04-23 17:56:44 +0200 |
commit | c6849a3ac17e336811f1d5bba991d2a9bdc47af1 (patch) | |
tree | b7348427ce20d56554deaabba280b190f46d9cb1 /net/ipv4/tcp_input.c | |
parent | Merge branch 'fib-rules-extack-support' (diff) | |
download | linux-c6849a3ac17e336811f1d5bba991d2a9bdc47af1.tar.xz linux-c6849a3ac17e336811f1d5bba991d2a9bdc47af1.zip |
net: init sk_cookie for inet socket
With sk_cookie we can identify a socket, that is very helpful for
traceing and statistic, i.e. tcp tracepiont and ebpf.
So we'd better init it by default for inet socket.
When using it, we just need call atomic64_read(&sk->sk_cookie).
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_input.c')
-rw-r--r-- | net/ipv4/tcp_input.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 5a17cfc75326..17b78582ba63 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -78,6 +78,7 @@ #include <linux/errqueue.h> #include <trace/events/tcp.h> #include <linux/static_key.h> +#include <linux/sock_diag.h> int sysctl_tcp_max_orphans __read_mostly = NR_FILE; @@ -6190,10 +6191,15 @@ struct request_sock *inet_reqsk_alloc(const struct request_sock_ops *ops, #if IS_ENABLED(CONFIG_IPV6) ireq->pktopts = NULL; #endif - atomic64_set(&ireq->ir_cookie, 0); ireq->ireq_state = TCP_NEW_SYN_RECV; write_pnet(&ireq->ireq_net, sock_net(sk_listener)); ireq->ireq_family = sk_listener->sk_family; + + BUILD_BUG_ON(offsetof(struct inet_request_sock, ir_cookie) != + offsetof(struct sock, sk_cookie)); + BUILD_BUG_ON(offsetof(struct inet_request_sock, ireq_net) != + offsetof(struct sock, sk_net)); + sock_init_cookie((struct sock *)ireq); } return req; |