diff options
author | Xin Long <lucien.xin@gmail.com> | 2020-10-29 15:05:04 +0800 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2020-10-30 15:24:21 -0700 |
commit | f1bfe8b5415171b5e70c2a47d399c91bd7c2752e (patch) | |
tree | 0f4916867d8f9041b025c4d8e804232de9b23b1a /include/net/sctp/sctp.h | |
parent | a1dd2cf2f1aedabc2ca9bb4f90231a521c52d8eb (diff) |
sctp: add udphdr to overhead when udp_port is set
sctp_mtu_payload() is for calculating the frag size before making
chunks from a msg. So we should only add udphdr size to overhead
when udp socks are listening, as only then sctp can handle the
incoming sctp over udp packets and outgoing sctp over udp packets
will be possible.
Note that we can't do this according to transport->encap_port, as
different transports may be set to different values, while the
chunks were made before choosing the transport, we could not be
able to meet all rfc6951#section-5.6 recommends.
v1->v2:
- Add udp_port for sctp_sock to avoid a potential race issue, it
will be used in xmit path in the next patch.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net/sctp/sctp.h')
-rw-r--r-- | include/net/sctp/sctp.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index bfd87a0aa2f1..86f74f2fe6de 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h @@ -578,10 +578,13 @@ static inline __u32 sctp_mtu_payload(const struct sctp_sock *sp, { __u32 overhead = sizeof(struct sctphdr) + extra; - if (sp) + if (sp) { overhead += sp->pf->af->net_header_len; - else + if (sp->udp_port) + overhead += sizeof(struct udphdr); + } else { overhead += sizeof(struct ipv6hdr); + } if (WARN_ON_ONCE(mtu && mtu <= overhead)) mtu = overhead; |