/* A helper function for delayed processing of INET ECN CE bit. */ staticvoid sctp_do_ecn_ce_work(struct sctp_association *asoc,
__u32 lowest_tsn)
{ /* Save the TSN away for comparison when we receive CWR */
/* Helper function for delayed processing of SCTP ECNE chunk. */ /* RFC 2960 Appendix A * *RFC2481detailsaspecificbitforasendertosendin *theheaderofitsnextoutboundTCPsegmenttoindicateto *itspeerthatithasreduceditscongestionwindow.This *istermedtheCWRbit.ForSCTPthesameindicationismade *byincludingtheCWRchunk.Thischunkcontainsonedata *element,i.e.theTSNnumberthatwassentintheECNEchunk. *ThiselementrepresentsthelowestTSNnumberinthedatagram *thatwasoriginallymarkedwiththeCEbit.
*/ staticstruct sctp_chunk *sctp_do_ecn_ecne_work(struct sctp_association *asoc,
__u32 lowest_tsn, struct sctp_chunk *chunk)
{ struct sctp_chunk *repl;
/* Our previously transmitted packet ran into some congestion *soweshouldtakeactionbyreducingcwndandssthresh *andthenACKourpeerthatwewe'vedonesoby *sendingaCWR.
*/
/* First, try to determine if we want to actually lower *ourcwndvariables.OnlylowerthemiftheECNElooksmore *recentthanthelastresponse.
*/ if (TSN_lt(asoc->last_cwr_tsn, lowest_tsn)) { struct sctp_transport *transport;
/* Find which transport's congestion variables *needtobeadjusted.
*/
transport = sctp_assoc_lookup_tsn(asoc, lowest_tsn);
/* Update the congestion variables. */ if (transport)
sctp_transport_lower_cwnd(transport,
SCTP_LOWER_CWND_ECNE);
asoc->last_cwr_tsn = lowest_tsn;
}
/* Always try to quiet the other end. In case of lost CWR, *resendlast_cwr_tsn.
*/
repl = sctp_make_cwr(asoc, asoc->last_cwr_tsn, chunk);
/* If we run out of memory, it will look like a lost CWR. We'll *getbackinsynceventually.
*/ return repl;
}
/* Helper function to do delayed processing of ECN CWR chunk. */ staticvoid sctp_do_ecn_cwr_work(struct sctp_association *asoc,
__u32 lowest_tsn)
{ /* Turn off ECNE getting auto-prepended to every outgoing *packet
*/
asoc->need_ecne = 0;
}
/* Generate SACK if necessary. We call this at the end of a packet. */ staticint sctp_gen_sack(struct sctp_association *asoc, int force, struct sctp_cmd_seq *commands)
{ struct sctp_transport *trans = asoc->peer.last_data_from;
__u32 ctsn, max_tsn_seen; struct sctp_chunk *sack; int error = 0;
/* From 12.2 Parameters necessary per association (i.e. the TCB): * *AckState:Thisflagindicatesifthenextreceivedpacket *:istoberespondedtowithaSACK.... *:WhenDATAchunksareoutoforder,SACK's *:arenotdelayed(seeSection6). * *[ThisisactuallynotmentionedinSection6,butwe *implementithereanyway.--piggy]
*/ if (max_tsn_seen != ctsn)
asoc->peer.sack_needed = 1;
/* From 6.2 Acknowledgement on Reception of DATA Chunks: * *Section4.2of[RFC2581]SHOULDbefollowed.Specifically, *anacknowledgementSHOULDbegeneratedforatleastevery *secondpacket(noteverysecondDATAchunk)received,and *SHOULDbegeneratedwithin200msofthearrivalofany *unacknowledgedDATAchunk....
*/ if (!asoc->peer.sack_needed) {
asoc->peer.sack_cnt++;
/* Set the SACK delay timeout based on the *SACKdelayforthelasttransport *datawasreceivedfrom,orthedefault *fortheassociation.
*/ if (trans) { /* We will need a SACK for the next packet. */ if (asoc->peer.sack_cnt >= trans->sackfreq - 1)
asoc->peer.sack_needed = 1;
asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
trans->sackdelay;
} else { /* We will need a SACK for the next packet. */ if (asoc->peer.sack_cnt >= asoc->sackfreq - 1)
asoc->peer.sack_needed = 1;
/* When the T3-RTX timer expires, it calls this function to create the *relevantstatemachineevent.
*/ void sctp_generate_t3_rtx_event(struct timer_list *t)
{ struct sctp_transport *transport =
timer_container_of(transport, t, T3_rtx_timer); struct sctp_association *asoc = transport->asoc; struct sock *sk = asoc->base.sk; struct net *net = sock_net(sk); int error;
/* Check whether a task is in the sock. */
bh_lock_sock(sk); if (sock_owned_by_user(sk)) {
pr_debug("%s: sock is busy\n", __func__);
/* Try again later. */ if (!mod_timer(&transport->T3_rtx_timer, jiffies + (HZ/20)))
sctp_transport_hold(transport); goto out_unlock;
}
/* Run through the state machine. */
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX),
asoc->state,
asoc->ep, asoc,
transport, GFP_ATOMIC);
/* This is a sa interface for producing timeout events. It works *fortimeoutswhichusetheassociationastheirparameter.
*/ staticvoid sctp_generate_timeout_event(struct sctp_association *asoc, enum sctp_event_timeout timeout_type)
{ struct sock *sk = asoc->base.sk; struct net *net = sock_net(sk); int error = 0;
bh_lock_sock(sk); if (sock_owned_by_user(sk)) {
pr_debug("%s: sock is busy: timer %d\n", __func__,
timeout_type);
/* Try again later. */ if (!mod_timer(&asoc->timers[timeout_type], jiffies + (HZ/20)))
sctp_association_hold(asoc); goto out_unlock;
}
/* Is this association really dead and just waiting around for *thetimertoletgoofthereference?
*/ if (asoc->base.dead) goto out_unlock;
/* Run through the state machine. */
error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT,
SCTP_ST_TIMEOUT(timeout_type),
asoc->state, asoc->ep, asoc,
(void *)timeout_type, GFP_ATOMIC);
/* Generate a heart beat event. If the sock is busy, reschedule. Make *surethatthetransportisstillvalid.
*/ void sctp_generate_heartbeat_event(struct timer_list *t)
{ struct sctp_transport *transport = timer_container_of(transport, t,
hb_timer); struct sctp_association *asoc = transport->asoc; struct sock *sk = asoc->base.sk; struct net *net = sock_net(sk);
u32 elapsed, timeout; int error = 0;
bh_lock_sock(sk); if (sock_owned_by_user(sk)) {
pr_debug("%s: sock is busy\n", __func__);
/* Try again later. */ if (!mod_timer(&transport->hb_timer, jiffies + (HZ/20)))
sctp_transport_hold(transport); goto out_unlock;
}
/* Check if we should still send the heartbeat or reschedule */
elapsed = jiffies - transport->last_time_sent;
timeout = sctp_transport_timeout(transport); if (elapsed < timeout) {
elapsed = timeout - elapsed; if (!mod_timer(&transport->hb_timer, jiffies + elapsed))
sctp_transport_hold(transport); goto out_unlock;
}
/* RFC 2960 8.2 Path Failure Detection * *Whenitspeerendpointismulti-homed,anendpointshouldkeepa *errorcounterforeachofthedestinationtransportaddressesofthe *peerendpoint. * *EachtimetheT3-rtxtimerexpiresonanyaddress,orwhena *HEARTBEATsenttoanidleaddressisnotacknowledgedwithinaRTO, *theerrorcounterofthatdestinationaddresswillbeincremented. *Whenthevalueintheerrorcounterexceedstheprotocolparameter *'Path.Max.Retrans'ofthatdestinationaddress,theendpointshould *markthedestinationtransportaddressasinactive,anda *notificationSHOULDbesenttotheupperlayer. *
*/ staticvoid sctp_do_8_2_transport_strike(struct sctp_cmd_seq *commands, struct sctp_association *asoc, struct sctp_transport *transport, int is_hb)
{ /* The check for association's overall error counter exceeding the *thresholdisdoneinthestatefunction.
*/ /* We are here due to a timer expiration. If the timer was *notaHEARTBEAT,thennormalerrortrackingisdone. *Ifthetimerwasaheartbeat,weonlyincrementerrorcounts *whenwealreadyhaveanoutstandingHEARTBEATthathasnot *beenacknowledged. *Additionally,sometranportstatesinhibiterrorincrements.
*/ if (!is_hb) {
asoc->overall_error_count++; if (transport->state != SCTP_INACTIVE)
transport->error_count++;
} elseif (transport->hb_sent) { if (transport->state != SCTP_UNCONFIRMED)
asoc->overall_error_count++; if (transport->state != SCTP_INACTIVE)
transport->error_count++;
}
/* If the transport error count is greater than the pf_retrans *threshold,andlessthanpathmaxrtx,andifthecurrentstate *isSCTP_ACTIVE,thenmarkthistransportasPartiallyFailed, *seeSCTPQuickFailoverDraft,section5.1
*/ if (asoc->base.net->sctp.pf_enable &&
transport->state == SCTP_ACTIVE &&
transport->error_count < transport->pathmaxrxt &&
transport->error_count > transport->pf_retrans) {
/* SEND_FAILED sent later when cleaning up the association. */
asoc->outqueue.error = error;
sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL());
}
/* SEND_FAILED sent later when cleaning up the association. */
asoc->outqueue.error = error;
sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL());
}
/* Process an init chunk (may be real INIT/INIT-ACK or an embedded INIT *insidethecookie.Inreality,thisisonlyusedforINIT-ACKprocessing *sinceallothercasesuse"temporary"associationsandcandoall *theirworkinstatefunsdirectly.
*/ staticint sctp_cmd_process_init(struct sctp_cmd_seq *commands, struct sctp_association *asoc, struct sctp_chunk *chunk, struct sctp_init_chunk *peer_init,
gfp_t gfp)
{ int error;
/* We only process the init as a sideeffect in a single *case.ThisiswhenweprocesstheINIT-ACK.Ifwe *failduringINITprocessing(duetomallocproblems), *justreturntheerrorandstopprocessingthestack.
*/ if (!sctp_process_init(asoc, chunk, sctp_source(chunk), peer_init, gfp))
error = -ENOMEM; else
error = 0;
return error;
}
/* Helper function to break out starting up of heartbeat timers. */ staticvoid sctp_cmd_hb_timers_start(struct sctp_cmd_seq *cmds, struct sctp_association *asoc)
{ struct sctp_transport *t;
/* Start a heartbeat timer for each transport on the association. *holdareferenceonthetransporttomakesurenoneof *theneededdatastructuresgoaway.
*/
list_for_each_entry(t, &asoc->peer.transport_addr_list, transports)
sctp_transport_reset_hb_timer(t);
}
list_for_each_entry(t, &asoc->peer.transport_addr_list,
transports) { if (timer_delete(&t->hb_timer))
sctp_transport_put(t);
}
}
/* Helper function to stop any pending T3-RTX timers */ staticvoid sctp_cmd_t3_rtx_timers_stop(struct sctp_cmd_seq *cmds, struct sctp_association *asoc)
{ struct sctp_transport *t;
list_for_each_entry(t, &asoc->peer.transport_addr_list,
transports) { if (timer_delete(&t->T3_rtx_timer))
sctp_transport_put(t);
}
}
/* Helper function to handle the reception of an HEARTBEAT ACK. */ staticvoid sctp_cmd_transport_on(struct sctp_cmd_seq *cmds, struct sctp_association *asoc, struct sctp_transport *t, struct sctp_chunk *chunk)
{ struct sctp_sender_hb_info *hbinfo; int was_unconfirmed = 0;
/* 8.3 Upon the receipt of the HEARTBEAT ACK, the sender of the *HEARTBEATshouldcleartheerrorcounterofthedestination *transportaddresstowhichtheHEARTBEATwassent.
*/
t->error_count = 0;
/* Clear the hb_sent flag to signal that we had a good *acknowledgement.
*/
t->hb_sent = 0;
/* Mark the destination transport address as active if it is not so *marked.
*/ if ((t->state == SCTP_INACTIVE) || (t->state == SCTP_UNCONFIRMED)) {
was_unconfirmed = 1;
sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP,
SCTP_HEARTBEAT_SUCCESS);
}
if (t->state == SCTP_PF)
sctp_assoc_control_transport(asoc, t, SCTP_TRANSPORT_UP,
SCTP_HEARTBEAT_SUCCESS);
/* HB-ACK was received for a the proper HB. Consider this *forwardprogress.
*/ if (t->dst)
sctp_transport_dst_confirm(t);
/* The receiver of the HEARTBEAT ACK should also perform an *RTTmeasurementforthatdestinationtransportaddress *usingthetimevaluecarriedintheHEARTBEATACKchunk. *Ifthetransport'srto_pendingvariablehasbeencleared, *itwasmostlikelyduetoaretransmit.However,wewant *tore-enableittoproperlyupdatetherto.
*/ if (t->rto_pending == 0)
t->rto_pending = 1;
/* Update the heartbeat timer. */
sctp_transport_reset_hb_timer(t);
if (was_unconfirmed && asoc->peer.transport_count == 1)
sctp_transport_immediate_rtx(t);
}
/* Helper function to process the process SACK command. */ staticint sctp_cmd_process_sack(struct sctp_cmd_seq *cmds, struct sctp_association *asoc, struct sctp_chunk *chunk)
{ int err = 0;
if (sctp_outq_sack(&asoc->outqueue, chunk)) { /* There are no more TSNs awaiting SACK. */
err = sctp_do_sm(asoc->base.net, SCTP_EVENT_T_OTHER,
SCTP_ST_OTHER(SCTP_EVENT_NO_PENDING_TSN),
asoc->state, asoc->ep, asoc, NULL,
GFP_ATOMIC);
}
return err;
}
/* Helper function to set the timeout value for T2-SHUTDOWN timer and to set *thetransportforashutdownchunk.
*/ staticvoid sctp_cmd_setup_t2(struct sctp_cmd_seq *cmds, struct sctp_association *asoc, struct sctp_chunk *chunk)
{ struct sctp_transport *t;
if (chunk->transport)
t = chunk->transport; else {
t = sctp_assoc_choose_alter_transport(asoc,
asoc->shutdown_last_sent_to);
chunk->transport = t;
}
asoc->shutdown_last_sent_to = t;
asoc->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] = t->rto;
}
/* Helper function to change the state of an association. */ staticvoid sctp_cmd_new_state(struct sctp_cmd_seq *cmds, struct sctp_association *asoc, enum sctp_state state)
{ struct sock *sk = asoc->base.sk;
if (sctp_style(sk, TCP)) { /* Change the sk->sk_state of a TCP-style socket that has *successfullycompletedaconnect()call.
*/ if (sctp_state(asoc, ESTABLISHED) && sctp_sstate(sk, CLOSED))
inet_sk_set_state(sk, SCTP_SS_ESTABLISHED);
/* Set the RCV_SHUTDOWN flag when a SHUTDOWN is received. */ if (sctp_state(asoc, SHUTDOWN_RECEIVED) &&
sctp_sstate(sk, ESTABLISHED)) {
inet_sk_set_state(sk, SCTP_SS_CLOSING);
sk->sk_shutdown |= RCV_SHUTDOWN;
}
}
if (sctp_state(asoc, COOKIE_WAIT)) { /* Reset init timeouts since they may have been *increasedduetotimerexpirations.
*/
asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] =
asoc->rto_initial;
asoc->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE] =
asoc->rto_initial;
}
if (sctp_state(asoc, ESTABLISHED)) {
kfree(asoc->peer.cookie);
asoc->peer.cookie = NULL;
}
if (sctp_state(asoc, ESTABLISHED) ||
sctp_state(asoc, CLOSED) ||
sctp_state(asoc, SHUTDOWN_RECEIVED)) { /* Wake up any processes waiting in the asoc's wait queue in *sctp_wait_for_connect()orsctp_wait_for_sndbuf().
*/ if (waitqueue_active(&asoc->wait))
wake_up_interruptible(&asoc->wait);
/* Wake up any processes waiting in the sk's sleep queue of *aTCP-styleorUDP-stylepeeled-offsocketin *sctp_wait_for_accept()orsctp_wait_for_packet(). *ForaUDP-stylesocket,thewaitersarewokenupbythe *notifications.
*/ if (!sctp_style(sk, UDP))
sk->sk_state_change(sk);
}
if (sctp_state(asoc, SHUTDOWN_PENDING) &&
!sctp_outq_is_empty(&asoc->outqueue))
sctp_outq_uncork(&asoc->outqueue, GFP_ATOMIC);
}
/* Helper function to delete an association. */ staticvoid sctp_cmd_delete_tcb(struct sctp_cmd_seq *cmds, struct sctp_association *asoc)
{ struct sock *sk = asoc->base.sk;
/* If it is a non-temporary association belonging to a TCP-style *listeningsocketthatisnotclosed,donotfreeitsothataccept() *canpickituplater.
*/ if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING) &&
(!asoc->temp) && (sk->sk_shutdown != SHUTDOWN_MASK)) return;
while (chunk->chunk_end > chunk->skb->data) {
err_hdr = (struct sctp_errhdr *)(chunk->skb->data);
ev = sctp_ulpevent_make_remote_error(asoc, chunk, 0,
GFP_ATOMIC); if (!ev) return;
asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
switch (err_hdr->cause) { case SCTP_ERROR_UNKNOWN_CHUNK:
{ struct sctp_chunkhdr *unk_chunk_hdr;
unk_chunk_hdr = (struct sctp_chunkhdr *)(err_hdr + 1); switch (unk_chunk_hdr->type) { /* ADDIP 4.1 A9) If the peer responds to an ASCONF with *anERRORchunkreportingthatitdidnotrecognized *theASCONFchunktype,thesenderoftheASCONFMUST *NOTsendanyfurtherASCONFchunksandMUSTstopits *T-4timer.
*/ case SCTP_CID_ASCONF: if (asoc->peer.asconf_capable == 0) break;
/* Helper function to remove the association non-primary peer *transports.
*/ staticvoid sctp_cmd_del_non_primary(struct sctp_association *asoc)
{ struct sctp_transport *t; struct list_head *temp; struct list_head *pos;
list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
t = list_entry(pos, struct sctp_transport, transports); if (!sctp_cmp_addr_exact(&t->ipaddr,
&asoc->peer.primary_addr)) {
sctp_assoc_rm_peer(asoc, t);
}
}
}
/* Helper function to set sk_err on a 1-1 style socket. */ staticvoid sctp_cmd_set_sk_err(struct sctp_association *asoc, int error)
{ struct sock *sk = asoc->base.sk;
if (!sctp_style(sk, UDP))
sk->sk_err = error;
}
/* Helper function to generate an association change event */ staticvoid sctp_cmd_assoc_change(struct sctp_cmd_seq *commands, struct sctp_association *asoc,
u8 state)
{ struct sctp_ulpevent *ev;
ev = sctp_ulpevent_make_assoc_change(asoc, 0, state, 0,
asoc->c.sinit_num_ostreams,
asoc->c.sinit_max_instreams,
NULL, GFP_ATOMIC); if (ev)
asoc->stream.si->enqueue_event(&asoc->ulpq, ev);
}
/* These three macros allow us to pull the debugging code out of the *mainflowofsctp_do_sm()tokeepattentionfocusedonthereal *functionalitythere.
*/ #define debug_pre_sfn() \
pr_debug("%s[pre-fn]: ep:%p, %s, %s, asoc:%p[%s], %s\n", __func__, \
ep, sctp_evttype_tbl[event_type], (*debug_fn)(subtype), \
asoc, sctp_state_tbl[state], state_fn->name)
/* Look up the state function, run it, and then process the *sideeffects.Thesethreestepsaretheheartoflksctp.
*/
state_fn = sctp_sm_lookup_event(net, event_type, state, subtype);
sctp_init_cmd_seq(&commands);
debug_pre_sfn();
status = state_fn->fn(net, ep, asoc, subtype, event_arg, &commands);
debug_post_sfn();
/* FIXME - Most of the dispositions left today would be categorized *as"exceptional"dispositions.Forthosedispositions,it *maynotbepropertorunthroughanyofthecommandsatall. *Forexample,thecommandinterpretermightberunonlywith *dispositionSCTP_DISPOSITION_CONSUME.
*/ if (0 != (error = sctp_cmd_interpreter(event_type, subtype, state,
ep, *asoc,
event_arg, status,
commands, gfp))) goto bail;
case SCTP_DISPOSITION_NOMEM: /* We ran out of memory, so we need to discard this *packet.
*/ /* BUG--we should now recover some memory, probably by *reneging...
*/
error = -ENOMEM; break;
case SCTP_DISPOSITION_DELETE_TCB: case SCTP_DISPOSITION_ABORT: /* This should now be a command. */
*asoc = NULL; break;
case SCTP_DISPOSITION_CONSUME: /* *Weshouldnolongerhavemuchworktodohereasthe *realworkhasbeendoneasexplicitcommandsabove.
*/ break;
case SCTP_DISPOSITION_VIOLATION:
net_err_ratelimited("protocol violation state %d chunkid %d\n",
state, subtype.chunk); break;
case SCTP_DISPOSITION_NOT_IMPL:
pr_warn("unimplemented feature in state %d, event_type %d, event_id %d\n",
state, event_type, subtype.chunk); break;
case SCTP_DISPOSITION_BUG:
pr_err("bug in state %d, event_type %d, event_id %d\n",
state, event_type, subtype.chunk);
BUG(); break;
default:
pr_err("impossible disposition %d in state %d, event_type %d, event_id %d\n",
status, state, event_type, subtype.chunk);
error = status; if (error >= 0)
error = -EINVAL;
WARN_ON_ONCE(1); break;
}
if (SCTP_EVENT_T_TIMEOUT != event_type)
chunk = event_arg;
/* Note: This whole file is a huge candidate for rework. *Forexample,eachcommandcouldeitherhaveitsownhandler,so *theloopwouldlooklike: *while(cmds) *cmd->handle(x,y,z) *--jgrimm
*/ while (NULL != (cmd = sctp_next_cmd(commands))) { switch (cmd->verb) { case SCTP_CMD_NOP: /* Do nothing. */ break;
case SCTP_CMD_NEW_ASOC: /* Register a new association. */ if (local_cork) {
sctp_outq_uncork(&asoc->outqueue, gfp);
local_cork = 0;
}
/* Register with the endpoint. */
asoc = cmd->obj.asoc;
BUG_ON(asoc->peer.primary_path == NULL);
sctp_endpoint_add_asoc(ep, asoc); break;
case SCTP_CMD_PURGE_OUTQUEUE:
sctp_outq_teardown(&asoc->outqueue); break;
case SCTP_CMD_DELETE_TCB: if (local_cork) {
sctp_outq_uncork(&asoc->outqueue, gfp);
local_cork = 0;
} /* Delete the current association. */
sctp_cmd_delete_tcb(commands, asoc);
asoc = NULL; break;
case SCTP_CMD_NEW_STATE: /* Enter a new state. */
sctp_cmd_new_state(commands, asoc, cmd->obj.state); break;
case SCTP_CMD_REPORT_TSN: /* Record the arrival of a TSN. */
error = sctp_tsnmap_mark(&asoc->peer.tsn_map,
cmd->obj.u32, NULL); break;
case SCTP_CMD_REPORT_FWDTSN:
asoc->stream.si->report_ftsn(&asoc->ulpq, cmd->obj.u32); break;
case SCTP_CMD_PROCESS_FWDTSN:
asoc->stream.si->handle_ftsn(&asoc->ulpq,
cmd->obj.chunk); break;
case SCTP_CMD_GEN_SACK: /* Generate a Selective ACK. *Theargumenttellsuswhethertojustcount *thepacketandMAYBEgenerateaSACK,or *forceaSACKout.
*/
force = cmd->obj.i32;
error = sctp_gen_sack(asoc, force, commands); break;
case SCTP_CMD_PROCESS_SACK: /* Process an inbound SACK. */
error = sctp_cmd_process_sack(commands, asoc,
cmd->obj.chunk); break;
case SCTP_CMD_GEN_INIT_ACK: /* Generate an INIT ACK chunk. */
new_obj = sctp_make_init_ack(asoc, chunk, GFP_ATOMIC, 0); if (!new_obj) {
error = -ENOMEM; break;
}
case SCTP_CMD_PEER_INIT: /* Process a unified INIT from the peer. *Note:OnlyusedduringINIT-ACKprocessing.If *thereisanerrorjustreturntotheoutter *layerwhichwillbail.
*/
error = sctp_cmd_process_init(commands, asoc, chunk,
cmd->obj.init, gfp); break;
case SCTP_CMD_GEN_COOKIE_ECHO: /* Generate a COOKIE ECHO chunk. */
new_obj = sctp_make_cookie_echo(asoc, chunk); if (!new_obj) { if (cmd->obj.chunk)
sctp_chunk_free(cmd->obj.chunk);
error = -ENOMEM; break;
}
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
SCTP_CHUNK(new_obj));
/* If there is an ERROR chunk to be sent along with *theCOOKIE_ECHO,sendit,too.
*/ if (cmd->obj.chunk)
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
SCTP_CHUNK(cmd->obj.chunk));
if (new_obj->transport) {
new_obj->transport->init_sent_count++;
asoc->init_last_sent_to = new_obj->transport;
}
/* FIXME - Eventually come up with a cleaner way to *enablingCOOKIE-ECHO+DATAbundlingduring *multihomingstalecookiescenarios,thefollowing *commandplayswithasoc->peer.retran_pathto *avoidtheproblemofsendingtheCOOKIE-ECHOand *DATAindifferentpaths,whichcouldresult *intheassociationbeingABORTediftheDATAchunk *isprocessedfirstbytheserver.Checkingthe *initerrorcountersimplycausesthiscommand *tobeexecutedonlyduringfailedattemptsof *associationestablishment.
*/ if ((asoc->peer.retran_path !=
asoc->peer.primary_path) &&
(asoc->init_err_counter > 0)) {
sctp_add_cmd_sf(commands,
SCTP_CMD_FORCE_PRIM_RETRAN,
SCTP_NULL());
}
break;
case SCTP_CMD_GEN_SHUTDOWN: /* Generate SHUTDOWN when in SHUTDOWN_SENT state. *Reseterrorcounts.
*/
asoc->overall_error_count = 0;
case SCTP_CMD_CHUNK_ULP: /* Send a chunk to the sockets layer. */
pr_debug("%s: sm_sideff: chunk_up:%p, ulpq:%p\n",
__func__, cmd->obj.chunk, &asoc->ulpq);
case SCTP_CMD_EVENT_ULP: /* Send a notification to the sockets layer. */
pr_debug("%s: sm_sideff: event_up:%p, ulpq:%p\n",
__func__, cmd->obj.ulpevent, &asoc->ulpq);
case SCTP_CMD_REPLY: /* If an caller has not already corked, do cork. */ if (!asoc->outqueue.cork) {
sctp_outq_cork(&asoc->outqueue);
local_cork = 1;
} /* Send a chunk to our peer. */
sctp_outq_tail(&asoc->outqueue, cmd->obj.chunk, gfp); break;
case SCTP_CMD_SEND_PKT: /* Send a full packet to our peer. */
packet = cmd->obj.packet;
sctp_packet_transmit(packet, gfp);
sctp_ootb_pkt_free(packet); break;
case SCTP_CMD_T1_RETRAN: /* Mark a transport for retransmission. */
sctp_retransmit(&asoc->outqueue, cmd->obj.transport,
SCTP_RTXR_T1_RTX); break;
case SCTP_CMD_RETRAN: /* Mark a transport for retransmission. */
sctp_retransmit(&asoc->outqueue, cmd->obj.transport,
SCTP_RTXR_T3_RTX); break;
case SCTP_CMD_ECN_CE: /* Do delayed CE processing. */
sctp_do_ecn_ce_work(asoc, cmd->obj.u32); break;
case SCTP_CMD_ECN_ECNE: /* Do delayed ECNE processing. */
new_obj = sctp_do_ecn_ecne_work(asoc, cmd->obj.u32,
chunk); if (new_obj)
sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
SCTP_CHUNK(new_obj)); break;
case SCTP_CMD_ECN_CWR: /* Do delayed CWR processing. */
sctp_do_ecn_cwr_work(asoc, cmd->obj.u32); break;
case SCTP_CMD_SETUP_T2:
sctp_cmd_setup_t2(commands, asoc, cmd->obj.chunk); break;
case SCTP_CMD_TIMER_START_ONCE:
timer = &asoc->timers[cmd->obj.to];
if (timer_pending(timer)) break;
fallthrough;
case SCTP_CMD_TIMER_START:
timer = &asoc->timers[cmd->obj.to];
timeout = asoc->timeouts[cmd->obj.to];
BUG_ON(!timeout);
case SCTP_CMD_TIMER_RESTART:
timer = &asoc->timers[cmd->obj.to];
timeout = asoc->timeouts[cmd->obj.to]; if (!mod_timer(timer, jiffies + timeout))
sctp_association_hold(asoc); break;
case SCTP_CMD_TIMER_STOP:
timer = &asoc->timers[cmd->obj.to]; if (timer_delete(timer))
sctp_association_put(asoc); break;
case SCTP_CMD_INIT_CHOOSE_TRANSPORT:
chunk = cmd->obj.chunk;
t = sctp_assoc_choose_alter_transport(asoc,
asoc->init_last_sent_to);
asoc->init_last_sent_to = t;
chunk->transport = t;
t->init_sent_count++; /* Set the new transport as primary */
sctp_assoc_set_primary(asoc, t); break;
case SCTP_CMD_INIT_RESTART: /* Do the needed accounting and updates *associatedwithrestartinganinitialization *timer.Onlymultiplythetimeoutbytwoif *alltransportshavebeentriedatthecurrent *timeout.
*/
sctp_cmd_t1_timer_update(asoc,
SCTP_EVENT_TIMEOUT_T1_INIT, "INIT");
case SCTP_CMD_COOKIEECHO_RESTART: /* Do the needed accounting and updates *associatedwithrestartinganinitialization *timer.Onlymultiplythetimeoutbytwoif *alltransportshavebeentriedatthecurrent *timeout.
*/
sctp_cmd_t1_timer_update(asoc,
SCTP_EVENT_TIMEOUT_T1_COOKIE, "COOKIE");
/* If we've sent any data bundled with *COOKIE-ECHOweneedtoresend.
*/
list_for_each_entry(t, &asoc->peer.transport_addr_list,
transports) {
sctp_retransmit_mark(&asoc->outqueue, t,
SCTP_RTXR_T1_RTX);
}
case SCTP_CMD_REPORT_DUP:
sctp_tsnmap_mark_dup(&asoc->peer.tsn_map,
cmd->obj.u32); break;
case SCTP_CMD_REPORT_BAD_TAG:
pr_debug("%s: vtag mismatch!\n", __func__); break;
case SCTP_CMD_STRIKE: /* Mark one strike against a transport. */
sctp_do_8_2_transport_strike(commands, asoc,
cmd->obj.transport, 0); break;
case SCTP_CMD_TRANSPORT_IDLE:
t = cmd->obj.transport;
sctp_transport_lower_cwnd(t, SCTP_LOWER_CWND_INACTIVE); break;
case SCTP_CMD_TRANSPORT_HB_SENT:
t = cmd->obj.transport;
sctp_do_8_2_transport_strike(commands, asoc,
t, 1);
t->hb_sent = 1; break;
case SCTP_CMD_TRANSPORT_ON:
t = cmd->obj.transport;
sctp_cmd_transport_on(commands, asoc, t, chunk); break;
case SCTP_CMD_HB_TIMERS_START:
sctp_cmd_hb_timers_start(commands, asoc); break;
case SCTP_CMD_HB_TIMER_UPDATE:
t = cmd->obj.transport;
sctp_transport_reset_hb_timer(t); break;
case SCTP_CMD_HB_TIMERS_STOP:
sctp_cmd_hb_timers_stop(commands, asoc); break;
case SCTP_CMD_PROBE_TIMER_UPDATE:
t = cmd->obj.transport;
sctp_transport_reset_probe_timer(t); break;
case SCTP_CMD_REPORT_ERROR:
error = cmd->obj.error; break;
case SCTP_CMD_PROCESS_CTSN: /* Dummy up a SACK for processing. */
sackh.cum_tsn_ack = cmd->obj.be32;
sackh.a_rwnd = htonl(asoc->peer.rwnd +
asoc->outqueue.outstanding_bytes);
sackh.num_gap_ack_blocks = 0;
sackh.num_dup_tsns = 0;
chunk->subh.sack_hdr = &sackh;
sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK,
SCTP_CHUNK(chunk)); break;
case SCTP_CMD_DISCARD_PACKET: /* We need to discard the whole packet. *Uncorkthequeuesincetheremightbe *responsespending
*/
chunk->pdiscard = 1; if (asoc) {
sctp_outq_uncork(&asoc->outqueue, gfp);
local_cork = 0;
} break;
case SCTP_CMD_RTO_PENDING:
t = cmd->obj.transport;
t->rto_pending = 1; break;
case SCTP_CMD_PART_DELIVER:
asoc->stream.si->start_pd(&asoc->ulpq, GFP_ATOMIC); break;
case SCTP_CMD_RENEGE:
asoc->stream.si->renege_events(&asoc->ulpq,
cmd->obj.chunk,
GFP_ATOMIC); break;
case SCTP_CMD_SETUP_T4:
sctp_cmd_setup_t4(commands, asoc, cmd->obj.chunk); break;
case SCTP_CMD_PROCESS_OPERR:
sctp_cmd_process_operr(commands, asoc, chunk); break; case SCTP_CMD_CLEAR_INIT_TAG:
asoc->peer.i.init_tag = 0; break; case SCTP_CMD_DEL_NON_PRIMARY:
sctp_cmd_del_non_primary(asoc); break; case SCTP_CMD_T3_RTX_TIMERS_STOP:
sctp_cmd_t3_rtx_timers_stop(commands, asoc); break; case SCTP_CMD_FORCE_PRIM_RETRAN:
t = asoc->peer.retran_path;
asoc->peer.retran_path = asoc->peer.primary_path;
sctp_outq_uncork(&asoc->outqueue, gfp);
local_cork = 0;
asoc->peer.retran_path = t; break; case SCTP_CMD_SET_SK_ERR:
sctp_cmd_set_sk_err(asoc, cmd->obj.error); break; case SCTP_CMD_ASSOC_CHANGE:
sctp_cmd_assoc_change(commands, asoc,
cmd->obj.u8); break; case SCTP_CMD_ADAPTATION_IND:
sctp_cmd_adaptation_ind(commands, asoc); break; case SCTP_CMD_PEER_NO_AUTH:
sctp_cmd_peer_no_auth(commands, asoc); break;
case SCTP_CMD_ASSOC_SHKEY:
error = sctp_auth_asoc_init_active_key(asoc,
GFP_ATOMIC); break; case SCTP_CMD_UPDATE_INITTAG:
asoc->peer.i.init_tag = cmd->obj.u32; break; case SCTP_CMD_SEND_MSG: if (!asoc->outqueue.cork) {
sctp_outq_cork(&asoc->outqueue);
local_cork = 1;
}
sctp_cmd_send_msg(asoc, cmd->obj.msg, gfp); break; case SCTP_CMD_PURGE_ASCONF_QUEUE:
sctp_asconf_queue_teardown(asoc); break;
case SCTP_CMD_SET_ASOC: if (asoc && local_cork) {
sctp_outq_uncork(&asoc->outqueue, gfp);
local_cork = 0;
}
asoc = cmd->obj.asoc; break;
if (error) {
cmd = sctp_next_cmd(commands); while (cmd) { if (cmd->verb == SCTP_CMD_REPLY)
sctp_chunk_free(cmd->obj.chunk);
cmd = sctp_next_cmd(commands);
} break;
}
}
/* If this is in response to a received chunk, wait until *wearedonewiththepackettoopenthequeuesothatwedon't *sendmultiplepacketsinresponsetoasinglerequest.
*/ if (asoc && SCTP_EVENT_T_CHUNK == event_type && chunk) { if (chunk->end_of_packet || chunk->singleton)
sctp_outq_uncork(&asoc->outqueue, gfp);
} elseif (local_cork)
sctp_outq_uncork(&asoc->outqueue, gfp);
if (sp->data_ready_signalled)
sp->data_ready_signalled = 0;
return error;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.31 Sekunden
(vorverarbeitet am 2026-09-28)
¤
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.