From: Vlad Yasevich <vladislav.yasevich@hp.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, lksctp-developers@lists.sourceforge.net
Subject: Re: [PATCH 08/13] SCTP: Use hashed lookup when looking for an association.
Date: Fri, 09 Nov 2007 11:48:12 -0500 [thread overview]
Message-ID: <47348F4C.8030504@hp.com> (raw)
In-Reply-To: <11944575913296-git-send-email-vladislav.yasevich@hp.com>
Vlad Yasevich wrote:
> 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 endopoint we already have.
This one is missing an unlock. Will send an update shortly.
-vlad
>
> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
> ---
> net/sctp/endpointola.c | 33 +++++++++++++++++++++------------
> 1 files changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
> index 2d2d81e..f38fa0f 100644
> --- a/net/sctp/endpointola.c
> +++ b/net/sctp/endpointola.c
> @@ -328,24 +328,33 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc(
> const union sctp_addr *paddr,
> 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;
> - struct sctp_association *asoc;
> - struct list_head *pos;
>
> + *transport = NULL;
> rport = ntohs(paddr->v4.sin_port);
>
> - list_for_each(pos, &ep->asocs) {
> - asoc = list_entry(pos, struct sctp_association, asocs);
> - if (rport == asoc->peer.port) {
> - *transport = sctp_assoc_lookup_paddr(asoc, paddr);
> -
> - if (*transport)
> - return asoc;
> + hash = sctp_assoc_hashfn(ep->base.bind_addr.port, rport);
> + head = &sctp_assoc_hashtable[hash];
> + read_lock(&head->lock);
> + for (epb = head->chain; epb; epb = epb->next) {
> + asoc = sctp_assoc(epb);
> + if (asoc->ep != ep || rport != asoc->peer.port)
> + goto next;
> +
> + t = sctp_assoc_lookup_paddr(asoc, paddr);
> + if (t) {
> + *transport = t;
> + break;
> }
> +next:
> + asoc = NULL;
> }
> -
> - *transport = NULL;
> - return NULL;
> + return asoc;
> }
>
> /* Lookup association on an endpoint based on a peer address. BH-safe. */
next prev parent reply other threads:[~2007-11-09 16:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-07 17:46 [GIT PATCHES 0/13] SCTP fixes Vlad Yasevich
2007-11-07 17:46 ` [PATCH 01/13] SCTP : Fix bad formatted comment in outqueue.c Vlad Yasevich
2007-11-07 17:46 ` [PATCH 02/13] SCTP : Fix to process bundled ASCONF chunk correctly Vlad Yasevich
2007-11-07 17:46 ` [PATCH 03/13] SCTP: Fix difference cases of retransmit Vlad Yasevich
2007-11-07 17:46 ` [PATCH 04/13] SCTP: Update RCU handling during the ADD-IP case Vlad Yasevich
2007-11-07 17:46 ` [PATCH 05/13] SCTP: Correctly disable ADD-IP when AUTH is not supported Vlad Yasevich
2007-11-07 17:46 ` [PATCH 06/13] SCTP: Allow ADD-IP to work with AUTH for backward compatibility Vlad Yasevich
2007-11-07 17:46 ` [PATCH 07/13] SCTP: Fix a potential race between timers and receive path Vlad Yasevich
2007-11-07 17:46 ` [PATCH 08/13] SCTP: Use hashed lookup when looking for an association Vlad Yasevich
2007-11-09 16:48 ` Vlad Yasevich [this message]
2007-11-07 17:46 ` [PATCH 09/13] SCTP: Convert custom hash lists to use hlist Vlad Yasevich
2007-11-07 17:46 ` [PATCH 10/13] SCTP: Make sctp_verify_param return multiple indications Vlad Yasevich
2007-11-07 17:46 ` [PATCH 11/13] SCTP: Fix PR-SCTP to deliver all the accumulated ordered chunks Vlad Yasevich
2007-11-07 17:46 ` [PATCH 12/13] SCTP: Clean-up some defines for regressions tests Vlad Yasevich
2007-11-07 17:46 ` [PATCH 13/13] SCTP: Always flush the queue when uncorcking Vlad Yasevich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47348F4C.8030504@hp.com \
--to=vladislav.yasevich@hp.com \
--cc=davem@davemloft.net \
--cc=lksctp-developers@lists.sourceforge.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).