2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-15 16:53:54 +08:00

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 <David.Laight@ACULAB.COM>
Reported-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Marcelo Ricardo Leitner 2016-09-20 18:19:13 -03:00 committed by David S. Miller
parent 21641c2e1f
commit a3007446e5

View File

@ -1719,7 +1719,7 @@ static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn)
{ {
int i; int i;
sctp_sack_variable_t *frags; sctp_sack_variable_t *frags;
__u16 gap; __u16 tsn_offset, blocks;
__u32 ctsn = ntohl(sack->cum_tsn_ack); __u32 ctsn = ntohl(sack->cum_tsn_ack);
if (TSN_lte(tsn, ctsn)) if (TSN_lte(tsn, ctsn))
@ -1738,10 +1738,11 @@ static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn)
*/ */
frags = sack->variable; frags = sack->variable;
gap = tsn - ctsn; blocks = ntohs(sack->num_gap_ack_blocks);
for (i = 0; i < ntohs(sack->num_gap_ack_blocks); ++i) { tsn_offset = tsn - ctsn;
if (TSN_lte(ntohs(frags[i].gab.start), gap) && for (i = 0; i < blocks; ++i) {
TSN_lte(gap, ntohs(frags[i].gab.end))) if (tsn_offset >= ntohs(frags[i].gab.start) &&
tsn_offset <= ntohs(frags[i].gab.end))
goto pass; goto pass;
} }