aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2007-06-14 16:06:21 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-06-14 16:06:21 -0400
commit559f0a2857f1d1a93c4f398d2775e228fdb8b8ce (patch)
treeab30bcb58b49c17aa40942ebfb446a8e3a26deac /net/sctp/socket.c
parent74235a25c673f80147c1f975304888e8212a14d5 (diff)
parent06ad391919b2078ec2e012f0593014b88e7a6c4e (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/vxy/lksctp-dev
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 4dcdabf56473..6edaaa009d62 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -333,12 +333,19 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
333 if (!sp->pf->bind_verify(sp, addr)) 333 if (!sp->pf->bind_verify(sp, addr))
334 return -EADDRNOTAVAIL; 334 return -EADDRNOTAVAIL;
335 335
336 /* We must either be unbound, or bind to the same port. */ 336 /* We must either be unbound, or bind to the same port.
337 if (bp->port && (snum != bp->port)) { 337 * It's OK to allow 0 ports if we are already bound.
338 SCTP_DEBUG_PRINTK("sctp_do_bind:" 338 * We'll just inhert an already bound port in this case
339 */
340 if (bp->port) {
341 if (!snum)
342 snum = bp->port;
343 else if (snum != bp->port) {
344 SCTP_DEBUG_PRINTK("sctp_do_bind:"
339 " New port %d does not match existing port " 345 " New port %d does not match existing port "
340 "%d.\n", snum, bp->port); 346 "%d.\n", snum, bp->port);
341 return -EINVAL; 347 return -EINVAL;
348 }
342 } 349 }
343 350
344 if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE)) 351 if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
@@ -1655,6 +1662,9 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1655 goto out_free; 1662 goto out_free;
1656 } 1663 }
1657 1664
1665 if (asoc->pmtu_pending)
1666 sctp_assoc_pending_pmtu(asoc);
1667
1658 /* If fragmentation is disabled and the message length exceeds the 1668 /* If fragmentation is disabled and the message length exceeds the
1659 * association fragmentation point, return EMSGSIZE. The I-D 1669 * association fragmentation point, return EMSGSIZE. The I-D
1660 * does not specify what this error is, but this looks like 1670 * does not specify what this error is, but this looks like
@@ -3550,6 +3560,7 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,
3550 struct sock *sk = asoc->base.sk; 3560 struct sock *sk = asoc->base.sk;
3551 struct socket *sock; 3561 struct socket *sock;
3552 struct inet_sock *inetsk; 3562 struct inet_sock *inetsk;
3563 struct sctp_af *af;
3553 int err = 0; 3564 int err = 0;
3554 3565
3555 /* An association cannot be branched off from an already peeled-off 3566 /* An association cannot be branched off from an already peeled-off
@@ -3571,8 +3582,9 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,
3571 /* Make peeled-off sockets more like 1-1 accepted sockets. 3582 /* Make peeled-off sockets more like 1-1 accepted sockets.
3572 * Set the daddr and initialize id to something more random 3583 * Set the daddr and initialize id to something more random
3573 */ 3584 */
3585 af = sctp_get_af_specific(asoc->peer.primary_addr.sa.sa_family);
3586 af->to_sk_daddr(&asoc->peer.primary_addr, sk);
3574 inetsk = inet_sk(sock->sk); 3587 inetsk = inet_sk(sock->sk);
3575 inetsk->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr;
3576 inetsk->id = asoc->next_tsn ^ jiffies; 3588 inetsk->id = asoc->next_tsn ^ jiffies;
3577 3589
3578 *sockp = sock; 3590 *sockp = sock;
@@ -4343,11 +4355,12 @@ copy_getaddrs:
4343 err = -EFAULT; 4355 err = -EFAULT;
4344 goto error; 4356 goto error;
4345 } 4357 }
4346 if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) 4358 if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) {
4347 return -EFAULT; 4359 err = -EFAULT;
4360 goto error;
4361 }
4348 if (put_user(bytes_copied, optlen)) 4362 if (put_user(bytes_copied, optlen))
4349 return -EFAULT; 4363 err = -EFAULT;
4350
4351error: 4364error:
4352 kfree(addrs); 4365 kfree(addrs);
4353 return err; 4366 return err;