aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-03-15 21:12:12 -0700
committerMister Oyster <oysterized@gmail.com>2017-04-13 12:32:03 +0200
commita1d299cdf484c409d17b58f827603421d49cdd99 (patch)
treeae9d80e057514da6501dd22f55a0c57531e5d06a /include
parentda0c1b95417f03880070019f35961098311837a2 (diff)
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 <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> [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 <lorenzo@google.com> Bug: 24163529 Change-Id: Ibf09017e1ab00af5e6925273117c335d7f515d73
Diffstat (limited to 'include')
-rw-r--r--include/net/sock.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 8b920ebc4..ae1509860 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -67,6 +67,7 @@
#include <linux/atomic.h>
#include <net/dst.h>
#include <net/checksum.h>
+#include <net/tcp_states.h>
struct cgroup;
struct cgroup_subsys;
@@ -2270,6 +2271,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 *);