[PATCH] sctp: Fix sending when PMTU is less than SCTP_DEFAULT_MINSEGMENT
From: Petr Malat
Date: Thu Nov 05 2020 - 05:42:33 EST
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@xxxxxxxxx>
---
net/sctp/output.c | 8 ++++++++
1 file changed, 8 insertions(+)
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)) {
--
2.20.1