Skip to content

Commit d805397

Browse files
lxindavem330
authored andcommitted
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>
1 parent ec20a63 commit d805397

4 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎include/net/sctp/structs.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,8 @@ struct sctp_transport {
876876
unsigned long sackdelay;
877877
__u32 sackfreq;
878878

879+
atomic_t mtu_info;
880+
879881
/* When was the last time that we heard from this transport? We use
880882
* this to pick new active and retran paths.
881883
*/

‎net/sctp/associola.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,8 @@ void sctp_assoc_sync_pmtu(struct sctp_association *asoc)
14501450
/* Get the lowest pmtu of all the transports. */
14511451
list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) {
14521452
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));
14541455
t->pmtu_pending = 0;
14551456
}
14561457
if (!pmtu || (t->pathmtu < pmtu))

‎net/sctp/input.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc,
395395
return;
396396

397397
if (sock_owned_by_user(sk)) {
398+
atomic_set(&t->mtu_info, pmtu);
398399
asoc->pmtu_pending = 1;
399400
t->pmtu_pending = 1;
400401
return;

‎net/sctp/output.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ void sctp_packet_config(struct sctp_packet *packet, __u32 vtag,
120120
sctp_assoc_sync_pmtu(asoc);
121121
}
122122

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+
123129
/* If there a is a prepend chunk stick it on the list before
124130
* any other chunks get appended.
125131
*/

0 commit comments

Comments
 (0)