diff options
Diffstat (limited to 'net/sctp/endpointola.c')
-rw-r--r-- | net/sctp/endpointola.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index 2d2d81ef4a69..de6f505d6ff8 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c | |||
@@ -328,24 +328,35 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc( | |||
328 | const union sctp_addr *paddr, | 328 | const union sctp_addr *paddr, |
329 | struct sctp_transport **transport) | 329 | struct sctp_transport **transport) |
330 | { | 330 | { |
331 | struct sctp_association *asoc = NULL; | ||
332 | struct sctp_transport *t = NULL; | ||
333 | struct sctp_hashbucket *head; | ||
334 | struct sctp_ep_common *epb; | ||
335 | struct hlist_node *node; | ||
336 | int hash; | ||
331 | int rport; | 337 | int rport; |
332 | struct sctp_association *asoc; | ||
333 | struct list_head *pos; | ||
334 | 338 | ||
339 | *transport = NULL; | ||
335 | rport = ntohs(paddr->v4.sin_port); | 340 | rport = ntohs(paddr->v4.sin_port); |
336 | 341 | ||
337 | list_for_each(pos, &ep->asocs) { | 342 | hash = sctp_assoc_hashfn(ep->base.bind_addr.port, rport); |
338 | asoc = list_entry(pos, struct sctp_association, asocs); | 343 | head = &sctp_assoc_hashtable[hash]; |
339 | if (rport == asoc->peer.port) { | 344 | read_lock(&head->lock); |
340 | *transport = sctp_assoc_lookup_paddr(asoc, paddr); | 345 | sctp_for_each_hentry(epb, node, &head->chain) { |
341 | 346 | asoc = sctp_assoc(epb); | |
342 | if (*transport) | 347 | if (asoc->ep != ep || rport != asoc->peer.port) |
343 | return asoc; | 348 | goto next; |
349 | |||
350 | t = sctp_assoc_lookup_paddr(asoc, paddr); | ||
351 | if (t) { | ||
352 | *transport = t; | ||
353 | break; | ||
344 | } | 354 | } |
355 | next: | ||
356 | asoc = NULL; | ||
345 | } | 357 | } |
346 | 358 | read_unlock(&head->lock); | |
347 | *transport = NULL; | 359 | return asoc; |
348 | return NULL; | ||
349 | } | 360 | } |
350 | 361 | ||
351 | /* Lookup association on an endpoint based on a peer address. BH-safe. */ | 362 | /* Lookup association on an endpoint based on a peer address. BH-safe. */ |