sctp: implement prsctp TTL policy
[cascardo/linux.git] / net / sctp / chunk.c
index 1eb94bf..2698d12 100644 (file)
@@ -335,13 +335,27 @@ errout:
 /* Check whether this message has expired. */
 int sctp_chunk_abandoned(struct sctp_chunk *chunk)
 {
-       struct sctp_datamsg *msg = chunk->msg;
+       if (!chunk->asoc->prsctp_enable ||
+           !SCTP_PR_POLICY(chunk->sinfo.sinfo_flags)) {
+               struct sctp_datamsg *msg = chunk->msg;
+
+               if (!msg->can_abandon)
+                       return 0;
+
+               if (time_after(jiffies, msg->expires_at))
+                       return 1;
 
-       if (!msg->can_abandon)
                return 0;
+       }
 
-       if (time_after(jiffies, msg->expires_at))
+       if (SCTP_PR_TTL_ENABLED(chunk->sinfo.sinfo_flags) &&
+           time_after(jiffies, chunk->prsctp_param)) {
+               if (chunk->sent_count)
+                       chunk->asoc->abandoned_sent[SCTP_PR_INDEX(TTL)]++;
+               else
+                       chunk->asoc->abandoned_unsent[SCTP_PR_INDEX(TTL)]++;
                return 1;
+       }
 
        return 0;
 }