160c778b2SVlad Yasevich /* SCTP kernel implementation 21da177e4SLinus Torvalds * (C) Copyright IBM Corp. 2003, 2004 31da177e4SLinus Torvalds * 460c778b2SVlad Yasevich * This file is part of the SCTP kernel implementation 51da177e4SLinus Torvalds * 659c51591SMichael Opdenacker * This file contains the code relating the chunk abstraction. 71da177e4SLinus Torvalds * 860c778b2SVlad Yasevich * This SCTP implementation is free software; 91da177e4SLinus Torvalds * you can redistribute it and/or modify it under the terms of 101da177e4SLinus Torvalds * the GNU General Public License as published by 111da177e4SLinus Torvalds * the Free Software Foundation; either version 2, or (at your option) 121da177e4SLinus Torvalds * any later version. 131da177e4SLinus Torvalds * 1460c778b2SVlad Yasevich * This SCTP implementation is distributed in the hope that it 151da177e4SLinus Torvalds * will be useful, but WITHOUT ANY WARRANTY; without even the implied 161da177e4SLinus Torvalds * ************************ 171da177e4SLinus Torvalds * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 181da177e4SLinus Torvalds * See the GNU General Public License for more details. 191da177e4SLinus Torvalds * 201da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License 214b2f13a2SJeff Kirsher * along with GNU CC; see the file COPYING. If not, see 224b2f13a2SJeff Kirsher * <http://www.gnu.org/licenses/>. 231da177e4SLinus Torvalds * 241da177e4SLinus Torvalds * Please send any bug reports or fixes you make to the 251da177e4SLinus Torvalds * email address(es): 2691705c61SDaniel Borkmann * lksctp developers <linux-sctp@vger.kernel.org> 271da177e4SLinus Torvalds * 281da177e4SLinus Torvalds * Written or modified by: 291da177e4SLinus Torvalds * Jon Grimm <jgrimm@us.ibm.com> 301da177e4SLinus Torvalds * Sridhar Samudrala <sri@us.ibm.com> 311da177e4SLinus Torvalds */ 321da177e4SLinus Torvalds 33145ce502SJoe Perches #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 34145ce502SJoe Perches 351da177e4SLinus Torvalds #include <linux/types.h> 361da177e4SLinus Torvalds #include <linux/kernel.h> 371da177e4SLinus Torvalds #include <linux/net.h> 381da177e4SLinus Torvalds #include <linux/inet.h> 391da177e4SLinus Torvalds #include <linux/skbuff.h> 405a0e3ad6STejun Heo #include <linux/slab.h> 411da177e4SLinus Torvalds #include <net/sock.h> 421da177e4SLinus Torvalds #include <net/sctp/sctp.h> 431da177e4SLinus Torvalds #include <net/sctp/sm.h> 441da177e4SLinus Torvalds 451da177e4SLinus Torvalds /* This file is mostly in anticipation of future work, but initially 461da177e4SLinus Torvalds * populate with fragment tracking for an outbound message. 471da177e4SLinus Torvalds */ 481da177e4SLinus Torvalds 491da177e4SLinus Torvalds /* Initialize datamsg from memory. */ 501da177e4SLinus Torvalds static void sctp_datamsg_init(struct sctp_datamsg *msg) 511da177e4SLinus Torvalds { 52c0acdfb4SReshetova, Elena refcount_set(&msg->refcnt, 1); 531da177e4SLinus Torvalds msg->send_failed = 0; 541da177e4SLinus Torvalds msg->send_error = 0; 550e3aef8dSVlad Yasevich msg->can_delay = 1; 56e5f61296SXin Long msg->abandoned = 0; 571da177e4SLinus Torvalds msg->expires_at = 0; 581da177e4SLinus Torvalds INIT_LIST_HEAD(&msg->chunks); 591da177e4SLinus Torvalds } 601da177e4SLinus Torvalds 611da177e4SLinus Torvalds /* Allocate and initialize datamsg. */ 62dda91928SDaniel Borkmann static struct sctp_datamsg *sctp_datamsg_new(gfp_t gfp) 631da177e4SLinus Torvalds { 641da177e4SLinus Torvalds struct sctp_datamsg *msg; 651da177e4SLinus Torvalds msg = kmalloc(sizeof(struct sctp_datamsg), gfp); 66e8c38751SLi Zefan if (msg) { 671da177e4SLinus Torvalds sctp_datamsg_init(msg); 681da177e4SLinus Torvalds SCTP_DBG_OBJCNT_INC(datamsg); 69e8c38751SLi Zefan } 701da177e4SLinus Torvalds return msg; 711da177e4SLinus Torvalds } 721da177e4SLinus Torvalds 73b61c654fSXin Long void sctp_datamsg_free(struct sctp_datamsg *msg) 74b61c654fSXin Long { 75b61c654fSXin Long struct sctp_chunk *chunk; 76b61c654fSXin Long 77b61c654fSXin Long /* This doesn't have to be a _safe vairant because 78b61c654fSXin Long * sctp_chunk_free() only drops the refs. 79b61c654fSXin Long */ 80b61c654fSXin Long list_for_each_entry(chunk, &msg->chunks, frag_list) 81b61c654fSXin Long sctp_chunk_free(chunk); 82b61c654fSXin Long 83b61c654fSXin Long sctp_datamsg_put(msg); 84b61c654fSXin Long } 85b61c654fSXin Long 861da177e4SLinus Torvalds /* Final destructruction of datamsg memory. */ 871da177e4SLinus Torvalds static void sctp_datamsg_destroy(struct sctp_datamsg *msg) 881da177e4SLinus Torvalds { 891da177e4SLinus Torvalds struct list_head *pos, *temp; 901da177e4SLinus Torvalds struct sctp_chunk *chunk; 911da177e4SLinus Torvalds struct sctp_sock *sp; 921da177e4SLinus Torvalds struct sctp_ulpevent *ev; 931da177e4SLinus Torvalds struct sctp_association *asoc = NULL; 941da177e4SLinus Torvalds int error = 0, notify; 951da177e4SLinus Torvalds 961da177e4SLinus Torvalds /* If we failed, we may need to notify. */ 971da177e4SLinus Torvalds notify = msg->send_failed ? -1 : 0; 981da177e4SLinus Torvalds 991da177e4SLinus Torvalds /* Release all references. */ 1001da177e4SLinus Torvalds list_for_each_safe(pos, temp, &msg->chunks) { 1011da177e4SLinus Torvalds list_del_init(pos); 1021da177e4SLinus Torvalds chunk = list_entry(pos, struct sctp_chunk, frag_list); 1031da177e4SLinus Torvalds /* Check whether we _really_ need to notify. */ 1041da177e4SLinus Torvalds if (notify < 0) { 1051da177e4SLinus Torvalds asoc = chunk->asoc; 1061da177e4SLinus Torvalds if (msg->send_error) 1071da177e4SLinus Torvalds error = msg->send_error; 1081da177e4SLinus Torvalds else 1091da177e4SLinus Torvalds error = asoc->outqueue.error; 1101da177e4SLinus Torvalds 1111da177e4SLinus Torvalds sp = sctp_sk(asoc->base.sk); 1121da177e4SLinus Torvalds notify = sctp_ulpevent_type_enabled(SCTP_SEND_FAILED, 1131da177e4SLinus Torvalds &sp->subscribe); 1141da177e4SLinus Torvalds } 1151da177e4SLinus Torvalds 1161da177e4SLinus Torvalds /* Generate a SEND FAILED event only if enabled. */ 1171da177e4SLinus Torvalds if (notify > 0) { 1181da177e4SLinus Torvalds int sent; 1191da177e4SLinus Torvalds if (chunk->has_tsn) 1201da177e4SLinus Torvalds sent = SCTP_DATA_SENT; 1211da177e4SLinus Torvalds else 1221da177e4SLinus Torvalds sent = SCTP_DATA_UNSENT; 1231da177e4SLinus Torvalds 1241da177e4SLinus Torvalds ev = sctp_ulpevent_make_send_failed(asoc, chunk, sent, 1251da177e4SLinus Torvalds error, GFP_ATOMIC); 1261da177e4SLinus Torvalds if (ev) 1279162e0edSXin Long asoc->stream.si->enqueue_event(&asoc->ulpq, ev); 1281da177e4SLinus Torvalds } 1291da177e4SLinus Torvalds 1301da177e4SLinus Torvalds sctp_chunk_put(chunk); 1311da177e4SLinus Torvalds } 1321da177e4SLinus Torvalds 1331da177e4SLinus Torvalds SCTP_DBG_OBJCNT_DEC(datamsg); 1341da177e4SLinus Torvalds kfree(msg); 1351da177e4SLinus Torvalds } 1361da177e4SLinus Torvalds 1371da177e4SLinus Torvalds /* Hold a reference. */ 1381da177e4SLinus Torvalds static void sctp_datamsg_hold(struct sctp_datamsg *msg) 1391da177e4SLinus Torvalds { 140c0acdfb4SReshetova, Elena refcount_inc(&msg->refcnt); 1411da177e4SLinus Torvalds } 1421da177e4SLinus Torvalds 1431da177e4SLinus Torvalds /* Release a reference. */ 1441da177e4SLinus Torvalds void sctp_datamsg_put(struct sctp_datamsg *msg) 1451da177e4SLinus Torvalds { 146c0acdfb4SReshetova, Elena if (refcount_dec_and_test(&msg->refcnt)) 1471da177e4SLinus Torvalds sctp_datamsg_destroy(msg); 1481da177e4SLinus Torvalds } 1491da177e4SLinus Torvalds 1501da177e4SLinus Torvalds /* Assign a chunk to this datamsg. */ 1511da177e4SLinus Torvalds static void sctp_datamsg_assign(struct sctp_datamsg *msg, struct sctp_chunk *chunk) 1521da177e4SLinus Torvalds { 1531da177e4SLinus Torvalds sctp_datamsg_hold(msg); 1541da177e4SLinus Torvalds chunk->msg = msg; 1551da177e4SLinus Torvalds } 1561da177e4SLinus Torvalds 1571da177e4SLinus Torvalds 1581da177e4SLinus Torvalds /* A data chunk can have a maximum payload of (2^16 - 20). Break 1591da177e4SLinus Torvalds * down any such message into smaller chunks. Opportunistically, fragment 1601da177e4SLinus Torvalds * the chunks down to the current MTU constraints. We may get refragmented 1611da177e4SLinus Torvalds * later if the PMTU changes, but it is _much better_ to fragment immediately 1621da177e4SLinus Torvalds * with a reasonable guess than always doing our fragmentation on the 1631da177e4SLinus Torvalds * soft-interrupt. 1641da177e4SLinus Torvalds */ 1651da177e4SLinus Torvalds struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc, 1661da177e4SLinus Torvalds struct sctp_sndrcvinfo *sinfo, 167e0eb093eSAl Viro struct iov_iter *from) 1681da177e4SLinus Torvalds { 169bfd2e4b8SMarcelo Ricardo Leitner size_t len, first_len, max_data, remaining; 170bfd2e4b8SMarcelo Ricardo Leitner size_t msg_len = iov_iter_count(from); 1711b1e0bc9SXin Long struct sctp_shared_key *shkey = NULL; 172bfd2e4b8SMarcelo Ricardo Leitner struct list_head *pos, *temp; 1731da177e4SLinus Torvalds struct sctp_chunk *chunk; 1741da177e4SLinus Torvalds struct sctp_datamsg *msg; 175bfd2e4b8SMarcelo Ricardo Leitner int err; 1761da177e4SLinus Torvalds 1771da177e4SLinus Torvalds msg = sctp_datamsg_new(GFP_KERNEL); 1781da177e4SLinus Torvalds if (!msg) 1796e51fe75STommi Rantala return ERR_PTR(-ENOMEM); 1801da177e4SLinus Torvalds 1811da177e4SLinus Torvalds /* Note: Calculate this outside of the loop, so that all fragments 1821da177e4SLinus Torvalds * have the same expiration. 1831da177e4SLinus Torvalds */ 1848ae808ebSXin Long if (asoc->peer.prsctp_capable && sinfo->sinfo_timetolive && 1858ae808ebSXin Long (SCTP_PR_TTL_ENABLED(sinfo->sinfo_flags) || 1868ae808ebSXin Long !SCTP_PR_POLICY(sinfo->sinfo_flags))) 1871da177e4SLinus Torvalds msg->expires_at = jiffies + 1881da177e4SLinus Torvalds msecs_to_jiffies(sinfo->sinfo_timetolive); 1890605483fSXin Long 1903e62abf9SVlad Yasevich /* This is the biggest possible DATA chunk that can fit into 1913e62abf9SVlad Yasevich * the packet 1923e62abf9SVlad Yasevich */ 1932f5e3c9dSMarcelo Ricardo Leitner max_data = asoc->frag_point; 194*afd0a800SJakub Audykowicz if (unlikely(!max_data)) { 195*afd0a800SJakub Audykowicz max_data = sctp_min_frag_point(sctp_sk(asoc->base.sk), 196*afd0a800SJakub Audykowicz sctp_datachk_len(&asoc->stream)); 197*afd0a800SJakub Audykowicz pr_warn_ratelimited("%s: asoc:%p frag_point is zero, forcing max_data to default minimum (%Zu)", 198*afd0a800SJakub Audykowicz __func__, asoc, max_data); 199*afd0a800SJakub Audykowicz } 2001da177e4SLinus Torvalds 2014cd57c80SVlad Yasevich /* If the the peer requested that we authenticate DATA chunks 2022bccbadfSwangweidong * we need to account for bundling of the AUTH chunks along with 2034cd57c80SVlad Yasevich * DATA. 2044cd57c80SVlad Yasevich */ 2054cd57c80SVlad Yasevich if (sctp_auth_send_cid(SCTP_CID_DATA, asoc)) { 2064cd57c80SVlad Yasevich struct sctp_hmac *hmac_desc = sctp_auth_asoc_get_hmac(asoc); 2074cd57c80SVlad Yasevich 2084cd57c80SVlad Yasevich if (hmac_desc) 209bb96dec7SXin Long max_data -= SCTP_PAD4(sizeof(struct sctp_auth_chunk) + 2104cd57c80SVlad Yasevich hmac_desc->hmac_len); 2111b1e0bc9SXin Long 2123ff547c0SXin Long if (sinfo->sinfo_tsn && 2133ff547c0SXin Long sinfo->sinfo_ssn != asoc->active_key_id) { 2143ff547c0SXin Long shkey = sctp_auth_get_shkey(asoc, sinfo->sinfo_ssn); 2153ff547c0SXin Long if (!shkey) { 2163ff547c0SXin Long err = -EINVAL; 2173ff547c0SXin Long goto errout; 2183ff547c0SXin Long } 2193ff547c0SXin Long } else { 2201b1e0bc9SXin Long shkey = asoc->shkey; 2214cd57c80SVlad Yasevich } 2223ff547c0SXin Long } 2234cd57c80SVlad Yasevich 224bfd2e4b8SMarcelo Ricardo Leitner /* Set first_len and then account for possible bundles on first frag */ 225bfd2e4b8SMarcelo Ricardo Leitner first_len = max_data; 2261da177e4SLinus Torvalds 2275d7ff261SVlad Yasevich /* Check to see if we have a pending SACK and try to let it be bundled 2285d7ff261SVlad Yasevich * with this message. Do this if we don't have any data queued already. 2295d7ff261SVlad Yasevich * To check that, look at out_qlen and retransmit list. 2305d7ff261SVlad Yasevich * NOTE: we will not reduce to account for SACK, if the message would 2315d7ff261SVlad Yasevich * not have been fragmented. 2325d7ff261SVlad Yasevich */ 2335d7ff261SVlad Yasevich if (timer_pending(&asoc->timers[SCTP_EVENT_TIMEOUT_SACK]) && 2345d7ff261SVlad Yasevich asoc->outqueue.out_qlen == 0 && 2355d7ff261SVlad Yasevich list_empty(&asoc->outqueue.retransmit) && 236bfd2e4b8SMarcelo Ricardo Leitner msg_len > max_data) 237d4d6c614SXin Long first_len -= SCTP_PAD4(sizeof(struct sctp_sack_chunk)); 2385d7ff261SVlad Yasevich 2391da177e4SLinus Torvalds /* Encourage Cookie-ECHO bundling. */ 2405d7ff261SVlad Yasevich if (asoc->state < SCTP_STATE_COOKIE_ECHOED) 241bfd2e4b8SMarcelo Ricardo Leitner first_len -= SCTP_ARBITRARY_COOKIE_ECHO_LEN; 2423e62abf9SVlad Yasevich 2433e62abf9SVlad Yasevich /* Account for a different sized first fragment */ 2443e62abf9SVlad Yasevich if (msg_len >= first_len) { 2450e3aef8dSVlad Yasevich msg->can_delay = 0; 246fedb1bd3SMarcelo Ricardo Leitner if (msg_len > first_len) 247fedb1bd3SMarcelo Ricardo Leitner SCTP_INC_STATS(sock_net(asoc->base.sk), 248fedb1bd3SMarcelo Ricardo Leitner SCTP_MIB_FRAGUSRMSGS); 249bfd2e4b8SMarcelo Ricardo Leitner } else { 250bfd2e4b8SMarcelo Ricardo Leitner /* Which may be the only one... */ 251bfd2e4b8SMarcelo Ricardo Leitner first_len = msg_len; 2521da177e4SLinus Torvalds } 2531da177e4SLinus Torvalds 254bfd2e4b8SMarcelo Ricardo Leitner /* Create chunks for all DATA chunks. */ 255bfd2e4b8SMarcelo Ricardo Leitner for (remaining = msg_len; remaining; remaining -= len) { 256bfd2e4b8SMarcelo Ricardo Leitner u8 frag = SCTP_DATA_MIDDLE_FRAG; 2571da177e4SLinus Torvalds 258bfd2e4b8SMarcelo Ricardo Leitner if (remaining == msg_len) { 259bfd2e4b8SMarcelo Ricardo Leitner /* First frag, which may also be the last */ 2601da177e4SLinus Torvalds frag |= SCTP_DATA_FIRST_FRAG; 261bfd2e4b8SMarcelo Ricardo Leitner len = first_len; 262bfd2e4b8SMarcelo Ricardo Leitner } else { 263bfd2e4b8SMarcelo Ricardo Leitner /* Middle frags */ 264bfd2e4b8SMarcelo Ricardo Leitner len = max_data; 265bfd2e4b8SMarcelo Ricardo Leitner } 2661da177e4SLinus Torvalds 267bfd2e4b8SMarcelo Ricardo Leitner if (len >= remaining) { 268bfd2e4b8SMarcelo Ricardo Leitner /* Last frag, which may also be the first */ 269bfd2e4b8SMarcelo Ricardo Leitner len = remaining; 2701da177e4SLinus Torvalds frag |= SCTP_DATA_LAST_FRAG; 2711da177e4SLinus Torvalds 272b93d6471SWei Yongjun /* The application requests to set the I-bit of the 273b93d6471SWei Yongjun * last DATA chunk of a user message when providing 274b93d6471SWei Yongjun * the user message to the SCTP implementation. 275b93d6471SWei Yongjun */ 276b93d6471SWei Yongjun if ((sinfo->sinfo_flags & SCTP_EOF) || 277b93d6471SWei Yongjun (sinfo->sinfo_flags & SCTP_SACK_IMMEDIATELY)) 278b93d6471SWei Yongjun frag |= SCTP_DATA_SACK_IMM; 279b93d6471SWei Yongjun } 280b93d6471SWei Yongjun 2810c3f6f65SXin Long chunk = asoc->stream.si->make_datafrag(asoc, sinfo, len, frag, 2820c3f6f65SXin Long GFP_KERNEL); 2836e51fe75STommi Rantala if (!chunk) { 2846e51fe75STommi Rantala err = -ENOMEM; 2851da177e4SLinus Torvalds goto errout; 2866e51fe75STommi Rantala } 2876e51fe75STommi Rantala 288e0eb093eSAl Viro err = sctp_user_addto_chunk(chunk, len, from); 2891da177e4SLinus Torvalds if (err < 0) 290be364c8cSTommi Rantala goto errout_chunk_free; 2911da177e4SLinus Torvalds 2921b1e0bc9SXin Long chunk->shkey = shkey; 2931b1e0bc9SXin Long 2941da177e4SLinus Torvalds /* Put the chunk->skb back into the form expected by send. */ 295bfd2e4b8SMarcelo Ricardo Leitner __skb_pull(chunk->skb, (__u8 *)chunk->chunk_hdr - 296bfd2e4b8SMarcelo Ricardo Leitner chunk->skb->data); 2971da177e4SLinus Torvalds 2981da177e4SLinus Torvalds sctp_datamsg_assign(msg, chunk); 2991da177e4SLinus Torvalds list_add_tail(&chunk->frag_list, &msg->chunks); 3001da177e4SLinus Torvalds } 3011da177e4SLinus Torvalds 3021da177e4SLinus Torvalds return msg; 3031da177e4SLinus Torvalds 304be364c8cSTommi Rantala errout_chunk_free: 305be364c8cSTommi Rantala sctp_chunk_free(chunk); 306be364c8cSTommi Rantala 3071da177e4SLinus Torvalds errout: 3081da177e4SLinus Torvalds list_for_each_safe(pos, temp, &msg->chunks) { 3091da177e4SLinus Torvalds list_del_init(pos); 3101da177e4SLinus Torvalds chunk = list_entry(pos, struct sctp_chunk, frag_list); 3111da177e4SLinus Torvalds sctp_chunk_free(chunk); 3121da177e4SLinus Torvalds } 31380445cfbSFlorian Westphal sctp_datamsg_put(msg); 314bfd2e4b8SMarcelo Ricardo Leitner 3156e51fe75STommi Rantala return ERR_PTR(err); 3161da177e4SLinus Torvalds } 3171da177e4SLinus Torvalds 3181da177e4SLinus Torvalds /* Check whether this message has expired. */ 3191da177e4SLinus Torvalds int sctp_chunk_abandoned(struct sctp_chunk *chunk) 3201da177e4SLinus Torvalds { 3218ae808ebSXin Long if (!chunk->asoc->peer.prsctp_capable) 3221da177e4SLinus Torvalds return 0; 3231da177e4SLinus Torvalds 324e5f61296SXin Long if (chunk->msg->abandoned) 325e5f61296SXin Long return 1; 326e5f61296SXin Long 327779edd73SXin Long if (!chunk->has_tsn && 328779edd73SXin Long !(chunk->chunk_hdr->flags & SCTP_DATA_FIRST_FRAG)) 329779edd73SXin Long return 0; 330779edd73SXin Long 331a6c2f792SXin Long if (SCTP_PR_TTL_ENABLED(chunk->sinfo.sinfo_flags) && 3320605483fSXin Long time_after(jiffies, chunk->msg->expires_at)) { 333d229d48dSXin Long struct sctp_stream_out *streamout = 33405364ca0SKonstantin Khorenko SCTP_SO(&chunk->asoc->stream, 33505364ca0SKonstantin Khorenko chunk->sinfo.sinfo_stream); 336d229d48dSXin Long 337d229d48dSXin Long if (chunk->sent_count) { 338a6c2f792SXin Long chunk->asoc->abandoned_sent[SCTP_PR_INDEX(TTL)]++; 339f952be79SMarcelo Ricardo Leitner streamout->ext->abandoned_sent[SCTP_PR_INDEX(TTL)]++; 340d229d48dSXin Long } else { 341a6c2f792SXin Long chunk->asoc->abandoned_unsent[SCTP_PR_INDEX(TTL)]++; 342f952be79SMarcelo Ricardo Leitner streamout->ext->abandoned_unsent[SCTP_PR_INDEX(TTL)]++; 343d229d48dSXin Long } 344e5f61296SXin Long chunk->msg->abandoned = 1; 345a6c2f792SXin Long return 1; 34601aadb3aSXin Long } else if (SCTP_PR_RTX_ENABLED(chunk->sinfo.sinfo_flags) && 3470605483fSXin Long chunk->sent_count > chunk->sinfo.sinfo_timetolive) { 348d229d48dSXin Long struct sctp_stream_out *streamout = 34905364ca0SKonstantin Khorenko SCTP_SO(&chunk->asoc->stream, 35005364ca0SKonstantin Khorenko chunk->sinfo.sinfo_stream); 351d229d48dSXin Long 35201aadb3aSXin Long chunk->asoc->abandoned_sent[SCTP_PR_INDEX(RTX)]++; 353f952be79SMarcelo Ricardo Leitner streamout->ext->abandoned_sent[SCTP_PR_INDEX(RTX)]++; 354e5f61296SXin Long chunk->msg->abandoned = 1; 35501aadb3aSXin Long return 1; 3568ae808ebSXin Long } else if (!SCTP_PR_POLICY(chunk->sinfo.sinfo_flags) && 3578ae808ebSXin Long chunk->msg->expires_at && 3588ae808ebSXin Long time_after(jiffies, chunk->msg->expires_at)) { 359e5f61296SXin Long chunk->msg->abandoned = 1; 3608ae808ebSXin Long return 1; 361a6c2f792SXin Long } 3628dbdf1f5SXin Long /* PRIO policy is processed by sendmsg, not here */ 363a6c2f792SXin Long 364a6c2f792SXin Long return 0; 365a6c2f792SXin Long } 366a6c2f792SXin Long 3671da177e4SLinus Torvalds /* This chunk (and consequently entire message) has failed in its sending. */ 3681da177e4SLinus Torvalds void sctp_chunk_fail(struct sctp_chunk *chunk, int error) 3691da177e4SLinus Torvalds { 3701da177e4SLinus Torvalds chunk->msg->send_failed = 1; 3711da177e4SLinus Torvalds chunk->msg->send_error = error; 3721da177e4SLinus Torvalds } 373