Commit 247d0d19 authored by Jon Grimm's avatar Jon Grimm

[SCTP] Break out sctp_assoc_valid() from sctp_id2assoc().

sctp_id2assoc() was trying to do too many things.  Break out, so
sctp_assoc_bh_rcv() can just find out whether the assoc is valid.
parent ec7bf6c1
......@@ -793,6 +793,26 @@ struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc,
return transport;
}
/* Is this a live association structure. */
int sctp_assoc_valid(struct sock *sk, struct sctp_association *asoc)
{
/* First, verify that this is a kernel address. */
if (!sctp_is_valid_kaddr((unsigned long) asoc))
return 0;
/* Verify that this _is_ an sctp_association
* data structure and if so, that the socket matches.
*/
if (SCTP_ASSOC_EYECATCHER != asoc->eyecatcher)
return 0;
if (asoc->base.sk != sk)
return 0;
/* The association is valid. */
return 1;
}
/* Do delayed input processing. This is scheduled by sctp_rcv(). */
static void sctp_assoc_bh_rcv(struct sctp_association *asoc)
{
......@@ -801,7 +821,6 @@ static void sctp_assoc_bh_rcv(struct sctp_association *asoc)
struct sock *sk;
struct sctp_inq *inqueue;
int state, subtype;
sctp_assoc_t associd = sctp_assoc2id(asoc);
int error = 0;
/* The association should be held so we should be safe. */
......@@ -831,7 +850,7 @@ static void sctp_assoc_bh_rcv(struct sctp_association *asoc)
/* Check to see if the association is freed in response to
* the incoming chunk. If so, get out of the while loop.
*/
if (!sctp_id2assoc(sk, associd))
if (!sctp_assoc_valid(sk, asoc))
break;
/* If there is an error on chunk, discard this packet. */
......
......@@ -101,6 +101,9 @@ static char *sctp_hmac_alg = SCTP_COOKIE_HMAC_ALG;
extern kmem_cache_t *sctp_bucket_cachep;
extern int sctp_assoc_valid(struct sock *sk, struct sctp_association *asoc);
/* Look up the association by its id. If this is not a UDP-style
* socket, the ID field is always ignored.
*/
......@@ -124,18 +127,10 @@ struct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id)
return asoc;
}
/* First, verify that this is a kernel address. */
if (sctp_is_valid_kaddr((unsigned long) id)) {
struct sctp_association *temp;
/* Verify that this _is_ an sctp_association
* data structure and if so, that the socket matches.
*/
temp = (struct sctp_association *)id;
if ((SCTP_ASSOC_EYECATCHER == temp->eyecatcher) &&
(temp->base.sk == sk))
asoc = temp;
}
/* Otherwise this is a UDP-style socket. */
asoc = (struct sctp_association *)id;
if (!sctp_assoc_valid(sk, asoc))
return NULL;
return asoc;
}
......
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