]> git.hungrycats.org Git - linux/commitdiff
sctp: introduce sctp_dst_mtu
authorMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Thu, 26 Apr 2018 19:58:57 +0000 (16:58 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Jul 2018 09:26:12 +0000 (11:26 +0200)
[ Upstream commit 6ff0f871c20ec1769a481edca86f23c76b2b06d3 ]

Which makes sure that the MTU respects the minimum value of
SCTP_DEFAULT_MINSEGMENT and that it is correctly aligned.

Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/sctp/sctp.h
net/sctp/associola.c
net/sctp/transport.c

index 35498e613ff5458e5433facbf409e9c90a5153b7..edfa9d0f6005b5d3ea42310bfd75a33ecd7b13c6 100644 (file)
@@ -609,10 +609,15 @@ static inline struct dst_entry *sctp_transport_dst_check(struct sctp_transport *
        return t->dst;
 }
 
+static inline __u32 sctp_dst_mtu(const struct dst_entry *dst)
+{
+       return SCTP_TRUNC4(max_t(__u32, dst_mtu(dst),
+                                SCTP_DEFAULT_MINSEGMENT));
+}
+
 static inline bool sctp_transport_pmtu_check(struct sctp_transport *t)
 {
-       __u32 pmtu = max_t(size_t, SCTP_TRUNC4(dst_mtu(t->dst)),
-                          SCTP_DEFAULT_MINSEGMENT);
+       __u32 pmtu = sctp_dst_mtu(t->dst);
 
        if (t->pathmtu == pmtu)
                return true;
index a47179da24e61f976616631df60b875d5f719ddd..ef8adac1be83b41d6e9233f7c53c4f595395e810 100644 (file)
@@ -1446,11 +1446,9 @@ void sctp_assoc_sync_pmtu(struct sctp_association *asoc)
                return;
 
        /* Get the lowest pmtu of all the transports. */
-       list_for_each_entry(t, &asoc->peer.transport_addr_list,
-                               transports) {
+       list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) {
                if (t->pmtu_pending && t->dst) {
-                       sctp_transport_update_pmtu(
-                                       t, SCTP_TRUNC4(dst_mtu(t->dst)));
+                       sctp_transport_update_pmtu(t, sctp_dst_mtu(t->dst));
                        t->pmtu_pending = 0;
                }
                if (!pmtu || (t->pathmtu < pmtu))
index 03fc2c427aca4ddb3c8915a524b20389ff1269bb..e23071741bbf38024191c07af00fd7e85aae7059 100644 (file)
@@ -242,9 +242,9 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk)
                                                &transport->fl, sk);
        }
 
-       if (transport->dst) {
-               transport->pathmtu = SCTP_TRUNC4(dst_mtu(transport->dst));
-       else
+       if (transport->dst)
+               transport->pathmtu = sctp_dst_mtu(transport->dst);
+       else
                transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
 }