aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/sock.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h65
1 files changed, 36 insertions, 29 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 7a7b14e9628a..169c92afcafa 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -72,6 +72,7 @@
72#include <net/tcp_states.h> 72#include <net/tcp_states.h>
73#include <linux/net_tstamp.h> 73#include <linux/net_tstamp.h>
74#include <net/smc.h> 74#include <net/smc.h>
75#include <net/l3mdev.h>
75 76
76/* 77/*
77 * This structure really needs to be cleaned up. 78 * This structure really needs to be cleaned up.
@@ -1108,6 +1109,8 @@ struct proto {
1108 struct kmem_cache *slab; 1109 struct kmem_cache *slab;
1109 unsigned int obj_size; 1110 unsigned int obj_size;
1110 slab_flags_t slab_flags; 1111 slab_flags_t slab_flags;
1112 size_t useroffset; /* Usercopy region offset */
1113 size_t usersize; /* Usercopy region size */
1111 1114
1112 struct percpu_counter *orphan_count; 1115 struct percpu_counter *orphan_count;
1113 1116
@@ -1262,6 +1265,7 @@ proto_memory_pressure(struct proto *prot)
1262/* Called with local bh disabled */ 1265/* Called with local bh disabled */
1263void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc); 1266void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc);
1264int sock_prot_inuse_get(struct net *net, struct proto *proto); 1267int sock_prot_inuse_get(struct net *net, struct proto *proto);
1268int sock_inuse_get(struct net *net);
1265#else 1269#else
1266static inline void sock_prot_inuse_add(struct net *net, struct proto *prot, 1270static inline void sock_prot_inuse_add(struct net *net, struct proto *prot,
1267 int inc) 1271 int inc)
@@ -1445,10 +1449,8 @@ do { \
1445} while (0) 1449} while (0)
1446 1450
1447#ifdef CONFIG_LOCKDEP 1451#ifdef CONFIG_LOCKDEP
1448static inline bool lockdep_sock_is_held(const struct sock *csk) 1452static inline bool lockdep_sock_is_held(const struct sock *sk)
1449{ 1453{
1450 struct sock *sk = (struct sock *)csk;
1451
1452 return lockdep_is_held(&sk->sk_lock) || 1454 return lockdep_is_held(&sk->sk_lock) ||
1453 lockdep_is_held(&sk->sk_lock.slock); 1455 lockdep_is_held(&sk->sk_lock.slock);
1454} 1456}
@@ -1583,7 +1585,7 @@ int sock_no_connect(struct socket *, struct sockaddr *, int, int);
1583int sock_no_socketpair(struct socket *, struct socket *); 1585int sock_no_socketpair(struct socket *, struct socket *);
1584int sock_no_accept(struct socket *, struct socket *, int, bool); 1586int sock_no_accept(struct socket *, struct socket *, int, bool);
1585int sock_no_getname(struct socket *, struct sockaddr *, int *, int); 1587int sock_no_getname(struct socket *, struct sockaddr *, int *, int);
1586unsigned int sock_no_poll(struct file *, struct socket *, 1588__poll_t sock_no_poll(struct file *, struct socket *,
1587 struct poll_table_struct *); 1589 struct poll_table_struct *);
1588int sock_no_ioctl(struct socket *, unsigned int, unsigned long); 1590int sock_no_ioctl(struct socket *, unsigned int, unsigned long);
1589int sock_no_listen(struct socket *, int); 1591int sock_no_listen(struct socket *, int);
@@ -2337,31 +2339,6 @@ static inline bool sk_listener(const struct sock *sk)
2337 return (1 << sk->sk_state) & (TCPF_LISTEN | TCPF_NEW_SYN_RECV); 2339 return (1 << sk->sk_state) & (TCPF_LISTEN | TCPF_NEW_SYN_RECV);
2338} 2340}
2339 2341
2340/**
2341 * sk_state_load - read sk->sk_state for lockless contexts
2342 * @sk: socket pointer
2343 *
2344 * Paired with sk_state_store(). Used in places we do not hold socket lock :
2345 * tcp_diag_get_info(), tcp_get_info(), tcp_poll(), get_tcp4_sock() ...
2346 */
2347static inline int sk_state_load(const struct sock *sk)
2348{
2349 return smp_load_acquire(&sk->sk_state);
2350}
2351
2352/**
2353 * sk_state_store - update sk->sk_state
2354 * @sk: socket pointer
2355 * @newstate: new state
2356 *
2357 * Paired with sk_state_load(). Should be used in contexts where
2358 * state change might impact lockless readers.
2359 */
2360static inline void sk_state_store(struct sock *sk, int newstate)
2361{
2362 smp_store_release(&sk->sk_state, newstate);
2363}
2364
2365void sock_enable_timestamp(struct sock *sk, int flag); 2342void sock_enable_timestamp(struct sock *sk, int flag);
2366int sock_get_timestamp(struct sock *, struct timeval __user *); 2343int sock_get_timestamp(struct sock *, struct timeval __user *);
2367int sock_get_timestampns(struct sock *, struct timespec __user *); 2344int sock_get_timestampns(struct sock *, struct timespec __user *);
@@ -2412,4 +2389,34 @@ static inline int sk_get_rmem0(const struct sock *sk, const struct proto *proto)
2412 return *proto->sysctl_rmem; 2389 return *proto->sysctl_rmem;
2413} 2390}
2414 2391
2392/* Default TCP Small queue budget is ~1 ms of data (1sec >> 10)
2393 * Some wifi drivers need to tweak it to get more chunks.
2394 * They can use this helper from their ndo_start_xmit()
2395 */
2396static inline void sk_pacing_shift_update(struct sock *sk, int val)
2397{
2398 if (!sk || !sk_fullsock(sk) || sk->sk_pacing_shift == val)
2399 return;
2400 sk->sk_pacing_shift = val;
2401}
2402
2403/* if a socket is bound to a device, check that the given device
2404 * index is either the same or that the socket is bound to an L3
2405 * master device and the given device index is also enslaved to
2406 * that L3 master
2407 */
2408static inline bool sk_dev_equal_l3scope(struct sock *sk, int dif)
2409{
2410 int mdif;
2411
2412 if (!sk->sk_bound_dev_if || sk->sk_bound_dev_if == dif)
2413 return true;
2414
2415 mdif = l3mdev_master_ifindex_by_index(sock_net(sk), dif);
2416 if (mdif && mdif == sk->sk_bound_dev_if)
2417 return true;
2418
2419 return false;
2420}
2421
2415#endif /* _SOCK_H */ 2422#endif /* _SOCK_H */