diff options
author | Xin Long <lucien.xin@gmail.com> | 2018-10-15 07:58:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-10-16 01:54:20 -0400 |
commit | d805397c3822d57ca3884d4bea37b2291fc40992 (patch) | |
tree | 26a590ccde4580779a2428d6071b87bdc967bfae | |
parent | ec20a63aa8b8ec3223fb25cdb2a49f9f9dfda88c (diff) |
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>
-rw-r--r-- | include/net/sctp/structs.h | 2 | ||||
-rw-r--r-- | net/sctp/associola.c | 3 | ||||
-rw-r--r-- | net/sctp/input.c | 1 | ||||
-rw-r--r-- | net/sctp/output.c | 6 |
4 files changed, 11 insertions, 1 deletions
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 28a7c8e44636..a11f93790476 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -876,6 +876,8 @@ struct sctp_transport { | |||
876 | unsigned long sackdelay; | 876 | unsigned long sackdelay; |
877 | __u32 sackfreq; | 877 | __u32 sackfreq; |
878 | 878 | ||
879 | atomic_t mtu_info; | ||
880 | |||
879 | /* When was the last time that we heard from this transport? We use | 881 | /* When was the last time that we heard from this transport? We use |
880 | * this to pick new active and retran paths. | 882 | * this to pick new active and retran paths. |
881 | */ | 883 | */ |
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 297d9cf960b9..a827a1f562bf 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -1450,7 +1450,8 @@ void sctp_assoc_sync_pmtu(struct sctp_association *asoc) | |||
1450 | /* Get the lowest pmtu of all the transports. */ | 1450 | /* Get the lowest pmtu of all the transports. */ |
1451 | list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) { | 1451 | list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) { |
1452 | if (t->pmtu_pending && t->dst) { | 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 | t->pmtu_pending = 0; | 1455 | t->pmtu_pending = 0; |
1455 | } | 1456 | } |
1456 | if (!pmtu || (t->pathmtu < pmtu)) | 1457 | if (!pmtu || (t->pathmtu < pmtu)) |
diff --git a/net/sctp/input.c b/net/sctp/input.c index 9bbc5f92c941..5c36a99882ed 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c | |||
@@ -395,6 +395,7 @@ void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc, | |||
395 | return; | 395 | return; |
396 | 396 | ||
397 | if (sock_owned_by_user(sk)) { | 397 | if (sock_owned_by_user(sk)) { |
398 | atomic_set(&t->mtu_info, pmtu); | ||
398 | asoc->pmtu_pending = 1; | 399 | asoc->pmtu_pending = 1; |
399 | t->pmtu_pending = 1; | 400 | t->pmtu_pending = 1; |
400 | return; | 401 | return; |
diff --git a/net/sctp/output.c b/net/sctp/output.c index 7f849b01ec8e..67939ad99c01 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c | |||
@@ -120,6 +120,12 @@ void sctp_packet_config(struct sctp_packet *packet, __u32 vtag, | |||
120 | sctp_assoc_sync_pmtu(asoc); | 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 | /* If there a is a prepend chunk stick it on the list before | 129 | /* If there a is a prepend chunk stick it on the list before |
124 | * any other chunks get appended. | 130 | * any other chunks get appended. |
125 | */ | 131 | */ |