sctp: update frag_point when stream_interleave is set

sctp_assoc_update_frag_point() should be called whenever asoc->pathmtu
changes, but we missed one place in sctp_association_init(). It would
cause frag_point is zero when sending data.

As says in Jakub's reproducer, if sp->pathmtu is set by socketopt, the
new asoc->pathmtu inherits it in sctp_association_init(). Later when
transports are added and their pmtu >= asoc->pathmtu, it will never
call sctp_assoc_update_frag_point() to set frag_point.

This patch is to fix it by updating frag_point after asoc->pathmtu is
set as sp->pathmtu in sctp_association_init(). Note that it moved them
after sctp_stream_init(), as stream->si needs to be set first.

Frag_point's calculation is also related with datachunk's type, so it
needs to update frag_point when stream->si may be changed in
sctp_process_init().

v1->v2:
  - call sctp_assoc_update_frag_point() separately in sctp_process_init
    and sctp_association_init, per Marcelo's suggestion.

Fixes: 2f5e3c9df6 ("sctp: introduce sctp_assoc_update_frag_point")
Reported-by: Jakub Audykowicz <jakub.audykowicz@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Xin Long 2018-11-27 19:11:50 +08:00 committed by David S. Miller
parent 9410d386d0
commit 4135cce7fd
2 changed files with 7 additions and 3 deletions

View File

@ -118,9 +118,6 @@ static struct sctp_association *sctp_association_init(
asoc->flowlabel = sp->flowlabel; asoc->flowlabel = sp->flowlabel;
asoc->dscp = sp->dscp; asoc->dscp = sp->dscp;
/* Initialize default path MTU. */
asoc->pathmtu = sp->pathmtu;
/* Set association default SACK delay */ /* Set association default SACK delay */
asoc->sackdelay = msecs_to_jiffies(sp->sackdelay); asoc->sackdelay = msecs_to_jiffies(sp->sackdelay);
asoc->sackfreq = sp->sackfreq; asoc->sackfreq = sp->sackfreq;
@ -252,6 +249,10 @@ static struct sctp_association *sctp_association_init(
0, gfp)) 0, gfp))
goto fail_init; goto fail_init;
/* Initialize default path MTU. */
asoc->pathmtu = sp->pathmtu;
sctp_assoc_update_frag_point(asoc);
/* Assume that peer would support both address types unless we are /* Assume that peer would support both address types unless we are
* told otherwise. * told otherwise.
*/ */

View File

@ -2462,6 +2462,9 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
asoc->c.sinit_max_instreams, gfp)) asoc->c.sinit_max_instreams, gfp))
goto clean_up; goto clean_up;
/* Update frag_point when stream_interleave may get changed. */
sctp_assoc_update_frag_point(asoc);
if (!asoc->temp && sctp_assoc_set_id(asoc, gfp)) if (!asoc->temp && sctp_assoc_set_id(asoc, gfp))
goto clean_up; goto clean_up;