From: Eric Dumazet Date: Mon, 16 Mar 2015 04:12:12 +0000 (-0700) Subject: net: add sk_fullsock() helper X-Git-Url: https://git.stricted.de/?p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git;a=commitdiff_plain;h=1b37e0936815038a348230db69eaf00d2ecf4029 net: add sk_fullsock() helper We have many places where we want to check if a socket is not a timewait or request socket. Use a helper to avoid hard coding this. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller [backported from net-next 1d0ab253872cdd3d8e7913f59c266c7fd01771d0] [lorenzo@google.com: removed TCPF_NEW_SYN_RECV, and added a comment to add it back.] Signed-off-by: Lorenzo Colitti Bug: 24163529 Change-Id: Ibf09017e1ab00af5e6925273117c335d7f515d73 --- diff --git a/include/net/sock.h b/include/net/sock.h index 25001eeba49..8fda4597ceb 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -77,6 +77,7 @@ #include #include #include +#include #define TCP_BACKLOG_SCALE 4 @@ -2286,6 +2287,15 @@ static inline struct sock *skb_steal_sock(struct sk_buff *skb) return NULL; } +/* This helper checks if a socket is a full socket, + * ie _not_ a timewait or request socket. + * TODO: Check for TCPF_NEW_SYN_RECV when that starts to exist. + */ +static inline bool sk_fullsock(const struct sock *sk) +{ + return (1 << sk->sk_state) & ~(TCPF_TIME_WAIT); +} + extern void sock_enable_timestamp(struct sock *sk, int flag); extern int sock_get_timestamp(struct sock *, struct timeval __user *); extern int sock_get_timestampns(struct sock *, struct timespec __user *);