Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sctp: use the pmtu from the icmp packet to update transport pathmtu

Other than asoc pmtu sync from all transports, sctp_assoc_sync_pmtu
is also processing transport pmtu_pending by icmp packets. But it's
meaningless to use sctp_dst_mtu(t->dst) as new pmtu for a transport.

The right pmtu value should come from the icmp packet, and it would
be saved into transport->mtu_info in this patch and used later when
the pmtu sync happens in sctp_sendmsg_to_asoc or sctp_packet_config.

Besides, without this patch, as pmtu can only be updated correctly
when receiving a icmp packet and no place is holding sock lock, it
will take long time if the sock is busy with sending packets.

Note that it doesn't process transport->mtu_info in .release_cb(),
as there is no enough information for pmtu update, like for which
asoc or transport. It is not worth traversing all asocs to check
pmtu_pending. So unlike tcp, sctp does this in tx path, for which
mtu_info needs to be atomic_t.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Xin Long and committed by
David S. Miller
d805397c ec20a63a

+11 -1
+2
include/net/sctp/structs.h
··· 876 876 unsigned long sackdelay; 877 877 __u32 sackfreq; 878 878 879 + atomic_t mtu_info; 880 + 879 881 /* When was the last time that we heard from this transport? We use 880 882 * this to pick new active and retran paths. 881 883 */
+2 -1
net/sctp/associola.c
··· 1450 1450 /* Get the lowest pmtu of all the transports. */ 1451 1451 list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) { 1452 1452 if (t->pmtu_pending && t->dst) { 1453 - sctp_transport_update_pmtu(t, sctp_dst_mtu(t->dst)); 1453 + sctp_transport_update_pmtu(t, 1454 + atomic_read(&t->mtu_info)); 1454 1455 t->pmtu_pending = 0; 1455 1456 } 1456 1457 if (!pmtu || (t->pathmtu < pmtu))
+1
net/sctp/input.c
··· 395 395 return; 396 396 397 397 if (sock_owned_by_user(sk)) { 398 + atomic_set(&t->mtu_info, pmtu); 398 399 asoc->pmtu_pending = 1; 399 400 t->pmtu_pending = 1; 400 401 return;
+6
net/sctp/output.c
··· 120 120 sctp_assoc_sync_pmtu(asoc); 121 121 } 122 122 123 + if (asoc->pmtu_pending) { 124 + if (asoc->param_flags & SPP_PMTUD_ENABLE) 125 + sctp_assoc_sync_pmtu(asoc); 126 + asoc->pmtu_pending = 0; 127 + } 128 + 123 129 /* If there a is a prepend chunk stick it on the list before 124 130 * any other chunks get appended. 125 131 */