From e75f31c1d0278a7f6fb5bf7bf32eedf030de2b55 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Thu, 30 Jun 2016 06:06:35 +0000 Subject: [PATCH] This patch fixes two bugs related to the setting of the I-Bit for SCTP DATA and I-DATA chunks. * For fragmented user messages, set the I-Bit only on the last fragment. * When using explicit EOR mode, set the I-Bit on the last fragment, whenever SCTP_SACK_IMMEDIATELY was set in snd_flags for any of the send() calls. Approved by: re (hrs) MFC after: 1 week --- sys/netinet/sctp_output.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index cca4be4e147..d8c3caef6ff 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -7325,10 +7325,12 @@ sctp_move_to_outqueue(struct sctp_tcb *stcb, /* All of it fits in the MTU */ if (sp->some_taken) { rcv_flags |= SCTP_DATA_LAST_FRAG; - sp->put_last_out = 1; } else { rcv_flags |= SCTP_DATA_NOT_FRAG; - sp->put_last_out = 1; + } + sp->put_last_out = 1; + if (sp->sinfo_flags & SCTP_SACK_IMMEDIATELY) { + rcv_flags |= SCTP_DATA_SACK_IMMEDIATELY; } } else { /* Not all of it fits, we fragment */ @@ -7396,8 +7398,8 @@ sctp_move_to_outqueue(struct sctp_tcb *stcb, if (sp->sinfo_flags & SCTP_UNORDERED) { rcv_flags |= SCTP_DATA_UNORDERED; } - if ((SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) && ((sp->sinfo_flags & SCTP_EOF) == SCTP_EOF)) || - ((sp->sinfo_flags & SCTP_SACK_IMMEDIATELY) == SCTP_SACK_IMMEDIATELY)) { + if (SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) && + (sp->sinfo_flags & SCTP_EOF) == SCTP_EOF) { rcv_flags |= SCTP_DATA_SACK_IMMEDIATELY; } /* clear out the chunk before setting up */ @@ -13280,7 +13282,9 @@ sctp_lower_sosend(struct socket *so, sctp_snd_sb_alloc(stcb, sndout); atomic_add_int(&sp->length, sndout); len += sndout; - + if (srcv->sinfo_flags & SCTP_SACK_IMMEDIATELY) { + sp->sinfo_flags |= SCTP_SACK_IMMEDIATELY; + } /* Did we reach EOR? */ if ((uio->uio_resid == 0) && ((user_marks_eor == 0) ||