Commit 6ff0f871 authored by Marcelo Ricardo Leitner's avatar Marcelo Ricardo Leitner Committed by David S. Miller

sctp: introduce sctp_dst_mtu

Which makes sure that the MTU respects the minimum value of
SCTP_DEFAULT_MINSEGMENT and that it is correctly aligned.
Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2521680e
...@@ -600,10 +600,15 @@ static inline __u32 sctp_mtu_payload(const struct sctp_sock *sp, ...@@ -600,10 +600,15 @@ static inline __u32 sctp_mtu_payload(const struct sctp_sock *sp,
return mtu ? mtu - overhead : overhead; return mtu ? mtu - overhead : overhead;
} }
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) static inline bool sctp_transport_pmtu_check(struct sctp_transport *t)
{ {
__u32 pmtu = max_t(size_t, SCTP_TRUNC4(dst_mtu(t->dst)), __u32 pmtu = sctp_dst_mtu(t->dst);
SCTP_DEFAULT_MINSEGMENT);
if (t->pathmtu == pmtu) if (t->pathmtu == pmtu)
return true; return true;
......
...@@ -1405,11 +1405,9 @@ void sctp_assoc_sync_pmtu(struct sctp_association *asoc) ...@@ -1405,11 +1405,9 @@ void sctp_assoc_sync_pmtu(struct sctp_association *asoc)
return; return;
/* Get the lowest pmtu of all the transports. */ /* Get the lowest pmtu of all the transports. */
list_for_each_entry(t, &asoc->peer.transport_addr_list, list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) {
transports) {
if (t->pmtu_pending && t->dst) { if (t->pmtu_pending && t->dst) {
sctp_transport_update_pmtu( sctp_transport_update_pmtu(t, sctp_dst_mtu(t->dst));
t, SCTP_TRUNC4(dst_mtu(t->dst)));
t->pmtu_pending = 0; t->pmtu_pending = 0;
} }
if (!pmtu || (t->pathmtu < pmtu)) if (!pmtu || (t->pathmtu < pmtu))
......
...@@ -242,9 +242,9 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk) ...@@ -242,9 +242,9 @@ void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk)
&transport->fl, sk); &transport->fl, sk);
} }
if (transport->dst) { if (transport->dst)
transport->pathmtu = SCTP_TRUNC4(dst_mtu(transport->dst)); transport->pathmtu = sctp_dst_mtu(transport->dst);
} else else
transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT; transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment