aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>2018-04-26 16:59:01 -0300
committerDavid S. Miller <davem@davemloft.net>2018-04-27 14:35:23 -0400
commit439ef0309cf4b743d76edc2abeca72b27ee1d996 (patch)
tree28249b9f025a593815d0e5da16ac29288fe41465 /net/sctp/socket.c
parentsctp: honor PMTU_DISABLED when handling icmp (diff)
downloadwireguard-linux-439ef0309cf4b743d76edc2abeca72b27ee1d996.tar.xz
wireguard-linux-439ef0309cf4b743d76edc2abeca72b27ee1d996.zip
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>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index ad8965835d8d..2d35c8ea2470 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3233,18 +3233,21 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
return -EINVAL;
}
+ asoc = sctp_id2assoc(sk, params.assoc_id);
+
if (val) {
int min_len, max_len;
+ __u16 datasize = asoc ? sctp_datachk_len(&asoc->stream) :
+ sizeof(struct sctp_data_chunk);
min_len = sctp_mtu_payload(sp, SCTP_DEFAULT_MINSEGMENT,
- sizeof(struct sctp_data_chunk));
- max_len = SCTP_MAX_CHUNK_LEN - sizeof(struct sctp_data_chunk);
+ datasize);
+ max_len = SCTP_MAX_CHUNK_LEN - datasize;
if (val < min_len || val > max_len)
return -EINVAL;
}
- asoc = sctp_id2assoc(sk, params.assoc_id);
if (asoc) {
if (val == 0) {
val = asoc->pathmtu - af->net_header_len;