Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sctp: remove the old ttl expires policy

The prsctp polices include ttl expires policy already, we should remove
the old ttl expires codes, and just adjust the new polices' codes to be
compatible with the old one for users.

This patch is to remove all the old expires codes, and if prsctp polices
are not set, it will still set msg's expires_at and check the expires in
sctp_check_abandoned.

Note that asoc->prsctp_enable is set by default, so users can't feel any
difference even if they use the old expires api in userspace.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Xin Long and committed by
David S. Miller
8ae808eb cc6ac9bc

+8 -28
-1
include/net/sctp/structs.h
··· 530 530 /* Did the messenge fail to send? */ 531 531 int send_error; 532 532 u8 send_failed:1, 533 - can_abandon:1, /* can chunks from this message can be abandoned. */ 534 533 can_delay; /* should this message be Nagle delayed */ 535 534 }; 536 535
+8 -24
net/sctp/chunk.c
··· 52 52 atomic_set(&msg->refcnt, 1); 53 53 msg->send_failed = 0; 54 54 msg->send_error = 0; 55 - msg->can_abandon = 0; 56 55 msg->can_delay = 1; 57 56 msg->expires_at = 0; 58 57 INIT_LIST_HEAD(&msg->chunks); ··· 181 182 /* Note: Calculate this outside of the loop, so that all fragments 182 183 * have the same expiration. 183 184 */ 184 - if (sinfo->sinfo_timetolive) { 185 - /* sinfo_timetolive is in milliseconds */ 185 + if (asoc->peer.prsctp_capable && sinfo->sinfo_timetolive && 186 + (SCTP_PR_TTL_ENABLED(sinfo->sinfo_flags) || 187 + !SCTP_PR_POLICY(sinfo->sinfo_flags))) 186 188 msg->expires_at = jiffies + 187 189 msecs_to_jiffies(sinfo->sinfo_timetolive); 188 - msg->can_abandon = 1; 189 - 190 - pr_debug("%s: msg:%p expires_at:%ld jiffies:%ld\n", __func__, 191 - msg, msg->expires_at, jiffies); 192 - } 193 - 194 - if (asoc->peer.prsctp_capable && 195 - SCTP_PR_TTL_ENABLED(sinfo->sinfo_flags)) 196 - msg->expires_at = 197 - jiffies + msecs_to_jiffies(sinfo->sinfo_timetolive); 198 190 199 191 /* This is the biggest possible DATA chunk that can fit into 200 192 * the packet ··· 344 354 /* Check whether this message has expired. */ 345 355 int sctp_chunk_abandoned(struct sctp_chunk *chunk) 346 356 { 347 - if (!chunk->asoc->peer.prsctp_capable || 348 - !SCTP_PR_POLICY(chunk->sinfo.sinfo_flags)) { 349 - struct sctp_datamsg *msg = chunk->msg; 350 - 351 - if (!msg->can_abandon) 352 - return 0; 353 - 354 - if (time_after(jiffies, msg->expires_at)) 355 - return 1; 356 - 357 + if (!chunk->asoc->peer.prsctp_capable) 357 358 return 0; 358 - } 359 359 360 360 if (SCTP_PR_TTL_ENABLED(chunk->sinfo.sinfo_flags) && 361 361 time_after(jiffies, chunk->msg->expires_at)) { ··· 357 377 } else if (SCTP_PR_RTX_ENABLED(chunk->sinfo.sinfo_flags) && 358 378 chunk->sent_count > chunk->sinfo.sinfo_timetolive) { 359 379 chunk->asoc->abandoned_sent[SCTP_PR_INDEX(RTX)]++; 380 + return 1; 381 + } else if (!SCTP_PR_POLICY(chunk->sinfo.sinfo_flags) && 382 + chunk->msg->expires_at && 383 + time_after(jiffies, chunk->msg->expires_at)) { 360 384 return 1; 361 385 } 362 386 /* PRIO policy is processed by sendmsg, not here */
-3
net/sctp/output.c
··· 866 866 rwnd = 0; 867 867 868 868 asoc->peer.rwnd = rwnd; 869 - /* Has been accepted for transmission. */ 870 - if (!asoc->peer.prsctp_capable) 871 - chunk->msg->can_abandon = 0; 872 869 sctp_chunk_assign_tsn(chunk); 873 870 sctp_chunk_assign_ssn(chunk); 874 871 }