Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 103646
b: refs/heads/master
c: 4e54064
h: refs/heads/master
v: v3
  • Loading branch information
Vlad Yasevich authored and David S. Miller committed Jul 19, 2008
1 parent 278be59 commit f44f404
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 23b29ed80bd7184398317a111dc488605cb66c7f
refs/heads/master: 4e54064e0a13b7a7d4a481123c1783f770538e30
25 changes: 16 additions & 9 deletions trunk/net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,19 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
if (snum && snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
return -EACCES;

/* See if the address matches any of the addresses we may have
* already bound before checking against other endpoints.
*/
if (sctp_bind_addr_match(bp, addr, sp))
return -EINVAL;

/* Make sure we are allowed to bind here.
* The function sctp_get_port_local() does duplicate address
* detection.
*/
addr->v4.sin_port = htons(snum);
if ((ret = sctp_get_port_local(sk, addr))) {
if (ret == (long) sk) {
/* This endpoint has a conflicting address. */
return -EINVAL;
} else {
return -EADDRINUSE;
}
return -EADDRINUSE;
}

/* Refresh ephemeral port. */
Expand Down Expand Up @@ -5584,8 +5585,9 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
struct sctp_endpoint *ep2;
ep2 = sctp_sk(sk2)->ep;

if (reuse && sk2->sk_reuse &&
sk2->sk_state != SCTP_SS_LISTENING)
if (sk == sk2 ||
(reuse && sk2->sk_reuse &&
sk2->sk_state != SCTP_SS_LISTENING))
continue;

if (sctp_bind_addr_conflict(&ep2->base.bind_addr, addr,
Expand Down Expand Up @@ -5702,8 +5704,13 @@ SCTP_STATIC int sctp_seqpacket_listen(struct sock *sk, int backlog)
if (!ep->base.bind_addr.port) {
if (sctp_autobind(sk))
return -EAGAIN;
} else
} else {
if (sctp_get_port(sk, inet_sk(sk)->num)) {
sk->sk_state = SCTP_SS_CLOSED;
return -EADDRINUSE;
}
sctp_sk(sk)->bind_hash->fastreuse = 0;
}

sctp_hash_endpoint(ep);
return 0;
Expand Down

0 comments on commit f44f404

Please sign in to comment.