/* Add the null key to the endpoint shared keys list and *setthehmcasandchunkspointers.
*/
ep->prsctp_enable = net->sctp.prsctp_enable;
ep->reconf_enable = net->sctp.reconf_enable;
ep->ecn_enable = net->sctp.ecn_enable;
/* Remember who we are attached to. */
ep->base.sk = sk;
ep->base.net = sock_net(sk);
sock_hold(ep->base.sk);
if (unlikely(!ep->base.dead)) {
WARN(1, "Attempt to destroy undead endpoint %p!\n", ep); return;
}
/* Free the digest buffer */
kfree(ep->digest);
/* SCTP-AUTH: Free up AUTH releated data such as shared keys *chunksandhmacsarraysthatwereallocated
*/
sctp_auth_destroy_keys(&ep->endpoint_shared_keys);
sctp_auth_free(ep);
sk = ep->base.sk; /* Remove and free the port */ if (sctp_sk(sk)->bind_hash)
sctp_put_port(sk);
call_rcu(&ep->rcu, sctp_endpoint_destroy_rcu);
}
/* Hold a reference to an endpoint. */ int sctp_endpoint_hold(struct sctp_endpoint *ep)
{ return refcount_inc_not_zero(&ep->base.refcnt);
}
/* Release a reference to an endpoint and clean up if there are *nomorereferences.
*/ void sctp_endpoint_put(struct sctp_endpoint *ep)
{ if (refcount_dec_and_test(&ep->base.refcnt))
sctp_endpoint_destroy(ep);
}
/* Is this the endpoint we are looking for? */ struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep, struct net *net, constunion sctp_addr *laddr, int dif, int sdif)
{ int bound_dev_if = READ_ONCE(ep->base.sk->sk_bound_dev_if); struct sctp_endpoint *retval = NULL;
/* Look for any peeled off association from the endpoint that matches the *givenpeeraddress.
*/ bool sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep, constunion sctp_addr *paddr)
{ int bound_dev_if = READ_ONCE(ep->base.sk->sk_bound_dev_if); struct sctp_sockaddr_entry *addr; struct net *net = ep->base.net; struct sctp_bind_addr *bp;
bp = &ep->base.bind_addr; /* This function is called with the socket lock held, *sotheaddress_listcannotchange.
*/
list_for_each_entry(addr, &bp->address_list, list) { if (sctp_has_association(net, &addr->a, paddr,
bound_dev_if, bound_dev_if)) returntrue;
}
returnfalse;
}
/* Do delayed input processing. This is scheduled by sctp_rcv(). *ThismaybecalledonBHortasktime.
*/ staticvoid sctp_endpoint_bh_rcv(struct work_struct *work)
{ struct sctp_endpoint *ep =
container_of(work, struct sctp_endpoint,
base.inqueue.immediate); struct sctp_association *asoc; struct sock *sk; struct net *net; struct sctp_transport *transport; struct sctp_chunk *chunk; struct sctp_inq *inqueue; union sctp_subtype subtype; enum sctp_state state; int error = 0; int first_time = 1; /* is this the first time through the loop */
if (ep->base.dead) return;
asoc = NULL;
inqueue = &ep->base.inqueue;
sk = ep->base.sk;
net = sock_net(sk);
while (NULL != (chunk = sctp_inq_pop(inqueue))) {
subtype = SCTP_ST_CHUNK(chunk->chunk_hdr->type);
/* If the first chunk in the packet is AUTH, do special *processingspecifiedinSection6.3ofSCTP-AUTHspec
*/ if (first_time && (subtype.chunk == SCTP_CID_AUTH)) { struct sctp_chunkhdr *next_hdr;
next_hdr = sctp_inq_peek(inqueue); if (!next_hdr) goto normal;
/* If the next chunk is COOKIE-ECHO, skip the AUTH *chunkwhilesavingapointertoitsowecando *Authenticationlater(duringcookie-echo *processing).
*/ if (next_hdr->type == SCTP_CID_COOKIE_ECHO) {
chunk->auth_chunk = skb_clone(chunk->skb,
GFP_ATOMIC);
chunk->auth = 1; continue;
}
}
normal: /* We might have grown an association since last we *looked,sotryagain. * *Thishappenswhenwe'vejustprocessedour *COOKIE-ECHOchunk.
*/ if (NULL == chunk->asoc) {
asoc = sctp_endpoint_lookup_assoc(ep,
sctp_source(chunk),
&transport);
chunk->asoc = asoc;
chunk->transport = transport;
}
state = asoc ? asoc->state : SCTP_STATE_CLOSED; if (sctp_auth_recv_cid(subtype.chunk, asoc) && !chunk->auth) continue;
/* Remember where the last DATA chunk came from so we *knowwheretosendtheSACK.
*/ if (asoc && sctp_chunk_is_data(chunk))
asoc->peer.last_data_from = chunk->transport; else {
SCTP_INC_STATS(ep->base.net, SCTP_MIB_INCTRLCHUNKS); if (asoc)
asoc->stats.ictrlchunks++;
}
if (chunk->transport)
chunk->transport->last_time_heard = ktime_get();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.