aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /net/sctp/socket.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c390
1 files changed, 40 insertions, 350 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 3a95fcb17a9e..44a1ab03a3f0 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -67,6 +67,7 @@
67#include <linux/poll.h> 67#include <linux/poll.h>
68#include <linux/init.h> 68#include <linux/init.h>
69#include <linux/crypto.h> 69#include <linux/crypto.h>
70#include <linux/slab.h>
70 71
71#include <net/ip.h> 72#include <net/ip.h>
72#include <net/icmp.h> 73#include <net/icmp.h>
@@ -394,7 +395,7 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
394 395
395 /* Refresh ephemeral port. */ 396 /* Refresh ephemeral port. */
396 if (!bp->port) 397 if (!bp->port)
397 bp->port = inet_sk(sk)->num; 398 bp->port = inet_sk(sk)->inet_num;
398 399
399 /* Add the address to the bind address list. 400 /* Add the address to the bind address list.
400 * Use GFP_ATOMIC since BHs will be disabled. 401 * Use GFP_ATOMIC since BHs will be disabled.
@@ -403,7 +404,7 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
403 404
404 /* Copy back into socket for getsockname() use. */ 405 /* Copy back into socket for getsockname() use. */
405 if (!ret) { 406 if (!ret) {
406 inet_sk(sk)->sport = htons(inet_sk(sk)->num); 407 inet_sk(sk)->inet_sport = htons(inet_sk(sk)->inet_num);
407 af->to_sk_saddr(addr, sk); 408 af->to_sk_saddr(addr, sk);
408 } 409 }
409 410
@@ -1117,7 +1118,7 @@ static int __sctp_connect(struct sock* sk,
1117 } 1118 }
1118 1119
1119 /* Initialize sk's dport and daddr for getpeername() */ 1120 /* Initialize sk's dport and daddr for getpeername() */
1120 inet_sk(sk)->dport = htons(asoc->peer.port); 1121 inet_sk(sk)->inet_dport = htons(asoc->peer.port);
1121 af = sctp_get_af_specific(sa_addr->sa.sa_family); 1122 af = sctp_get_af_specific(sa_addr->sa.sa_family);
1122 af->to_sk_daddr(sa_addr, sk); 1123 af->to_sk_daddr(sa_addr, sk);
1123 sk->sk_err = 0; 1124 sk->sk_err = 0;
@@ -1968,7 +1969,7 @@ SCTP_STATIC int sctp_recvmsg(struct kiocb *iocb, struct sock *sk,
1968 if (err) 1969 if (err)
1969 goto out_free; 1970 goto out_free;
1970 1971
1971 sock_recv_timestamp(msg, sk, skb); 1972 sock_recv_ts_and_drops(msg, sk, skb);
1972 if (sctp_ulpevent_is_notification(event)) { 1973 if (sctp_ulpevent_is_notification(event)) {
1973 msg->msg_flags |= MSG_NOTIFICATION; 1974 msg->msg_flags |= MSG_NOTIFICATION;
1974 sp->pf->event_msgname(event, msg->msg_name, addr_len); 1975 sp->pf->event_msgname(event, msg->msg_name, addr_len);
@@ -2086,6 +2087,8 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval,
2086 return -EINVAL; 2087 return -EINVAL;
2087 if (copy_from_user(&sp->autoclose, optval, optlen)) 2088 if (copy_from_user(&sp->autoclose, optval, optlen))
2088 return -EFAULT; 2089 return -EFAULT;
2090 /* make sure it won't exceed MAX_SCHEDULE_TIMEOUT */
2091 sp->autoclose = min_t(long, sp->autoclose, MAX_SCHEDULE_TIMEOUT / HZ);
2089 2092
2090 return 0; 2093 return 0;
2091} 2094}
@@ -2311,11 +2314,10 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params,
2311 } 2314 }
2312 } 2315 }
2313 2316
2314 /* Note that unless the spp_flag is set to SPP_PMTUD_ENABLE the value 2317 /* Note that a value of zero indicates the current setting should be
2315 * of this field is ignored. Note also that a value of zero 2318 left unchanged.
2316 * indicates the current setting should be left unchanged.
2317 */ 2319 */
2318 if ((params->spp_flags & SPP_PMTUD_ENABLE) && params->spp_pathmaxrxt) { 2320 if (params->spp_pathmaxrxt) {
2319 if (trans) { 2321 if (trans) {
2320 trans->pathmaxrxt = params->spp_pathmaxrxt; 2322 trans->pathmaxrxt = params->spp_pathmaxrxt;
2321 } else if (asoc) { 2323 } else if (asoc) {
@@ -2354,8 +2356,8 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk,
2354 pmtud_change == SPP_PMTUD || 2356 pmtud_change == SPP_PMTUD ||
2355 sackdelay_change == SPP_SACKDELAY || 2357 sackdelay_change == SPP_SACKDELAY ||
2356 params.spp_sackdelay > 500 || 2358 params.spp_sackdelay > 500 ||
2357 (params.spp_pathmtu 2359 (params.spp_pathmtu &&
2358 && params.spp_pathmtu < SCTP_DEFAULT_MINSEGMENT)) 2360 params.spp_pathmtu < SCTP_DEFAULT_MINSEGMENT))
2359 return -EINVAL; 2361 return -EINVAL;
2360 2362
2361 /* If an address other than INADDR_ANY is specified, and 2363 /* If an address other than INADDR_ANY is specified, and
@@ -3717,9 +3719,12 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3717 sp->hmac = NULL; 3719 sp->hmac = NULL;
3718 3720
3719 SCTP_DBG_OBJCNT_INC(sock); 3721 SCTP_DBG_OBJCNT_INC(sock);
3720 percpu_counter_inc(&sctp_sockets_allocated); 3722
3723 /* Set socket backlog limit. */
3724 sk->sk_backlog.limit = sysctl_sctp_rmem[1];
3721 3725
3722 local_bh_disable(); 3726 local_bh_disable();
3727 percpu_counter_inc(&sctp_sockets_allocated);
3723 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 3728 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
3724 local_bh_enable(); 3729 local_bh_enable();
3725 3730
@@ -3736,8 +3741,8 @@ SCTP_STATIC void sctp_destroy_sock(struct sock *sk)
3736 /* Release our hold on the endpoint. */ 3741 /* Release our hold on the endpoint. */
3737 ep = sctp_sk(sk)->ep; 3742 ep = sctp_sk(sk)->ep;
3738 sctp_endpoint_free(ep); 3743 sctp_endpoint_free(ep);
3739 percpu_counter_dec(&sctp_sockets_allocated);
3740 local_bh_disable(); 3744 local_bh_disable();
3745 percpu_counter_dec(&sctp_sockets_allocated);
3741 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1); 3746 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
3742 local_bh_enable(); 3747 local_bh_enable();
3743} 3748}
@@ -4349,90 +4354,6 @@ static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval
4349 return 0; 4354 return 0;
4350} 4355}
4351 4356
4352static int sctp_getsockopt_peer_addrs_num_old(struct sock *sk, int len,
4353 char __user *optval,
4354 int __user *optlen)
4355{
4356 sctp_assoc_t id;
4357 struct sctp_association *asoc;
4358 struct list_head *pos;
4359 int cnt = 0;
4360
4361 if (len < sizeof(sctp_assoc_t))
4362 return -EINVAL;
4363
4364 if (copy_from_user(&id, optval, sizeof(sctp_assoc_t)))
4365 return -EFAULT;
4366
4367 printk(KERN_WARNING "SCTP: Use of SCTP_GET_PEER_ADDRS_NUM_OLD "
4368 "socket option deprecated\n");
4369 /* For UDP-style sockets, id specifies the association to query. */
4370 asoc = sctp_id2assoc(sk, id);
4371 if (!asoc)
4372 return -EINVAL;
4373
4374 list_for_each(pos, &asoc->peer.transport_addr_list) {
4375 cnt ++;
4376 }
4377
4378 return cnt;
4379}
4380
4381/*
4382 * Old API for getting list of peer addresses. Does not work for 32-bit
4383 * programs running on a 64-bit kernel
4384 */
4385static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len,
4386 char __user *optval,
4387 int __user *optlen)
4388{
4389 struct sctp_association *asoc;
4390 int cnt = 0;
4391 struct sctp_getaddrs_old getaddrs;
4392 struct sctp_transport *from;
4393 void __user *to;
4394 union sctp_addr temp;
4395 struct sctp_sock *sp = sctp_sk(sk);
4396 int addrlen;
4397
4398 if (len < sizeof(struct sctp_getaddrs_old))
4399 return -EINVAL;
4400
4401 len = sizeof(struct sctp_getaddrs_old);
4402
4403 if (copy_from_user(&getaddrs, optval, len))
4404 return -EFAULT;
4405
4406 if (getaddrs.addr_num <= 0) return -EINVAL;
4407
4408 printk(KERN_WARNING "SCTP: Use of SCTP_GET_PEER_ADDRS_OLD "
4409 "socket option deprecated\n");
4410
4411 /* For UDP-style sockets, id specifies the association to query. */
4412 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
4413 if (!asoc)
4414 return -EINVAL;
4415
4416 to = (void __user *)getaddrs.addrs;
4417 list_for_each_entry(from, &asoc->peer.transport_addr_list,
4418 transports) {
4419 memcpy(&temp, &from->ipaddr, sizeof(temp));
4420 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4421 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len;
4422 if (copy_to_user(to, &temp, addrlen))
4423 return -EFAULT;
4424 to += addrlen ;
4425 cnt ++;
4426 if (cnt >= getaddrs.addr_num) break;
4427 }
4428 getaddrs.addr_num = cnt;
4429 if (put_user(len, optlen))
4430 return -EFAULT;
4431 if (copy_to_user(optval, &getaddrs, len))
4432 return -EFAULT;
4433
4434 return 0;
4435}
4436 4357
4437static int sctp_getsockopt_peer_addrs(struct sock *sk, int len, 4358static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
4438 char __user *optval, int __user *optlen) 4359 char __user *optval, int __user *optlen)
@@ -4485,125 +4406,6 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
4485 return 0; 4406 return 0;
4486} 4407}
4487 4408
4488static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len,
4489 char __user *optval,
4490 int __user *optlen)
4491{
4492 sctp_assoc_t id;
4493 struct sctp_bind_addr *bp;
4494 struct sctp_association *asoc;
4495 struct sctp_sockaddr_entry *addr;
4496 int cnt = 0;
4497
4498 if (len < sizeof(sctp_assoc_t))
4499 return -EINVAL;
4500
4501 if (copy_from_user(&id, optval, sizeof(sctp_assoc_t)))
4502 return -EFAULT;
4503
4504 printk(KERN_WARNING "SCTP: Use of SCTP_GET_LOCAL_ADDRS_NUM_OLD "
4505 "socket option deprecated\n");
4506
4507 /*
4508 * For UDP-style sockets, id specifies the association to query.
4509 * If the id field is set to the value '0' then the locally bound
4510 * addresses are returned without regard to any particular
4511 * association.
4512 */
4513 if (0 == id) {
4514 bp = &sctp_sk(sk)->ep->base.bind_addr;
4515 } else {
4516 asoc = sctp_id2assoc(sk, id);
4517 if (!asoc)
4518 return -EINVAL;
4519 bp = &asoc->base.bind_addr;
4520 }
4521
4522 /* If the endpoint is bound to 0.0.0.0 or ::0, count the valid
4523 * addresses from the global local address list.
4524 */
4525 if (sctp_list_single_entry(&bp->address_list)) {
4526 addr = list_entry(bp->address_list.next,
4527 struct sctp_sockaddr_entry, list);
4528 if (sctp_is_any(sk, &addr->a)) {
4529 rcu_read_lock();
4530 list_for_each_entry_rcu(addr,
4531 &sctp_local_addr_list, list) {
4532 if (!addr->valid)
4533 continue;
4534
4535 if ((PF_INET == sk->sk_family) &&
4536 (AF_INET6 == addr->a.sa.sa_family))
4537 continue;
4538
4539 if ((PF_INET6 == sk->sk_family) &&
4540 inet_v6_ipv6only(sk) &&
4541 (AF_INET == addr->a.sa.sa_family))
4542 continue;
4543
4544 cnt++;
4545 }
4546 rcu_read_unlock();
4547 } else {
4548 cnt = 1;
4549 }
4550 goto done;
4551 }
4552
4553 /* Protection on the bound address list is not needed,
4554 * since in the socket option context we hold the socket lock,
4555 * so there is no way that the bound address list can change.
4556 */
4557 list_for_each_entry(addr, &bp->address_list, list) {
4558 cnt ++;
4559 }
4560done:
4561 return cnt;
4562}
4563
4564/* Helper function that copies local addresses to user and returns the number
4565 * of addresses copied.
4566 */
4567static int sctp_copy_laddrs_old(struct sock *sk, __u16 port,
4568 int max_addrs, void *to,
4569 int *bytes_copied)
4570{
4571 struct sctp_sockaddr_entry *addr;
4572 union sctp_addr temp;
4573 int cnt = 0;
4574 int addrlen;
4575
4576 rcu_read_lock();
4577 list_for_each_entry_rcu(addr, &sctp_local_addr_list, list) {
4578 if (!addr->valid)
4579 continue;
4580
4581 if ((PF_INET == sk->sk_family) &&
4582 (AF_INET6 == addr->a.sa.sa_family))
4583 continue;
4584 if ((PF_INET6 == sk->sk_family) &&
4585 inet_v6_ipv6only(sk) &&
4586 (AF_INET == addr->a.sa.sa_family))
4587 continue;
4588 memcpy(&temp, &addr->a, sizeof(temp));
4589 if (!temp.v4.sin_port)
4590 temp.v4.sin_port = htons(port);
4591
4592 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk),
4593 &temp);
4594 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
4595 memcpy(to, &temp, addrlen);
4596
4597 to += addrlen;
4598 *bytes_copied += addrlen;
4599 cnt ++;
4600 if (cnt >= max_addrs) break;
4601 }
4602 rcu_read_unlock();
4603
4604 return cnt;
4605}
4606
4607static int sctp_copy_laddrs(struct sock *sk, __u16 port, void *to, 4409static int sctp_copy_laddrs(struct sock *sk, __u16 port, void *to,
4608 size_t space_left, int *bytes_copied) 4410 size_t space_left, int *bytes_copied)
4609{ 4411{
@@ -4647,112 +4449,6 @@ static int sctp_copy_laddrs(struct sock *sk, __u16 port, void *to,
4647 return cnt; 4449 return cnt;
4648} 4450}
4649 4451
4650/* Old API for getting list of local addresses. Does not work for 32-bit
4651 * programs running on a 64-bit kernel
4652 */
4653static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
4654 char __user *optval, int __user *optlen)
4655{
4656 struct sctp_bind_addr *bp;
4657 struct sctp_association *asoc;
4658 int cnt = 0;
4659 struct sctp_getaddrs_old getaddrs;
4660 struct sctp_sockaddr_entry *addr;
4661 void __user *to;
4662 union sctp_addr temp;
4663 struct sctp_sock *sp = sctp_sk(sk);
4664 int addrlen;
4665 int err = 0;
4666 void *addrs;
4667 void *buf;
4668 int bytes_copied = 0;
4669
4670 if (len < sizeof(struct sctp_getaddrs_old))
4671 return -EINVAL;
4672
4673 len = sizeof(struct sctp_getaddrs_old);
4674 if (copy_from_user(&getaddrs, optval, len))
4675 return -EFAULT;
4676
4677 if (getaddrs.addr_num <= 0 ||
4678 getaddrs.addr_num >= (INT_MAX / sizeof(union sctp_addr)))
4679 return -EINVAL;
4680
4681 printk(KERN_WARNING "SCTP: Use of SCTP_GET_LOCAL_ADDRS_OLD "
4682 "socket option deprecated\n");
4683
4684 /*
4685 * For UDP-style sockets, id specifies the association to query.
4686 * If the id field is set to the value '0' then the locally bound
4687 * addresses are returned without regard to any particular
4688 * association.
4689 */
4690 if (0 == getaddrs.assoc_id) {
4691 bp = &sctp_sk(sk)->ep->base.bind_addr;
4692 } else {
4693 asoc = sctp_id2assoc(sk, getaddrs.assoc_id);
4694 if (!asoc)
4695 return -EINVAL;
4696 bp = &asoc->base.bind_addr;
4697 }
4698
4699 to = getaddrs.addrs;
4700
4701 /* Allocate space for a local instance of packed array to hold all
4702 * the data. We store addresses here first and then put write them
4703 * to the user in one shot.
4704 */
4705 addrs = kmalloc(sizeof(union sctp_addr) * getaddrs.addr_num,
4706 GFP_KERNEL);
4707 if (!addrs)
4708 return -ENOMEM;
4709
4710 /* If the endpoint is bound to 0.0.0.0 or ::0, get the valid
4711 * addresses from the global local address list.
4712 */
4713 if (sctp_list_single_entry(&bp->address_list)) {
4714 addr = list_entry(bp->address_list.next,
4715 struct sctp_sockaddr_entry, list);
4716 if (sctp_is_any(sk, &addr->a)) {
4717 cnt = sctp_copy_laddrs_old(sk, bp->port,
4718 getaddrs.addr_num,
4719 addrs, &bytes_copied);
4720 goto copy_getaddrs;
4721 }
4722 }
4723
4724 buf = addrs;
4725 /* Protection on the bound address list is not needed since
4726 * in the socket option context we hold a socket lock and
4727 * thus the bound address list can't change.
4728 */
4729 list_for_each_entry(addr, &bp->address_list, list) {
4730 memcpy(&temp, &addr->a, sizeof(temp));
4731 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4732 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
4733 memcpy(buf, &temp, addrlen);
4734 buf += addrlen;
4735 bytes_copied += addrlen;
4736 cnt ++;
4737 if (cnt >= getaddrs.addr_num) break;
4738 }
4739
4740copy_getaddrs:
4741 /* copy the entire address list into the user provided space */
4742 if (copy_to_user(to, addrs, bytes_copied)) {
4743 err = -EFAULT;
4744 goto error;
4745 }
4746
4747 /* copy the leading structure back to user */
4748 getaddrs.addr_num = cnt;
4749 if (copy_to_user(optval, &getaddrs, len))
4750 err = -EFAULT;
4751
4752error:
4753 kfree(addrs);
4754 return err;
4755}
4756 4452
4757static int sctp_getsockopt_local_addrs(struct sock *sk, int len, 4453static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
4758 char __user *optval, int __user *optlen) 4454 char __user *optval, int __user *optlen)
@@ -5603,22 +5299,6 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname,
5603 case SCTP_INITMSG: 5299 case SCTP_INITMSG:
5604 retval = sctp_getsockopt_initmsg(sk, len, optval, optlen); 5300 retval = sctp_getsockopt_initmsg(sk, len, optval, optlen);
5605 break; 5301 break;
5606 case SCTP_GET_PEER_ADDRS_NUM_OLD:
5607 retval = sctp_getsockopt_peer_addrs_num_old(sk, len, optval,
5608 optlen);
5609 break;
5610 case SCTP_GET_LOCAL_ADDRS_NUM_OLD:
5611 retval = sctp_getsockopt_local_addrs_num_old(sk, len, optval,
5612 optlen);
5613 break;
5614 case SCTP_GET_PEER_ADDRS_OLD:
5615 retval = sctp_getsockopt_peer_addrs_old(sk, len, optval,
5616 optlen);
5617 break;
5618 case SCTP_GET_LOCAL_ADDRS_OLD:
5619 retval = sctp_getsockopt_local_addrs_old(sk, len, optval,
5620 optlen);
5621 break;
5622 case SCTP_GET_PEER_ADDRS: 5302 case SCTP_GET_PEER_ADDRS:
5623 retval = sctp_getsockopt_peer_addrs(sk, len, optval, 5303 retval = sctp_getsockopt_peer_addrs(sk, len, optval,
5624 optlen); 5304 optlen);
@@ -5861,7 +5541,7 @@ pp_not_found:
5861 */ 5541 */
5862success: 5542success:
5863 if (!sctp_sk(sk)->bind_hash) { 5543 if (!sctp_sk(sk)->bind_hash) {
5864 inet_sk(sk)->num = snum; 5544 inet_sk(sk)->inet_num = snum;
5865 sk_add_bind_node(sk, &pp->owner); 5545 sk_add_bind_node(sk, &pp->owner);
5866 sctp_sk(sk)->bind_hash = pp; 5546 sctp_sk(sk)->bind_hash = pp;
5867 } 5547 }
@@ -5933,7 +5613,7 @@ SCTP_STATIC int sctp_listen_start(struct sock *sk, int backlog)
5933 if (sctp_autobind(sk)) 5613 if (sctp_autobind(sk))
5934 return -EAGAIN; 5614 return -EAGAIN;
5935 } else { 5615 } else {
5936 if (sctp_get_port(sk, inet_sk(sk)->num)) { 5616 if (sctp_get_port(sk, inet_sk(sk)->inet_num)) {
5937 sk->sk_state = SCTP_SS_CLOSED; 5617 sk->sk_state = SCTP_SS_CLOSED;
5938 return -EADDRINUSE; 5618 return -EADDRINUSE;
5939 } 5619 }
@@ -6104,14 +5784,14 @@ static void sctp_bucket_destroy(struct sctp_bind_bucket *pp)
6104static inline void __sctp_put_port(struct sock *sk) 5784static inline void __sctp_put_port(struct sock *sk)
6105{ 5785{
6106 struct sctp_bind_hashbucket *head = 5786 struct sctp_bind_hashbucket *head =
6107 &sctp_port_hashtable[sctp_phashfn(inet_sk(sk)->num)]; 5787 &sctp_port_hashtable[sctp_phashfn(inet_sk(sk)->inet_num)];
6108 struct sctp_bind_bucket *pp; 5788 struct sctp_bind_bucket *pp;
6109 5789
6110 sctp_spin_lock(&head->lock); 5790 sctp_spin_lock(&head->lock);
6111 pp = sctp_sk(sk)->bind_hash; 5791 pp = sctp_sk(sk)->bind_hash;
6112 __sk_del_bind_node(sk); 5792 __sk_del_bind_node(sk);
6113 sctp_sk(sk)->bind_hash = NULL; 5793 sctp_sk(sk)->bind_hash = NULL;
6114 inet_sk(sk)->num = 0; 5794 inet_sk(sk)->inet_num = 0;
6115 sctp_bucket_destroy(pp); 5795 sctp_bucket_destroy(pp);
6116 sctp_spin_unlock(&head->lock); 5796 sctp_spin_unlock(&head->lock);
6117} 5797}
@@ -6138,7 +5818,7 @@ static int sctp_autobind(struct sock *sk)
6138 /* Initialize a local sockaddr structure to INADDR_ANY. */ 5818 /* Initialize a local sockaddr structure to INADDR_ANY. */
6139 af = sctp_sk(sk)->pf->af; 5819 af = sctp_sk(sk)->pf->af;
6140 5820
6141 port = htons(inet_sk(sk)->num); 5821 port = htons(inet_sk(sk)->inet_num);
6142 af->inaddr_any(&autoaddr, port); 5822 af->inaddr_any(&autoaddr, port);
6143 5823
6144 return sctp_do_bind(sk, &autoaddr, af->sockaddr_len); 5824 return sctp_do_bind(sk, &autoaddr, af->sockaddr_len);
@@ -6509,6 +6189,16 @@ do_nonblock:
6509 goto out; 6189 goto out;
6510} 6190}
6511 6191
6192void sctp_data_ready(struct sock *sk, int len)
6193{
6194 read_lock_bh(&sk->sk_callback_lock);
6195 if (sk_has_sleeper(sk))
6196 wake_up_interruptible_sync_poll(sk->sk_sleep, POLLIN |
6197 POLLRDNORM | POLLRDBAND);
6198 sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
6199 read_unlock_bh(&sk->sk_callback_lock);
6200}
6201
6512/* If socket sndbuf has changed, wake up all per association waiters. */ 6202/* If socket sndbuf has changed, wake up all per association waiters. */
6513void sctp_write_space(struct sock *sk) 6203void sctp_write_space(struct sock *sk)
6514{ 6204{
@@ -6683,7 +6373,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
6683 struct sctp_association *asoc) 6373 struct sctp_association *asoc)
6684{ 6374{
6685 struct inet_sock *inet = inet_sk(sk); 6375 struct inet_sock *inet = inet_sk(sk);
6686 struct inet_sock *newinet = inet_sk(newsk); 6376 struct inet_sock *newinet;
6687 6377
6688 newsk->sk_type = sk->sk_type; 6378 newsk->sk_type = sk->sk_type;
6689 newsk->sk_bound_dev_if = sk->sk_bound_dev_if; 6379 newsk->sk_bound_dev_if = sk->sk_bound_dev_if;
@@ -6707,12 +6397,12 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
6707 /* Initialize sk's sport, dport, rcv_saddr and daddr for 6397 /* Initialize sk's sport, dport, rcv_saddr and daddr for
6708 * getsockname() and getpeername() 6398 * getsockname() and getpeername()
6709 */ 6399 */
6710 newinet->sport = inet->sport; 6400 newinet->inet_sport = inet->inet_sport;
6711 newinet->saddr = inet->saddr; 6401 newinet->inet_saddr = inet->inet_saddr;
6712 newinet->rcv_saddr = inet->rcv_saddr; 6402 newinet->inet_rcv_saddr = inet->inet_rcv_saddr;
6713 newinet->dport = htons(asoc->peer.port); 6403 newinet->inet_dport = htons(asoc->peer.port);
6714 newinet->pmtudisc = inet->pmtudisc; 6404 newinet->pmtudisc = inet->pmtudisc;
6715 newinet->id = asoc->next_tsn ^ jiffies; 6405 newinet->inet_id = asoc->next_tsn ^ jiffies;
6716 6406
6717 newinet->uc_ttl = inet->uc_ttl; 6407 newinet->uc_ttl = inet->uc_ttl;
6718 newinet->mc_loop = 1; 6408 newinet->mc_loop = 1;
@@ -6751,13 +6441,13 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
6751 newsp->hmac = NULL; 6441 newsp->hmac = NULL;
6752 6442
6753 /* Hook this new socket in to the bind_hash list. */ 6443 /* Hook this new socket in to the bind_hash list. */
6754 head = &sctp_port_hashtable[sctp_phashfn(inet_sk(oldsk)->num)]; 6444 head = &sctp_port_hashtable[sctp_phashfn(inet_sk(oldsk)->inet_num)];
6755 sctp_local_bh_disable(); 6445 sctp_local_bh_disable();
6756 sctp_spin_lock(&head->lock); 6446 sctp_spin_lock(&head->lock);
6757 pp = sctp_sk(oldsk)->bind_hash; 6447 pp = sctp_sk(oldsk)->bind_hash;
6758 sk_add_bind_node(newsk, &pp->owner); 6448 sk_add_bind_node(newsk, &pp->owner);
6759 sctp_sk(newsk)->bind_hash = pp; 6449 sctp_sk(newsk)->bind_hash = pp;
6760 inet_sk(newsk)->num = inet_sk(oldsk)->num; 6450 inet_sk(newsk)->inet_num = inet_sk(oldsk)->inet_num;
6761 sctp_spin_unlock(&head->lock); 6451 sctp_spin_unlock(&head->lock);
6762 sctp_local_bh_enable(); 6452 sctp_local_bh_enable();
6763 6453