Fixes two bugs:

1) A lock issue, if we ever had to try again
   we would double lock the INP lock.
2) We were allowing (at wrap) associd 0... which really
   we cannot allow since 0 normally means in most socket
   API calls that we are wishing to effect something on
   the INP not TCB.

Approved by: re, rrs (mentor)
This commit is contained in:
Michael Tuexen 2009-09-16 13:44:12 +00:00
parent 9f1fab5064
commit 04a34c6c34
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/stable/8/; revision=197256

View File

@ -3926,12 +3926,20 @@ sctp_aloc_a_assoc_id(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
struct sctpasochead *head;
struct sctp_tcb *lstcb;
SCTP_INP_WLOCK(inp);
try_again:
if (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) {
/* TSNH */
SCTP_INP_WUNLOCK(inp);
return (0);
}
SCTP_INP_WLOCK(inp);
/*
* We don't allow assoc id to be 0, this is needed otherwise if the
* id were to wrap we would have issues with some socket options.
*/
if (inp->sctp_associd_counter == 0) {
inp->sctp_associd_counter++;
}
id = inp->sctp_associd_counter;
inp->sctp_associd_counter++;
lstcb = sctp_findasoc_ep_asocid_locked(inp, (sctp_assoc_t) id, 0);