aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index c1941276f6e3..ba1add0b13c3 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3719,12 +3719,9 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3719 sp->hmac = NULL; 3719 sp->hmac = NULL;
3720 3720
3721 SCTP_DBG_OBJCNT_INC(sock); 3721 SCTP_DBG_OBJCNT_INC(sock);
3722 percpu_counter_inc(&sctp_sockets_allocated);
3723
3724 /* Set socket backlog limit. */
3725 sk->sk_backlog.limit = sysctl_sctp_rmem[1];
3726 3722
3727 local_bh_disable(); 3723 local_bh_disable();
3724 percpu_counter_inc(&sctp_sockets_allocated);
3728 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 3725 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
3729 local_bh_enable(); 3726 local_bh_enable();
3730 3727
@@ -3741,8 +3738,8 @@ SCTP_STATIC void sctp_destroy_sock(struct sock *sk)
3741 /* Release our hold on the endpoint. */ 3738 /* Release our hold on the endpoint. */
3742 ep = sctp_sk(sk)->ep; 3739 ep = sctp_sk(sk)->ep;
3743 sctp_endpoint_free(ep); 3740 sctp_endpoint_free(ep);
3744 percpu_counter_dec(&sctp_sockets_allocated);
3745 local_bh_disable(); 3741 local_bh_disable();
3742 percpu_counter_dec(&sctp_sockets_allocated);
3746 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); 3743 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
3747 local_bh_enable(); 3744 local_bh_enable();
3748} 3745}
@@ -4387,7 +4384,7 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
4387 transports) { 4384 transports) {
4388 memcpy(&temp, &from->ipaddr, sizeof(temp)); 4385 memcpy(&temp, &from->ipaddr, sizeof(temp));
4389 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); 4386 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4390 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; 4387 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
4391 if (space_left < addrlen) 4388 if (space_left < addrlen)
4392 return -ENOMEM; 4389 return -ENOMEM;
4393 if (copy_to_user(to, &temp, addrlen)) 4390 if (copy_to_user(to, &temp, addrlen))
@@ -5702,7 +5699,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
5702 struct sctp_sock *sp = sctp_sk(sk); 5699 struct sctp_sock *sp = sctp_sk(sk);
5703 unsigned int mask; 5700 unsigned int mask;
5704 5701
5705 poll_wait(file, sk->sk_sleep, wait); 5702 poll_wait(file, sk_sleep(sk), wait);
5706 5703
5707 /* A TCP-style listening socket becomes readable when the accept queue 5704 /* A TCP-style listening socket becomes readable when the accept queue
5708 * is not empty. 5705 * is not empty.
@@ -5943,7 +5940,7 @@ static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p)
5943 int error; 5940 int error;
5944 DEFINE_WAIT(wait); 5941 DEFINE_WAIT(wait);
5945 5942
5946 prepare_to_wait_exclusive(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 5943 prepare_to_wait_exclusive(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
5947 5944
5948 /* Socket errors? */ 5945 /* Socket errors? */
5949 error = sock_error(sk); 5946 error = sock_error(sk);
@@ -5980,14 +5977,14 @@ static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p)
5980 sctp_lock_sock(sk); 5977 sctp_lock_sock(sk);
5981 5978
5982ready: 5979ready:
5983 finish_wait(sk->sk_sleep, &wait); 5980 finish_wait(sk_sleep(sk), &wait);
5984 return 0; 5981 return 0;
5985 5982
5986interrupted: 5983interrupted:
5987 error = sock_intr_errno(*timeo_p); 5984 error = sock_intr_errno(*timeo_p);
5988 5985
5989out: 5986out:
5990 finish_wait(sk->sk_sleep, &wait); 5987 finish_wait(sk_sleep(sk), &wait);
5991 *err = error; 5988 *err = error;
5992 return error; 5989 return error;
5993} 5990}
@@ -6061,14 +6058,14 @@ static void __sctp_write_space(struct sctp_association *asoc)
6061 wake_up_interruptible(&asoc->wait); 6058 wake_up_interruptible(&asoc->wait);
6062 6059
6063 if (sctp_writeable(sk)) { 6060 if (sctp_writeable(sk)) {
6064 if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) 6061 if (sk_sleep(sk) && waitqueue_active(sk_sleep(sk)))
6065 wake_up_interruptible(sk->sk_sleep); 6062 wake_up_interruptible(sk_sleep(sk));
6066 6063
6067 /* Note that we try to include the Async I/O support 6064 /* Note that we try to include the Async I/O support
6068 * here by modeling from the current TCP/UDP code. 6065 * here by modeling from the current TCP/UDP code.
6069 * We have not tested with it yet. 6066 * We have not tested with it yet.
6070 */ 6067 */
6071 if (sock->fasync_list && 6068 if (sock->wq->fasync_list &&
6072 !(sk->sk_shutdown & SEND_SHUTDOWN)) 6069 !(sk->sk_shutdown & SEND_SHUTDOWN))
6073 sock_wake_async(sock, 6070 sock_wake_async(sock,
6074 SOCK_WAKE_SPACE, POLL_OUT); 6071 SOCK_WAKE_SPACE, POLL_OUT);
@@ -6188,6 +6185,19 @@ do_nonblock:
6188 goto out; 6185 goto out;
6189} 6186}
6190 6187
6188void sctp_data_ready(struct sock *sk, int len)
6189{
6190 struct socket_wq *wq;
6191
6192 rcu_read_lock();
6193 wq = rcu_dereference(sk->sk_wq);
6194 if (wq_has_sleeper(wq))
6195 wake_up_interruptible_sync_poll(&wq->wait, POLLIN |
6196 POLLRDNORM | POLLRDBAND);
6197 sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
6198 rcu_read_unlock();
6199}
6200
6191/* If socket sndbuf has changed, wake up all per association waiters. */ 6201/* If socket sndbuf has changed, wake up all per association waiters. */
6192void sctp_write_space(struct sock *sk) 6202void sctp_write_space(struct sock *sk)
6193{ 6203{
@@ -6296,7 +6306,7 @@ static int sctp_wait_for_accept(struct sock *sk, long timeo)
6296 6306
6297 6307
6298 for (;;) { 6308 for (;;) {
6299 prepare_to_wait_exclusive(sk->sk_sleep, &wait, 6309 prepare_to_wait_exclusive(sk_sleep(sk), &wait,
6300 TASK_INTERRUPTIBLE); 6310 TASK_INTERRUPTIBLE);
6301 6311
6302 if (list_empty(&ep->asocs)) { 6312 if (list_empty(&ep->asocs)) {
@@ -6322,7 +6332,7 @@ static int sctp_wait_for_accept(struct sock *sk, long timeo)
6322 break; 6332 break;
6323 } 6333 }
6324 6334
6325 finish_wait(sk->sk_sleep, &wait); 6335 finish_wait(sk_sleep(sk), &wait);
6326 6336
6327 return err; 6337 return err;
6328} 6338}
@@ -6332,7 +6342,7 @@ static void sctp_wait_for_close(struct sock *sk, long timeout)
6332 DEFINE_WAIT(wait); 6342 DEFINE_WAIT(wait);
6333 6343
6334 do { 6344 do {
6335 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); 6345 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
6336 if (list_empty(&sctp_sk(sk)->ep->asocs)) 6346 if (list_empty(&sctp_sk(sk)->ep->asocs))
6337 break; 6347 break;
6338 sctp_release_sock(sk); 6348 sctp_release_sock(sk);
@@ -6340,7 +6350,7 @@ static void sctp_wait_for_close(struct sock *sk, long timeout)
6340 sctp_lock_sock(sk); 6350 sctp_lock_sock(sk);
6341 } while (!signal_pending(current) && timeout); 6351 } while (!signal_pending(current) && timeout);
6342 6352
6343 finish_wait(sk->sk_sleep, &wait); 6353 finish_wait(sk_sleep(sk), &wait);
6344} 6354}
6345 6355
6346static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk) 6356static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk)