diff options
author | Eric Dumazet <edumazet@google.com> | 2017-02-02 08:04:56 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-02-03 11:19:34 -0500 |
commit | 3541f9e8bdebce02458882b66b638d7302c1f616 (patch) | |
tree | 1049ef01f68f197e66fa77f18768aaf6d219f8b1 /include/linux/tcp.h | |
parent | ff3edc9b8efc8200c25f3a5adfb1c1de0a882dc5 (diff) | |
download | blackbird-op-linux-3541f9e8bdebce02458882b66b638d7302c1f616.tar.gz blackbird-op-linux-3541f9e8bdebce02458882b66b638d7302c1f616.zip |
tcp: add tcp_mss_clamp() helper
Small cleanup factorizing code doing the TCP_MAXSEG clamping.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/tcp.h')
-rw-r--r-- | include/linux/tcp.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/tcp.h b/include/linux/tcp.h index f88f4649ba6f..cfc2d9506ce8 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -445,4 +445,13 @@ static inline void tcp_saved_syn_free(struct tcp_sock *tp) struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk); +static inline u16 tcp_mss_clamp(const struct tcp_sock *tp, u16 mss) +{ + /* We use READ_ONCE() here because socket might not be locked. + * This happens for listeners. + */ + u16 user_mss = READ_ONCE(tp->rx_opt.user_mss); + + return (user_mss && user_mss < mss) ? user_mss : mss; +} #endif /* _LINUX_TCP_H */ |