Skip to content

Commit 439ef03

Browse files
marceloleitnerdavem330
authored andcommitted
sctp: consider idata chunks when setting SCTP_MAXSEG
When setting SCTP_MAXSEG sock option, it should consider which kind of data chunk is being used if the asoc is already available, so that the limit better reflect reality. Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 63d0133 commit 439ef03

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

net/sctp/socket.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,18 +3233,21 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
32333233
return -EINVAL;
32343234
}
32353235

3236+
asoc = sctp_id2assoc(sk, params.assoc_id);
3237+
32363238
if (val) {
32373239
int min_len, max_len;
3240+
__u16 datasize = asoc ? sctp_datachk_len(&asoc->stream) :
3241+
sizeof(struct sctp_data_chunk);
32383242

32393243
min_len = sctp_mtu_payload(sp, SCTP_DEFAULT_MINSEGMENT,
3240-
sizeof(struct sctp_data_chunk));
3241-
max_len = SCTP_MAX_CHUNK_LEN - sizeof(struct sctp_data_chunk);
3244+
datasize);
3245+
max_len = SCTP_MAX_CHUNK_LEN - datasize;
32423246

32433247
if (val < min_len || val > max_len)
32443248
return -EINVAL;
32453249
}
32463250

3247-
asoc = sctp_id2assoc(sk, params.assoc_id);
32483251
if (asoc) {
32493252
if (val == 0) {
32503253
val = asoc->pathmtu - af->net_header_len;

0 commit comments

Comments
 (0)