Commit de76e695 authored by Vlad Yasevich's avatar Vlad Yasevich Committed by David S. Miller

[SCTP]: Remove temporary associations from backlog and hash.

Every time SCTP creates a temporary association, the stack hashes it,
puts it on a list of endpoint associations and increments the backlog.
However, the lifetime of a temporary association is the processing time
of a current packet and it's destroyed after that. In fact, we don't
really want anyone else finding this association. There is no reason to
do this extra work.
Signed-off-by: default avatarVlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: default avatarSridhar Samudrala <sri@us.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4f444308
...@@ -346,11 +346,18 @@ void sctp_association_free(struct sctp_association *asoc) ...@@ -346,11 +346,18 @@ void sctp_association_free(struct sctp_association *asoc)
struct list_head *pos, *temp; struct list_head *pos, *temp;
int i; int i;
list_del(&asoc->asocs); /* Only real associations count against the endpoint, so
* don't bother for if this is a temporary association.
*/
if (!asoc->temp) {
list_del(&asoc->asocs);
/* Decrement the backlog value for a TCP-style listening socket. */ /* Decrement the backlog value for a TCP-style listening
if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING)) * socket.
sk->sk_ack_backlog--; */
if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))
sk->sk_ack_backlog--;
}
/* Mark as dead, so other users can know this structure is /* Mark as dead, so other users can know this structure is
* going away. * going away.
......
...@@ -144,6 +144,13 @@ void sctp_endpoint_add_asoc(struct sctp_endpoint *ep, ...@@ -144,6 +144,13 @@ void sctp_endpoint_add_asoc(struct sctp_endpoint *ep,
{ {
struct sock *sk = ep->base.sk; struct sock *sk = ep->base.sk;
/* If this is a temporary association, don't bother
* since we'll be removing it shortly and don't
* want anyone to find it anyway.
*/
if (asoc->temp)
return;
/* Now just add it to our list of asocs */ /* Now just add it to our list of asocs */
list_add_tail(&asoc->asocs, &ep->asocs); list_add_tail(&asoc->asocs, &ep->asocs);
......
...@@ -771,6 +771,9 @@ static void __sctp_hash_established(struct sctp_association *asoc) ...@@ -771,6 +771,9 @@ static void __sctp_hash_established(struct sctp_association *asoc)
/* Add an association to the hash. Local BH-safe. */ /* Add an association to the hash. Local BH-safe. */
void sctp_hash_established(struct sctp_association *asoc) void sctp_hash_established(struct sctp_association *asoc)
{ {
if (asoc->temp)
return;
sctp_local_bh_disable(); sctp_local_bh_disable();
__sctp_hash_established(asoc); __sctp_hash_established(asoc);
sctp_local_bh_enable(); sctp_local_bh_enable();
...@@ -804,6 +807,9 @@ static void __sctp_unhash_established(struct sctp_association *asoc) ...@@ -804,6 +807,9 @@ static void __sctp_unhash_established(struct sctp_association *asoc)
/* Remove association from the hash table. Local BH-safe. */ /* Remove association from the hash table. Local BH-safe. */
void sctp_unhash_established(struct sctp_association *asoc) void sctp_unhash_established(struct sctp_association *asoc)
{ {
if (asoc->temp)
return;
sctp_local_bh_disable(); sctp_local_bh_disable();
__sctp_unhash_established(asoc); __sctp_unhash_established(asoc);
sctp_local_bh_enable(); sctp_local_bh_enable();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment