aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/net/inet_sock.h25
-rw-r--r--include/net/sock.h25
2 files changed, 24 insertions, 26 deletions
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index a3431a4ff9cc..0a671c32d6b9 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -290,9 +290,32 @@ static inline void inet_sk_copy_descendant(struct sock *sk_to,
290#endif 290#endif
291 291
292int inet_sk_rebuild_header(struct sock *sk); 292int inet_sk_rebuild_header(struct sock *sk);
293void inet_sk_set_state(struct sock *sk, int state); 293
294/**
295 * inet_sk_state_load - read sk->sk_state for lockless contexts
296 * @sk: socket pointer
297 *
298 * Paired with inet_sk_state_store(). Used in places we don't hold socket lock:
299 * tcp_diag_get_info(), tcp_get_info(), tcp_poll(), get_tcp4_sock() ...
300 */
301static inline int inet_sk_state_load(const struct sock *sk)
302{
303 /* state change might impact lockless readers. */
304 return smp_load_acquire(&sk->sk_state);
305}
306
307/**
308 * inet_sk_state_store - update sk->sk_state
309 * @sk: socket pointer
310 * @newstate: new state
311 *
312 * Paired with inet_sk_state_load(). Should be used in contexts where
313 * state change might impact lockless readers.
314 */
294void inet_sk_state_store(struct sock *sk, int newstate); 315void inet_sk_state_store(struct sock *sk, int newstate);
295 316
317void inet_sk_set_state(struct sock *sk, int state);
318
296static inline unsigned int __inet_ehashfn(const __be32 laddr, 319static inline unsigned int __inet_ehashfn(const __be32 laddr,
297 const __u16 lport, 320 const __u16 lport,
298 const __be32 faddr, 321 const __be32 faddr,
diff --git a/include/net/sock.h b/include/net/sock.h
index 0a32f3ce381c..6c1db823f8b9 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2333,31 +2333,6 @@ static inline bool sk_listener(const struct sock *sk)
2333 return (1 << sk->sk_state) & (TCPF_LISTEN | TCPF_NEW_SYN_RECV); 2333 return (1 << sk->sk_state) & (TCPF_LISTEN | TCPF_NEW_SYN_RECV);
2334} 2334}
2335 2335
2336/**
2337 * sk_state_load - read sk->sk_state for lockless contexts
2338 * @sk: socket pointer
2339 *
2340 * Paired with sk_state_store(). Used in places we do not hold socket lock :
2341 * tcp_diag_get_info(), tcp_get_info(), tcp_poll(), get_tcp4_sock() ...
2342 */
2343static inline int sk_state_load(const struct sock *sk)
2344{
2345 return smp_load_acquire(&sk->sk_state);
2346}
2347
2348/**
2349 * sk_state_store - update sk->sk_state
2350 * @sk: socket pointer
2351 * @newstate: new state
2352 *
2353 * Paired with sk_state_load(). Should be used in contexts where
2354 * state change might impact lockless readers.
2355 */
2356static inline void sk_state_store(struct sock *sk, int newstate)
2357{
2358 smp_store_release(&sk->sk_state, newstate);
2359}
2360
2361void sock_enable_timestamp(struct sock *sk, int flag); 2336void sock_enable_timestamp(struct sock *sk, int flag);
2362int sock_get_timestamp(struct sock *, struct timeval __user *); 2337int sock_get_timestamp(struct sock *, struct timeval __user *);
2363int sock_get_timestampns(struct sock *, struct timespec __user *); 2338int sock_get_timestampns(struct sock *, struct timespec __user *);