diff mbox series

sctp: Fix sending when PMTU is less than SCTP_DEFAULT_MINSEGMENT

Message ID 20201105103946.18771-1-oss@malat.biz
State New
Headers show
Series sctp: Fix sending when PMTU is less than SCTP_DEFAULT_MINSEGMENT | expand

Commit Message

Petr Malat Nov. 5, 2020, 10:39 a.m. UTC
Function sctp_dst_mtu() never returns lower MTU than
SCTP_TRUNC4(SCTP_DEFAULT_MINSEGMENT) even when the actual MTU is less,
in which case we rely on the IP fragmentation and must enable it.

Signed-off-by: Petr Malat <oss@malat.biz>
---
 net/sctp/output.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/net/sctp/output.c b/net/sctp/output.c
index 1441eaf460bb..87a96cf6bfa4 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -552,6 +552,7 @@  int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
 	struct sk_buff *head;
 	struct sctphdr *sh;
 	struct sock *sk;
+	u32 pmtu;
 
 	pr_debug("%s: packet:%p\n", __func__, packet);
 	if (list_empty(&packet->chunk_list))
@@ -559,6 +560,13 @@  int sctp_packet_transmit(struct sctp_packet *packet, gfp_t gfp)
 	chunk = list_entry(packet->chunk_list.next, struct sctp_chunk, list);
 	sk = chunk->skb->sk;
 
+	/* Fragmentation on the IP level if the actual PMTU could be less
+	 * than SCTP_DEFAULT_MINSEGMENT. See sctp_dst_mtu().
+	 */
+	pmtu = tp->asoc ? tp->asoc->pathmtu : tp->pathmtu;
+	if (pmtu <= SCTP_DEFAULT_MINSEGMENT)
+		packet->ipfragok = 1;
+
 	/* check gso */
 	if (packet->size > tp->pathmtu && !packet->ipfragok) {
 		if (!sk_can_gso(sk)) {