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.h41
1 files changed, 11 insertions, 30 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index dc42b44c2aa1..06c5259aff30 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -166,7 +166,7 @@ struct sock_common {
166 * @sk_err: last error 166 * @sk_err: last error
167 * @sk_err_soft: errors that don't cause failure but are the cause of a 167 * @sk_err_soft: errors that don't cause failure but are the cause of a
168 * persistent failure not just 'timed out' 168 * persistent failure not just 'timed out'
169 * @sk_drops: raw drops counter 169 * @sk_drops: raw/udp drops counter
170 * @sk_ack_backlog: current listen backlog 170 * @sk_ack_backlog: current listen backlog
171 * @sk_max_ack_backlog: listen backlog set in listen() 171 * @sk_max_ack_backlog: listen backlog set in listen()
172 * @sk_priority: %SO_PRIORITY setting 172 * @sk_priority: %SO_PRIORITY setting
@@ -524,7 +524,7 @@ struct proto {
524 int (*ioctl)(struct sock *sk, int cmd, 524 int (*ioctl)(struct sock *sk, int cmd,
525 unsigned long arg); 525 unsigned long arg);
526 int (*init)(struct sock *sk); 526 int (*init)(struct sock *sk);
527 int (*destroy)(struct sock *sk); 527 void (*destroy)(struct sock *sk);
528 void (*shutdown)(struct sock *sk, int how); 528 void (*shutdown)(struct sock *sk, int how);
529 int (*setsockopt)(struct sock *sk, int level, 529 int (*setsockopt)(struct sock *sk, int level,
530 int optname, char __user *optval, 530 int optname, char __user *optval,
@@ -565,7 +565,7 @@ struct proto {
565#endif 565#endif
566 566
567 /* Memory pressure */ 567 /* Memory pressure */
568 void (*enter_memory_pressure)(void); 568 void (*enter_memory_pressure)(struct sock *sk);
569 atomic_t *memory_allocated; /* Current allocated memory. */ 569 atomic_t *memory_allocated; /* Current allocated memory. */
570 atomic_t *sockets_allocated; /* Current number of sockets. */ 570 atomic_t *sockets_allocated; /* Current number of sockets. */
571 /* 571 /*
@@ -990,6 +990,11 @@ static inline void sock_put(struct sock *sk)
990extern int sk_receive_skb(struct sock *sk, struct sk_buff *skb, 990extern int sk_receive_skb(struct sock *sk, struct sk_buff *skb,
991 const int nested); 991 const int nested);
992 992
993static inline void sk_set_socket(struct sock *sk, struct socket *sock)
994{
995 sk->sk_socket = sock;
996}
997
993/* Detach socket from process context. 998/* Detach socket from process context.
994 * Announce socket dead, detach it from wait queue and inode. 999 * Announce socket dead, detach it from wait queue and inode.
995 * Note that parent inode held reference count on this struct sock, 1000 * Note that parent inode held reference count on this struct sock,
@@ -1001,7 +1006,7 @@ static inline void sock_orphan(struct sock *sk)
1001{ 1006{
1002 write_lock_bh(&sk->sk_callback_lock); 1007 write_lock_bh(&sk->sk_callback_lock);
1003 sock_set_flag(sk, SOCK_DEAD); 1008 sock_set_flag(sk, SOCK_DEAD);
1004 sk->sk_socket = NULL; 1009 sk_set_socket(sk, NULL);
1005 sk->sk_sleep = NULL; 1010 sk->sk_sleep = NULL;
1006 write_unlock_bh(&sk->sk_callback_lock); 1011 write_unlock_bh(&sk->sk_callback_lock);
1007} 1012}
@@ -1011,7 +1016,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent)
1011 write_lock_bh(&sk->sk_callback_lock); 1016 write_lock_bh(&sk->sk_callback_lock);
1012 sk->sk_sleep = &parent->wait; 1017 sk->sk_sleep = &parent->wait;
1013 parent->sk = sk; 1018 parent->sk = sk;
1014 sk->sk_socket = parent; 1019 sk_set_socket(sk, parent);
1015 security_sock_graft(sk, parent); 1020 security_sock_graft(sk, parent);
1016 write_unlock_bh(&sk->sk_callback_lock); 1021 write_unlock_bh(&sk->sk_callback_lock);
1017} 1022}
@@ -1205,7 +1210,7 @@ static inline struct page *sk_stream_alloc_page(struct sock *sk)
1205 1210
1206 page = alloc_pages(sk->sk_allocation, 0); 1211 page = alloc_pages(sk->sk_allocation, 0);
1207 if (!page) { 1212 if (!page) {
1208 sk->sk_prot->enter_memory_pressure(); 1213 sk->sk_prot->enter_memory_pressure(sk);
1209 sk_stream_moderate_sndbuf(sk); 1214 sk_stream_moderate_sndbuf(sk);
1210 } 1215 }
1211 return page; 1216 return page;
@@ -1331,30 +1336,6 @@ extern int net_msg_warn;
1331#define LIMIT_NETDEBUG(fmt, args...) \ 1336#define LIMIT_NETDEBUG(fmt, args...) \
1332 do { if (net_msg_warn && net_ratelimit()) printk(fmt,##args); } while(0) 1337 do { if (net_msg_warn && net_ratelimit()) printk(fmt,##args); } while(0)
1333 1338
1334/*
1335 * Macros for sleeping on a socket. Use them like this:
1336 *
1337 * SOCK_SLEEP_PRE(sk)
1338 * if (condition)
1339 * schedule();
1340 * SOCK_SLEEP_POST(sk)
1341 *
1342 * N.B. These are now obsolete and were, afaik, only ever used in DECnet
1343 * and when the last use of them in DECnet has gone, I'm intending to
1344 * remove them.
1345 */
1346
1347#define SOCK_SLEEP_PRE(sk) { struct task_struct *tsk = current; \
1348 DECLARE_WAITQUEUE(wait, tsk); \
1349 tsk->state = TASK_INTERRUPTIBLE; \
1350 add_wait_queue((sk)->sk_sleep, &wait); \
1351 release_sock(sk);
1352
1353#define SOCK_SLEEP_POST(sk) tsk->state = TASK_RUNNING; \
1354 remove_wait_queue((sk)->sk_sleep, &wait); \
1355 lock_sock(sk); \
1356 }
1357
1358extern __u32 sysctl_wmem_max; 1339extern __u32 sysctl_wmem_max;
1359extern __u32 sysctl_rmem_max; 1340extern __u32 sysctl_rmem_max;
1360 1341