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>
This commit is contained in:

committed by
David S. Miller

parent
ff3edc9b8e
commit
3541f9e8bd
@@ -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 */
|
||||
|
Reference in New Issue
Block a user