From f2980ed522c6771f3019e5c86d4bd7c39a8fac54 Mon Sep 17 00:00:00 2001 From: Vlad Yasevich Date: Tue, 15 May 2007 17:14:58 -0400 Subject: [PATCH] --- yaml --- r: 57721 b: refs/heads/master c: 8b35805693e1915829355723537f99f1b8bc9cc0 h: refs/heads/master i: 57719: 0d5a731d209477919a164692ac49031915940071 v: v3 --- [refs] | 2 +- trunk/net/sctp/socket.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index 95cafbbdc8f3..7add30db1642 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d570ee490fb18220262cfe41284d7aede797ed4f +refs/heads/master: 8b35805693e1915829355723537f99f1b8bc9cc0 diff --git a/trunk/net/sctp/socket.c b/trunk/net/sctp/socket.c index d370c945a757..a5b6e559451e 100644 --- a/trunk/net/sctp/socket.c +++ b/trunk/net/sctp/socket.c @@ -333,12 +333,19 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len) if (!sp->pf->bind_verify(sp, addr)) return -EADDRNOTAVAIL; - /* We must either be unbound, or bind to the same port. */ - if (bp->port && (snum != bp->port)) { - SCTP_DEBUG_PRINTK("sctp_do_bind:" + /* We must either be unbound, or bind to the same port. + * It's OK to allow 0 ports if we are already bound. + * We'll just inhert an already bound port in this case + */ + if (bp->port) { + if (!snum) + snum = bp->port; + else if (snum != bp->port) { + SCTP_DEBUG_PRINTK("sctp_do_bind:" " New port %d does not match existing port " "%d.\n", snum, bp->port); - return -EINVAL; + return -EINVAL; + } } if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))