diff options
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r-- | net/sctp/socket.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index d370c945a757..a5b6e559451e 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)) |