mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
sctp: introduce sctp_mtu_payload
When given a MTU, this function calculates how much payload we can carry on it. Without a MTU, it calculates the amount of header overhead we have. So that when we have extra overhead, like the one added for IP options on SELinux patches, it is easier to handle it. Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c4b2893dae
commit
feddd6c1af
3 changed files with 31 additions and 20 deletions
|
@ -607,6 +607,25 @@ static inline struct dst_entry *sctp_transport_dst_check(struct sctp_transport *
|
|||
return t->dst;
|
||||
}
|
||||
|
||||
/* Calculate max payload size given a MTU, or the total overhead if
|
||||
* given MTU is zero
|
||||
*/
|
||||
static inline __u32 sctp_mtu_payload(const struct sctp_sock *sp,
|
||||
__u32 mtu, __u32 extra)
|
||||
{
|
||||
__u32 overhead = sizeof(struct sctphdr) + extra;
|
||||
|
||||
if (sp)
|
||||
overhead += sp->pf->af->net_header_len;
|
||||
else
|
||||
overhead += sizeof(struct ipv6hdr);
|
||||
|
||||
if (WARN_ON_ONCE(mtu && mtu <= overhead))
|
||||
mtu = overhead;
|
||||
|
||||
return mtu ? mtu - overhead : overhead;
|
||||
}
|
||||
|
||||
static inline bool sctp_transport_pmtu_check(struct sctp_transport *t)
|
||||
{
|
||||
__u32 pmtu = max_t(size_t, SCTP_TRUNC4(dst_mtu(t->dst)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue