From 9596952a638851a34a28be1cbc9f30d5032aaa8f Mon Sep 17 00:00:00 2001 From: tuexen Date: Thu, 11 Nov 2010 18:41:03 +0000 Subject: [PATCH] Fix the SACK/NR-SACK generation code. MFC after: 3 days. --- sys/netinet/sctp_output.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 1e683991dfb..50820b78366 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -10118,19 +10118,18 @@ sctp_send_sack(struct sctp_tcb *stcb) } } - if (((type == SCTP_SELECTIVE_ACK) && - (((asoc->mapping_array[0] | asoc->nr_mapping_array[0]) & 0x01) == 0x00)) || - ((type == SCTP_NR_SELECTIVE_ACK) && - ((asoc->mapping_array[0] & 0x01) == 0x00))) { - sel_start = 0; - } else { - sel_start = 1; - } if (compare_with_wrap(asoc->mapping_array_base_tsn, asoc->cumulative_tsn, MAX_TSN)) { offset = 1; } else { offset = asoc->mapping_array_base_tsn - asoc->cumulative_tsn; } + if ((offset == 1) || + ((type == SCTP_NR_SELECTIVE_ACK) && + ((asoc->mapping_array[0] & (1 << (1 - offset))) == 0))) { + sel_start = 0; + } else { + sel_start = 1; + } if (((type == SCTP_SELECTIVE_ACK) && compare_with_wrap(highest_tsn, asoc->cumulative_tsn, MAX_TSN)) || ((type == SCTP_NR_SELECTIVE_ACK) && @@ -10200,7 +10199,7 @@ sctp_send_sack(struct sctp_tcb *stcb) siz = (((MAX_TSN - asoc->mapping_array_base_tsn) + 1) + asoc->highest_tsn_inside_nr_map + 7) / 8; } - if ((asoc->nr_mapping_array[0] & 0x01) == 0x00) { + if ((asoc->nr_mapping_array[0] & (1 << (1 - offset))) == 0) { sel_start = 0; } else { sel_start = 1; -- 2.45.0