sctp_output.c revision 5dd46ab5742d7db1cbb08dec7b64fa14930c02f7
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * CDDL HEADER START
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * The contents of this file are subject to the terms of the
0168954460bd77d83497a4a6aa9c3f34c55dba25jchu * Common Development and Distribution License (the "License").
0168954460bd77d83497a4a6aa9c3f34c55dba25jchu * You may not use this file except in compliance with the License.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * See the License for the specific language governing permissions
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * and limitations under the License.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * When distributing Covered Code, include this CDDL HEADER in each
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * If applicable, add the following below this CDDL HEADER, with the
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * fields enclosed by brackets "[]" replaced with your own identifying
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * information: Portions Copyright [yyyy] [name of copyright owner]
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * CDDL HEADER END
5613d828c3413db2a71d47fbbc385a3f7a23d908Krishna Elango * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * PR-SCTP comments.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * A message can expire before it gets to the transmit list (i.e. it is still
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * in the unsent list - unchunked), after it gets to the transmit list, but
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * before transmission has actually started, or after transmission has begun.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Accordingly, we check for the status of a message in sctp_chunkify() when
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * the message is being transferred from the unsent list to the transmit list;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * in sctp_get_msg_to_send(), when we get the next chunk from the transmit
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * list and in sctp_rexmit() when we get the next chunk to be (re)transmitted.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * When we nuke a message in sctp_chunkify(), all we need to do is take it
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * out of the unsent list and update sctp_unsent; when a message is deemed
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * timed-out in sctp_get_msg_to_send() we can just take it out of the transmit
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * list, update sctp_unsent IFF transmission for the message has not yet begun
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * (i.e. !SCTP_CHUNK_ISSENT(meta->b_cont)). However, if transmission for the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * message has started, then we cannot just take it out of the list, we need
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * to send Forward TSN chunk to the peer so that the peer can clear its
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * fragment list for this message. However, we cannot just send the Forward
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * TSN in sctp_get_msg_to_send() because there might be unacked chunks for
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * messages preceeding this abandoned message. So, we send a Forward TSN
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * IFF all messages prior to this abandoned message has been SACKd, if not
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * we defer sending the Forward TSN to sctp_cumack(), which will check for
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * this condition and send the Forward TSN via sctp_check_abandoned_msg(). In
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * sctp_rexmit() when we check for retransmissions, we need to determine if
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * the advanced peer ack point can be moved ahead, and if so, send a Forward
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * TSN to the peer instead of retransmitting the chunk. Note that when
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * we send a Forward TSN for a message, there may be yet unsent chunks for
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * this message; we need to mark all such chunks as abandoned, so that
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * sctp_cumack() can take the message out of the transmit list, additionally
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * sctp_unsent need to be adjusted. Whenever sctp_unsent is updated (i.e.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * decremented when a message/chunk is deemed abandoned), sockfs needs to
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * be notified so that it can adjust its idea of the queued message.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Called to allocate a header mblk when sending data to SCTP.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Data will follow in b_cont of this mblk.
25cf1a301a396c38e8adf52c15f537b80d2483f7jlsctp_alloc_hdr(const char *name, int nlen, const char *control, int clen,
f8d2de6bd2421da1926f3daa456d161670decdf7jchu/*ARGSUSED2*/
bf8fc2340620695a402331e5da7c7db43264174det /* Get destination address, if specified */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* Ancillary Data? */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cmsg = (struct cmsghdr *)(mproto->b_rptr + tudr->OPT_offset);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl for (;;) {
8c3348818856b8366c07db7214dd7746a0aa3a07jchu /* Reject any new data requests if we are shutting down */
bf8fc2340620695a402331e5da7c7db43264174det /* Re-use the mproto to store relevant info. */
bf8fc2340620695a402331e5da7c7db43264174det mproto->b_wptr = mproto->b_rptr + sizeof (*sctp_msg_hdr);
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* User requested specific destination */
8c3348818856b8366c07db7214dd7746a0aa3a07jchu /* Send sendfail event */
8c3348818856b8366c07db7214dd7746a0aa3a07jchu sctp_sendfail_event(sctp, dupmsg(mproto), SCTP_ERR_BAD_SID,
bf8fc2340620695a402331e5da7c7db43264174det /* no data */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if (msg_len == 0) {
bf8fc2340620695a402331e5da7c7db43264174det /* Add it to the unsent list */
bf8fc2340620695a402331e5da7c7db43264174det sctp->sctp_xmit_unsent = sctp->sctp_xmit_unsent_tail = mproto;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Notify sockfs if the tx queue is full.
8c3348818856b8366c07db7214dd7746a0aa3a07jchu return (0);
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * While there are messages on sctp_xmit_unsent, detach each one. For each:
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * allocate space for the chunk header, fill in the data chunk, and fill in
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * the chunk header. Then append it to sctp_xmit_tail.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Return after appending as many bytes as required (bytes_to_send).
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * We also return if we've appended one or more chunks, and find a subsequent
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * unsent message is too big to fit in the segment.
f8d2de6bd2421da1926f3daa456d161670decdf7jchusctp_chunkify(sctp_t *sctp, int mss, int firstseg_len, int bytes_to_send)
f8d2de6bd2421da1926f3daa456d161670decdf7jchu sizeof (*sdc);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl xtralen = sctp->sctp_hdr6_len + sctps->sctps_wroff_xtra +
8bc7d88a7ed8565440a3cb4d316b626938433668et sizeof (*sdc);
bf8fc2340620695a402331e5da7c7db43264174det next_msg_hdr = (sctp_msg_hdr_t *)sctp->sctp_xmit_unsent->b_rptr;
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Will the entire next message fit in the current packet ?
bf8fc2340620695a402331e5da7c7db43264174det * if not, leave it on the unsent list.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * If this partially chunked, we ignore the next one for now and
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * use the one already present. For the unchunked bits, we use the
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * length of the last chunk.
8bc7d88a7ed8565440a3cb4d316b626938433668et chunk_len = ntohs(((sctp_data_hdr_t *)mp->b_rptr)->sdh_len);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Update ULP the amount of queued data, which is
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * sent-unack'ed + unsent.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* Skip as many mblk's as we need */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl while (chunk_mp != NULL && ((count - MBLKL(chunk_mp)) >= 0)) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* Split the chain, if needed */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (count > 0) {
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* Alloc chunk hdr, if needed */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu sdc->sdh_len = htons(sizeof (*sdc) + chunksize - count);
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * We defer assigning the SSN just before sending the chunk, else
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * if we drop the chunk in sctp_get_msg_to_send(), we would need
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * to send a Forward TSN to let the peer know. Some more comments
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * about this in sctp_impl.h for SCTP_CHUNK_SENT.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if (bytes_to_send > 0 && sctp->sctp_xmit_unsent != NULL) {
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if ((count > 0) &&
f8d2de6bd2421da1926f3daa456d161670decdf7jchu sizeof (*sdc);
08a74c0d0f6c3b94aa21216885efa4387c3d375cschwartzsctp_add_proto_hdr(sctp_t *sctp, sctp_faddr_t *fp, mblk_t *mp, int sacklen,
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * A reject|blackhole could mean that the address is 'down'. Similarly,
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * it is possible that the address went down, we tried to send an
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * heartbeat and ended up setting fp->saddr as unspec because we
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * didn't have any usable source address. In either case
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * sctp_get_dest() will try find an IRE, if available, and set
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * the source address, if needed. If we still don't have any
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * usable source address, fp->state will be SCTP_FADDRS_UNREACH and
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * we return EHOSTUNREACH.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if ((fp->ixa->ixa_ire->ire_flags & (RTF_REJECT|RTF_BLACKHOLE)) ||
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* Copy in IP header. */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu (sctps->sctps_wroff_xtra + hdrlen + sacklen) || DB_REF(mp) > 2) {
08a74c0d0f6c3b94aa21216885efa4387c3d375cschwartz * This can happen if IP headers are adjusted after
08a74c0d0f6c3b94aa21216885efa4387c3d375cschwartz * data was moved into chunks, or during retransmission,
08a74c0d0f6c3b94aa21216885efa4387c3d375cschwartz * or things like snoop is running.
08a74c0d0f6c3b94aa21216885efa4387c3d375cschwartz nmp = allocb(sctps->sctps_wroff_xtra + hdrlen + sacklen,
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* change addresses in header */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * SCTP requires every chunk to be padded so that the total length
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * is a multiple of SCTP_ALIGN. This function returns a mblk with
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * the specified pad length.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * The memory saving path of reusing the sctp_pad_mp
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * fails may be because it has been dupb() too
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * many times (DBLK_REFMAX). Use the memory consuming
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * path of allocating the pad mblk.
bf8fc2340620695a402331e5da7c7db43264174det /* Zero it out. SCTP_ALIGN is sizeof (int32_t) */
f8d2de6bd2421da1926f3daa456d161670decdf7jchusctp_find_fast_rexmit_mblks(sctp_t *sctp, int *total, sctp_faddr_t **fp)
bf8fc2340620695a402331e5da7c7db43264174det for (meta = sctp->sctp_xmit_head; meta != NULL; meta = meta->b_next) {
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * Use the same peer address to do fast
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * retransmission. If the original peer
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * address is dead, switch to the current
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * one. Record the old one so that we
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * will pick the chunks sent to the old
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * one for fast retransmission.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * We still return at least the first message
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * even if that message cannot fit in as
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * PMTU may have changed.
08a74c0d0f6c3b94aa21216885efa4387c3d375cschwartz /* Clear the flag as there is no more message to be fast rexmitted. */
08a74c0d0f6c3b94aa21216885efa4387c3d375cschwartz/* A debug function just to make sure that a mblk chain is not broken */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Gets the next unsent chunk to transmit. Messages that are abandoned are
bf8fc2340620695a402331e5da7c7db43264174det * skipped. A message can be abandoned if it has a non-zero timetolive and
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * transmission has not yet started or if it is a partially reliable
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * message and its time is up (assuming we are PR-SCTP aware).
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * We only return a chunk if it will fit entirely in the current packet.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * 'cansend' is used to determine if need to try and chunkify messages from
bf8fc2340620695a402331e5da7c7db43264174det * the unsent list, if any, and also as an input to sctp_chunkify() if so.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * firstseg_len indicates the space already used, cansend represents remaining
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * space in the window, ((sfa_pmss - firstseg_len) can therefore reasonably
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * be used to compute the cansend arg).
bf8fc2340620695a402331e5da7c7db43264174detsctp_get_msg_to_send(sctp_t *sctp, mblk_t **mp, mblk_t *meta, int *error,
bf8fc2340620695a402331e5da7c7db43264174det int32_t firstseg_len, uint32_t cansend, sctp_faddr_t *fp)
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * If we come here and the first chunk is sent, then we
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * we are PR-SCTP aware, in which case if the cumulative
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * TSN has moved upto or beyond the first chunk (which
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * means all the previous messages have been cumulative
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * SACK'd), then we send a Forward TSN with the last
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * chunk that was sent in this message. If we can't send
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * a Forward TSN because previous non-abandoned messages
bf8fc2340620695a402331e5da7c7db43264174det * have not been acked then we will defer the Forward TSN
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * to sctp_rexmit() or sctp_cumack().
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if (*error != 0) {
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Update ULP the amount of queued data, which is
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * sent-unack'ed + unsent.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* chunkify, if needed */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * If user specified destination, try to honor that.
bf8fc2340620695a402331e5da7c7db43264174det meta = sctp_chunkify(sctp, fp->sfa_pmss, firstseg_len, cansend);
0168954460bd77d83497a4a6aa9c3f34c55dba25jchu * sctp_chunkify() won't advance sctp_xmit_tail if it adds
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * new chunk(s) to the tail, so we need to skip the
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * sctp_xmit_tail, which would have already been processed.
08a74c0d0f6c3b94aa21216885efa4387c3d375cschwartz * This could happen when there is unacked chunks, but
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * nothing new to send.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * When sctp_chunkify() is called when the transmit queue
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * is empty then we need to start from sctp_xmit_tail.
08a74c0d0f6c3b94aa21216885efa4387c3d375cschwartz if (SCTP_CHUNK_ISSENT(sctp->sctp_xmit_tail->b_cont)) {
f8d2de6bd2421da1926f3daa456d161670decdf7jchu ASSERT(sctp_verify_chain(sctp->sctp_xmit_head, sctp->sctp_xmit_tail));
bf8fc2340620695a402331e5da7c7db43264174det if ((head = sctp_add_proto_hdr(sctp, fp, mp, 0, NULL)) == NULL) {
bf8fc2340620695a402331e5da7c7db43264174det /* send a SACK chunk */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Start persist timer if unable to send or when
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * trying to send into a zero window. This timer
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * ensures the blocked send attempt is retried.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Find first segment eligible for transmit.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Check rwnd.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Pick destination address, and check cwnd.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if (sacklen > 0 && (seglen + extra <= lfp->cwnd - lfp->suna) &&
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Only include SACK chunk if it can be bundled
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * with a data chunk, and sent to sctp_lastdata.
bf8fc2340620695a402331e5da7c7db43264174det * If none of the source addresses are
bf8fc2340620695a402331e5da7c7db43264174det * available (i.e error == EHOSTUNREACH),
bf8fc2340620695a402331e5da7c7db43264174det * pretend we have sent the data. We will
bf8fc2340620695a402331e5da7c7db43264174det * eventually time out trying to retramsmit
bf8fc2340620695a402331e5da7c7db43264174det * the data if the interface never comes up.
bf8fc2340620695a402331e5da7c7db43264174det * If we have already sent some stuff (i.e.,
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * notsent is B_FALSE) then we are fine, else
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * just mark this packet as sent.
bf8fc2340620695a402331e5da7c7db43264174det * If we haven't sent data to this destination for
bf8fc2340620695a402331e5da7c7db43264174det * a while, do slow start again.
81f63062a60a29358c252e0d10807f8a8547fbb5arutz * If none of the source addresses are
81f63062a60a29358c252e0d10807f8a8547fbb5arutz * available (i.e error == EHOSTUNREACH),
81f63062a60a29358c252e0d10807f8a8547fbb5arutz * pretend we have sent the data. We will
81f63062a60a29358c252e0d10807f8a8547fbb5arutz * eventually time out trying to retramsmit
81f63062a60a29358c252e0d10807f8a8547fbb5arutz * the data if the interface never comes up.
81f63062a60a29358c252e0d10807f8a8547fbb5arutz * If we have already sent some stuff (i.e.,
81f63062a60a29358c252e0d10807f8a8547fbb5arutz * notsent is B_FALSE) then we are fine, else
81f63062a60a29358c252e0d10807f8a8547fbb5arutz * just mark this packet as sent.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Use this chunk to measure RTT?
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Must not be a retransmision of an earlier chunk,
81f63062a60a29358c252e0d10807f8a8547fbb5arutz * ensure the tsn is current.
81f63062a60a29358c252e0d10807f8a8547fbb5arutz if (sctp->sctp_out_time == 0 && tsn == (sctp->sctp_ltsn - 1)) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (extra > 0) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Bundle chunks. We linkb() the chunks together to send
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * downstream in a single packet.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Partial chunks MUST NOT be bundled with full chunks, so we
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * rely on sctp_get_msg_to_send() to only return messages that
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * will fit entirely in the current packet.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* If no more eligible chunks, cease bundling */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Path MTU is different from what we thought it would
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * be when we created chunks, or IP headers have grown.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Need to clear the DF bit.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* xmit segment */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl dprint(2, ("sctp_output: Sending packet %d bytes, tsn %x "
25cf1a301a396c38e8adf52c15f537b80d2483f7jl "ssn %d to %p (rwnd %d, cansend %d, lastack_rxd %x)\n",
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* arm rto timer (if not set) */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* arm persist timer (if rto timer not set) */
8bc7d88a7ed8565440a3cb4d316b626938433668et * The following two functions initialize and destroy the cache
bf8fc2340620695a402331e5da7c7db43264174det * associated with the sets used for PR-SCTP.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu sctp_kmem_ftsn_set_cache = kmem_cache_create("sctp_ftsn_set_cache",
f8d2de6bd2421da1926f3daa456d161670decdf7jchu/* Free PR-SCTP sets */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu while (s != NULL) {
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Given a message meta block, meta, this routine creates or modifies
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * the set that will be used to generate a Forward TSN chunk. If the
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * entry for stream id, sid, for this message already exists, the
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * sequence number, ssn, is updated if it is greater than the existing
8c3348818856b8366c07db7214dd7746a0aa3a07jchu * one. If an entry for this sid does not exist, one is created if
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * the size does not exceed fp->sfa_pmss. We return false in case
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * or an error.
f8d2de6bd2421da1926f3daa456d161670decdf7jchusctp_add_ftsn_set(sctp_ftsn_set_t **s, sctp_faddr_t *fp, mblk_t *meta,
f8d2de6bd2421da1926f3daa456d161670decdf7jchu sctp_msg_hdr_t *msg_hdr = (sctp_msg_hdr_t *)meta->b_rptr;
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* msg_hdr->smh_ssn is already in NBO */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu ASSERT((*nsets == 0 && *s == NULL) || (*nsets > 0 && *s != NULL));
bf8fc2340620695a402331e5da7c7db43264174det if (*s == NULL) {
bf8fc2340620695a402331e5da7c7db43264174det *s = kmem_cache_alloc(sctp_kmem_ftsn_set_cache, KM_NOSLEEP);
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if (*s == NULL)
bf8fc2340620695a402331e5da7c7db43264174det /* the last one */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Given a set of stream id - sequence number pairs, this routing creates
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * a Forward TSN chunk. The cumulative TSN (advanced peer ack point)
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * for the chunk is obtained from sctp->sctp_adv_pap. The caller
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * will add the IP/SCTP header.
f8d2de6bd2421da1926f3daa456d161670decdf7jchusctp_make_ftsn_chunk(sctp_t *sctp, sctp_faddr_t *fp, sctp_ftsn_set_t *sets,
f8d2de6bd2421da1926f3daa456d161670decdf7jchu xtralen = sctp->sctp_hdr_len + sctps->sctps_wroff_xtra;
f8d2de6bd2421da1926f3daa456d161670decdf7jchu xtralen = sctp->sctp_hdr6_len + sctps->sctps_wroff_xtra;
bf8fc2340620695a402331e5da7c7db43264174det * The cast here should not be an issue since seglen is
bf8fc2340620695a402331e5da7c7db43264174det * the length of the Forward TSN chunk.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu while (nsets > 0) {
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Given a starting message, the routine steps through all the
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * messages whose TSN is less than sctp->sctp_adv_pap and creates
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * ftsn sets. The ftsn sets is then used to create an Forward TSN
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * chunk. All the messages, that have chunks that are included in the
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * ftsn sets, are flagged abandonded. If a message is partially sent
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * and is deemed abandoned, all remaining unsent chunks are marked
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * abandoned and are deducted from sctp_unsent.
f8d2de6bd2421da1926f3daa456d161670decdf7jchusctp_make_ftsns(sctp_t *sctp, mblk_t *meta, mblk_t *mp, mblk_t **nmp,
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Skip adding FTSN sets for un-ordered messages as they do
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * not have SSNs.
bf8fc2340620695a402331e5da7c7db43264174det * Can't compare with sets == NULL, since we don't add any
bf8fc2340620695a402331e5da7c7db43264174det * sets for un-ordered messages.
bf8fc2340620695a402331e5da7c7db43264174det *nmp = sctp_make_ftsn_chunk(sctp, fp, sets, nsets, *seglen);
f0a73f0415a4150b270534bc7ed2cbb77d87c5a2schwartz (sizeof (sctp_sack_frag_t) * sctp->sctp_sack_gaps);
f0a73f0415a4150b270534bc7ed2cbb77d87c5a2schwartz if (*seglen + sacklen > sctp->sctp_lastdata->sfa_pmss) {
f0a73f0415a4150b270534bc7ed2cbb77d87c5a2schwartz /* piggybacked SACK doesn't fit */
f0a73f0415a4150b270534bc7ed2cbb77d87c5a2schwartz head = sctp_add_proto_hdr(sctp, fp, *nmp, sacklen, NULL);
f0a73f0415a4150b270534bc7ed2cbb77d87c5a2schwartz * XXXNeed to optimise this, the reason it is done here is so
f0a73f0415a4150b270534bc7ed2cbb77d87c5a2schwartz * that we don't have to undo in case of failure.
f0a73f0415a4150b270534bc7ed2cbb77d87c5a2schwartz SEQ_GEQ(sctp->sctp_adv_pap, ntohl(sdc->sdh_tsn))) {
8c3348818856b8366c07db7214dd7746a0aa3a07jchu * Update ULP the amount of queued data, which is
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * sent-unack'ed + unsent.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * This function steps through messages starting at meta and checks if
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * the message is abandoned. It stops when it hits an unsent chunk or
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * a message that has all its chunk acked. This is the only place
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * where the sctp_adv_pap is moved forward to indicated abandoned
bf8fc2340620695a402331e5da7c7db43264174det * messages.
bf8fc2340620695a402331e5da7c7db43264174detsctp_check_adv_ack_pt(sctp_t *sctp, mblk_t *meta, mblk_t *mp)
f8d2de6bd2421da1926f3daa456d161670decdf7jchu ASSERT(SEQ_GT(ntohl(sdc->sdh_tsn), sctp->sctp_lastack_rxd));
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * We continue checking for successive messages only if there
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * is a chunk marked for retransmission. Else, we might
bf8fc2340620695a402331e5da7c7db43264174det * end up sending FTSN prematurely for chunks that have been
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * sent, but not yet acked.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Determine if we should bundle a data chunk with the chunk being
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * retransmitted. We bundle if
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * - the chunk is sent to the same destination and unack'ed.
bf8fc2340620695a402331e5da7c7db43264174det * - the chunk is unsent, i.e. new data.
bf8fc2340620695a402331e5da7c7db43264174det ((SCTP_CHUNK_ISSENT((mp)) && (SCTP_CHUNK_DEST(mp) == (fp) && \
bf8fc2340620695a402331e5da7c7db43264174det (((mp)->b_flag & (SCTP_CHUNK_FLAG_REXMIT|SCTP_CHUNK_FLAG_SENT)) != \
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Retransmit first segment which hasn't been acked with cumtsn or send
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * a Forward TSN chunk, if appropriate.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * We break in the following cases -
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * if the advanced peer ack point includes the next
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * chunk to be retransmited - possibly the Forward
8c3348818856b8366c07db7214dd7746a0aa3a07jchu * TSN was lost.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * if we are PRSCTP aware and the next chunk to be
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * retransmitted is now abandoned
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * if the next chunk to be retransmitted is for
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * the dest on which the timer went off. (this
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * message is not abandoned).
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * We check for Forward TSN only for the first
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * eligible chunk to be retransmitted. The reason
bf8fc2340620695a402331e5da7c7db43264174det * being if the first eligible chunk is skipped (say
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * it was sent to a destination other than oldfp)
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * then we cannot advance the cum TSN via Forward
bf8fc2340620695a402331e5da7c7db43264174det * TSN chunk.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Also, ftsn_check is B_TRUE only for the first
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * eligible chunk, it will be B_FALSE for all
8c3348818856b8366c07db7214dd7746a0aa3a07jchu * subsequent candidate messages for retransmission.
bf8fc2340620695a402331e5da7c7db43264174det * Retransmit fired for a destination which didn't have
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * any unacked data pending.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if (sctp->sctp_unacked == 0 && sctp->sctp_unsent != 0) {
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Send a window probe. Inflate frwnd to allow
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * sending one segment.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if (sctp->sctp_frwnd < (oldfp->sfa_pmss - sizeof (*sdc)))
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* next TSN to send */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * The above sctp_frwnd adjustment is coarse. The "changed"
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * sctp_frwnd may allow us to send more than 1 packet. So
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * tell sctp_output() to send only 1 packet.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* Last sent TSN */
bf8fc2340620695a402331e5da7c7db43264174det * After a time out, assume that everything has left the network. So
bf8fc2340620695a402331e5da7c7db43264174det * we can clear rxt_unacked for the original peer address.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * If we were probing for zero window, don't adjust retransmission
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * variables, but the timer is still backed off.
8c3348818856b8366c07db7214dd7746a0aa3a07jchu * Get the Zero Win Probe for retrasmission, sctp_rxt_nxttsn
bf8fc2340620695a402331e5da7c7db43264174det * and sctp_rxt_maxtsn will specify the ZWP packet.
bf8fc2340620695a402331e5da7c7db43264174det pkt = sctp_rexmit_packet(sctp, &meta, &mp, fp, &pkt_len);
bf8fc2340620695a402331e5da7c7db43264174det * The strikes will be clear by sctp_faddr_alive() when the
bf8fc2340620695a402331e5da7c7db43264174det * other side sends us an ack.
bf8fc2340620695a402331e5da7c7db43264174det * Enter slowstart for this destination
bf8fc2340620695a402331e5da7c7db43264174det * Move to the next unabandoned chunk. XXXCheck if meta will
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * always be marked abandoned.
bf8fc2340620695a402331e5da7c7db43264174det /* Find out if we need to piggyback SACK. */
1ff6511282dda236fdea133a0fc53438d8c4f5fdegillett (sizeof (sctp_sack_frag_t) * sctp->sctp_sack_gaps);
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if (seglen + sacklen > sctp->sctp_lastdata->sfa_pmss) {
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* piggybacked SACK doesn't fit */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * OK, we have room to send SACK back. But we
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * should send it back to the last fp where we
bf8fc2340620695a402331e5da7c7db43264174det * receive data from, unless sctp_lastdata equals
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * oldfp, then we should probably not send it
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * back to that fp. Also we should check that
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * the fp is alive.
bf8fc2340620695a402331e5da7c7db43264174det * Cancel RTT measurement if the retransmitted TSN is before the
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * TSN used for timimg.
07d06da50d310a325b457d6330165aebab1e0064Surya Prakki /* Clear the counter as the RTT calculation may be off. */
bf8fc2340620695a402331e5da7c7db43264174det * After a timeout, we should change the current faddr so that
1ff6511282dda236fdea133a0fc53438d8c4f5fdegillett * new chunks will be sent to the alternate address.
1a887b2e15e4d9b63b5add57f3334b5b31960018jchu head = sctp_add_proto_hdr(sctp, fp, nmp, sacklen, NULL);
f9721e075222d67dfc8cab85ccca4a17f1eb8325jchu /* We can at least and at most send 1 packet at timeout. */
f9721e075222d67dfc8cab85ccca4a17f1eb8325jchu /* Go through the list to find more chunks to be bundled. */
f9721e075222d67dfc8cab85ccca4a17f1eb8325jchu /* Check if the chunk can be bundled. */
1a887b2e15e4d9b63b5add57f3334b5b31960018jchu /* Go to the next message. */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Check if there is a new message which potentially
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * could be bundled with this retransmission.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* No more chunk to be bundled. */
bf8fc2340620695a402331e5da7c7db43264174det if (extra > 0) {
455c986069737584e38ba5b6e84f6052bebc0cf9krishnae * Path MTU is different from path we thought it would
bf8fc2340620695a402331e5da7c7db43264174det * be when we created chunks, or IP headers have grown.
1ff6511282dda236fdea133a0fc53438d8c4f5fdegillett * Need to clear the DF bit.
8bc7d88a7ed8565440a3cb4d316b626938433668et dprint(2, ("sctp_rexmit: Sending packet %d bytes, tsn %x "
bf8fc2340620695a402331e5da7c7db43264174det "ssn %d to %p (rwnd %d, lastack_rxd %x)\n",
8bc7d88a7ed8565440a3cb4d316b626938433668et * Restart the oldfp timer with exponential backoff and
8bc7d88a7ed8565440a3cb4d316b626938433668et * the new fp timer for the retransmitted chunks.
8bc7d88a7ed8565440a3cb4d316b626938433668et * If there is still some data in the oldfp, restart the
8bc7d88a7ed8565440a3cb4d316b626938433668et * retransmission timer. If there is no data, the heartbeat will
8bc7d88a7ed8565440a3cb4d316b626938433668et * continue to run so it will do its job in checking the reachability
8bc7d88a7ed8565440a3cb4d316b626938433668et * of the oldfp.
8bc7d88a7ed8565440a3cb4d316b626938433668et * Should we restart the timer of the new fp? If there is
8bc7d88a7ed8565440a3cb4d316b626938433668et * outstanding data to the new fp, the timer should be
8c3348818856b8366c07db7214dd7746a0aa3a07jchu * running already. So restarting it means that the timer
8bc7d88a7ed8565440a3cb4d316b626938433668et * will fire later for those outstanding data. But if
8bc7d88a7ed8565440a3cb4d316b626938433668et * we don't restart it, the timer will fire too early for the
8bc7d88a7ed8565440a3cb4d316b626938433668et * just retransmitted chunks to the new fp. The reason is that we
8bc7d88a7ed8565440a3cb4d316b626938433668et * don't keep a timestamp on when a chunk is retransmitted.
8c3348818856b8366c07db7214dd7746a0aa3a07jchu * So when the timer fires, it will just search for the
8bc7d88a7ed8565440a3cb4d316b626938433668et * chunk with the earliest TSN sent to new fp. This probably
8bc7d88a7ed8565440a3cb4d316b626938433668et * is the chunk we just retransmitted. So for now, let's
8bc7d88a7ed8565440a3cb4d316b626938433668et * be conservative and restart the timer of the new fp.
8bc7d88a7ed8565440a3cb4d316b626938433668et * This function is called by sctp_ss_rexmit() to create a packet
8bc7d88a7ed8565440a3cb4d316b626938433668et * to be retransmitted to the given fp. The given meta and mp
8bc7d88a7ed8565440a3cb4d316b626938433668et * parameters are respectively the sctp_msg_hdr_t and the mblk of the
8bc7d88a7ed8565440a3cb4d316b626938433668et * first chunk to be retransmitted. This is also called when we want
bf8fc2340620695a402331e5da7c7db43264174det * to retransmit a zero window probe from sctp_rexmit() or when we
8bc7d88a7ed8565440a3cb4d316b626938433668et * want to retransmit the zero window probe after the window has
8bc7d88a7ed8565440a3cb4d316b626938433668et * opened from sctp_got_sack().
8bc7d88a7ed8565440a3cb4d316b626938433668etsctp_rexmit_packet(sctp_t *sctp, mblk_t **meta, mblk_t **mp, sctp_faddr_t *fp,
8bc7d88a7ed8565440a3cb4d316b626938433668et if (extra > 0) {
8bc7d88a7ed8565440a3cb4d316b626938433668et * Don't update the TSN if we are doing a Zero Win Probe.
8bc7d88a7ed8565440a3cb4d316b626938433668et * Go through the list to find more chunks to be bundled.
8bc7d88a7ed8565440a3cb4d316b626938433668et * We should only retransmit sent by unack'ed chunks. Since
8bc7d88a7ed8565440a3cb4d316b626938433668et * they were sent before, the peer's receive window should
8bc7d88a7ed8565440a3cb4d316b626938433668et * be able to receive them.
8bc7d88a7ed8565440a3cb4d316b626938433668et /* Check if the chunk can be bundled. */
bf8fc2340620695a402331e5da7c7db43264174det /* Go to the next message. */
8bc7d88a7ed8565440a3cb4d316b626938433668et /* No more chunk to be bundled. */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* Don't bundle chunks beyond sctp_rxt_maxtsn. */
8c3348818856b8366c07db7214dd7746a0aa3a07jchu if (SEQ_GT(ntohl(sdc->sdh_tsn), sctp->sctp_rxt_maxtsn))
f8d2de6bd2421da1926f3daa456d161670decdf7jchu if ((new_len = seglen + new_len + extra) > fp->sfa_pmss)
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * Don't update the TSN if we are doing a Zero Win Probe.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * sctp_ss_rexmit() is called when we get a SACK after a timeout which
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * advances the cum_tsn but the cum_tsn is still less than what we have sent
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * (sctp_rxt_maxtsn) at the time of the timeout. This SACK is a "partial"
bf8fc2340620695a402331e5da7c7db43264174det * SACK. We retransmit unacked chunks without having to wait for another
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * timeout. The rationale is that the SACK should not be "partial" if all the
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * lost chunks have been retransmitted. Since the SACK is "partial,"
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * the chunks between the cum_tsn and the sctp_rxt_maxtsn should still
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * be missing. It is better for us to retransmit them now instead
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * of waiting for a timeout.
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * If the last cum ack is smaller than what we have just
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * retransmitted, simply return.
bf8fc2340620695a402331e5da7c7db43264174det if (SEQ_GEQ(sctp->sctp_lastack_rxd, sctp->sctp_rxt_nxttsn))
bf8fc2340620695a402331e5da7c7db43264174det ASSERT(SEQ_LEQ(sctp->sctp_rxt_nxttsn, sctp->sctp_rxt_maxtsn));
bf8fc2340620695a402331e5da7c7db43264174det * After a timer fires, sctp_current should be set to the new
bf8fc2340620695a402331e5da7c7db43264174det * fp where the retransmitted chunks are sent.
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * Since we are retransmitting, we only need to use cwnd to determine
bf8fc2340620695a402331e5da7c7db43264174det * how much we can send as we were allowed (by peer's receive window)
bf8fc2340620695a402331e5da7c7db43264174det * to send those retransmitted chunks previously when they are first
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * sent. If we record how much we have retransmitted but
bf8fc2340620695a402331e5da7c7db43264174det * unacknowledged using rxt_unacked, then the amount we can now send
bf8fc2340620695a402331e5da7c7db43264174det * is equal to cwnd minus rxt_unacked.
eae2e508a8e70b1ec407b10bd068c080651bbe5ckrishnae * The field rxt_unacked is incremented when we retransmit a packet
bf8fc2340620695a402331e5da7c7db43264174det * and decremented when we got a SACK acknowledging something. And
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * it is reset when the retransmission timer fires as we assume that
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * all packets have left the network after a timeout. If this
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * assumption is not true, it means that after a timeout, we can
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * get a SACK acknowledging more than rxt_unacked (its value only
8c3348818856b8366c07db7214dd7746a0aa3a07jchu * contains what is retransmitted when the timer fires). So
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * rxt_unacked will become very big (it is an unsiged int so going
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * negative means that the value is huge). This is the reason we
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * always send at least 1 MSS bytes.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * The reason why we do not have an accurate count is that we
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * only know how many packets are outstanding (using the TSN numbers).
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * But we do not know how many bytes those packets contain. To
f8d2de6bd2421da1926f3daa456d161670decdf7jchu * have an accurate count, we need to walk through the send list.
bf8fc2340620695a402331e5da7c7db43264174det * As it is not really important to have an accurate count during
bf8fc2340620695a402331e5da7c7db43264174det * retransmission, we skip this walk to save some time. This should
bf8fc2340620695a402331e5da7c7db43264174det * not make the retransmission too aggressive to cause congestion.
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* Find the first unack'ed chunk */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu for (meta = sctp->sctp_xmit_head; meta != NULL; meta = meta->b_next) {
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* Again, this may not be possible */
f8d2de6bd2421da1926f3daa456d161670decdf7jchu /* Everything is abandoned... */
goto found_msg;