提交 123ed979 编写于 作者: V Vlad Yasevich

SCTP: Use hashed lookup when looking for an association.

A SCTP endpoint may have a lot of associations on them and walking
the list is fairly inefficient.  Instead, use a hashed lookup,
and filter out the hash list based on the endopoing we already have.
Signed-off-by: NVlad Yasevich <vladislav.yasevich@hp.com>
上级 027f6e1a
...@@ -328,24 +328,34 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc( ...@@ -328,24 +328,34 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc(
const union sctp_addr *paddr, const union sctp_addr *paddr,
struct sctp_transport **transport) struct sctp_transport **transport)
{ {
struct sctp_association *asoc = NULL;
struct sctp_transport *t = NULL;
struct sctp_hashbucket *head;
struct sctp_ep_common *epb;
int hash;
int rport; int rport;
struct sctp_association *asoc;
struct list_head *pos;
*transport = NULL;
rport = ntohs(paddr->v4.sin_port); rport = ntohs(paddr->v4.sin_port);
list_for_each(pos, &ep->asocs) { hash = sctp_assoc_hashfn(ep->base.bind_addr.port, rport);
asoc = list_entry(pos, struct sctp_association, asocs); head = &sctp_assoc_hashtable[hash];
if (rport == asoc->peer.port) { read_lock(&head->lock);
*transport = sctp_assoc_lookup_paddr(asoc, paddr); for (epb = head->chain; epb; epb = epb->next) {
asoc = sctp_assoc(epb);
if (*transport) if (asoc->ep != ep || rport != asoc->peer.port)
return asoc; goto next;
t = sctp_assoc_lookup_paddr(asoc, paddr);
if (t) {
*transport = t;
break;
} }
next:
asoc = NULL;
} }
read_unlock(&head->lock);
*transport = NULL; return asoc;
return NULL;
} }
/* Lookup association on an endpoint based on a peer address. BH-safe. */ /* Lookup association on an endpoint based on a peer address. BH-safe. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册