Skip to content

Commit a300744

Browse files
marceloleitnerdavem330
authored andcommitted
sctp: fix the handling of SACK Gap Ack blocks
sctp_acked() is using 32bit arithmetics on 16bits vars, via TSN_lte() macros, which is weird and confusing. Once the offset to ctsn is calculated, all wrapping is already handled and thus to verify the Gap Ack blocks we can just use pure less/big-or-equal than checks. Also, rename gap variable to tsn_offset, so it's more meaningful, as it doesn't point to any gap at all. Even so, I don't think this discrepancy resulted in any practical bug. This patch is a preparation for the next one, which will introduce typecheck() for TSN_lte() macros and would cause a compile error here. Suggested-by: David Laight <[email protected]> Reported-by: David Laight <[email protected]> Signed-off-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 21641c2 commit a300744

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/sctp/outqueue.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,7 +1719,7 @@ static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn)
17191719
{
17201720
int i;
17211721
sctp_sack_variable_t *frags;
1722-
__u16 gap;
1722+
__u16 tsn_offset, blocks;
17231723
__u32 ctsn = ntohl(sack->cum_tsn_ack);
17241724

17251725
if (TSN_lte(tsn, ctsn))
@@ -1738,10 +1738,11 @@ static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn)
17381738
*/
17391739

17401740
frags = sack->variable;
1741-
gap = tsn - ctsn;
1742-
for (i = 0; i < ntohs(sack->num_gap_ack_blocks); ++i) {
1743-
if (TSN_lte(ntohs(frags[i].gab.start), gap) &&
1744-
TSN_lte(gap, ntohs(frags[i].gab.end)))
1741+
blocks = ntohs(sack->num_gap_ack_blocks);
1742+
tsn_offset = tsn - ctsn;
1743+
for (i = 0; i < blocks; ++i) {
1744+
if (tsn_offset >= ntohs(frags[i].gab.start) &&
1745+
tsn_offset <= ntohs(frags[i].gab.end))
17451746
goto pass;
17461747
}
17471748

0 commit comments

Comments
 (0)