diff options
author | Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> | 2007-12-31 17:57:40 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:00:26 -0500 |
commit | 409d22b470532cb92b91b9aeb7257357a176b849 (patch) | |
tree | df81227116c5d4ddf436c7d97d3d0980b16f621c /net/ipv4 | |
parent | 056834d9f6f6eaf4cc7268569e53acab957aac27 (diff) |
[TCP]: Code duplication removal, added tcp_bound_to_half_wnd()
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/tcp_output.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index bb7e80a284e7..b3110fc1570e 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -888,6 +888,15 @@ void tcp_mtup_init(struct sock *sk) | |||
888 | icsk->icsk_mtup.probe_size = 0; | 888 | icsk->icsk_mtup.probe_size = 0; |
889 | } | 889 | } |
890 | 890 | ||
891 | /* Bound MSS / TSO packet size with the half of the window */ | ||
892 | static int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize) | ||
893 | { | ||
894 | if (tp->max_window && pktsize > (tp->max_window >> 1)) | ||
895 | return max(tp->max_window >> 1, 68U - tp->tcp_header_len); | ||
896 | else | ||
897 | return pktsize; | ||
898 | } | ||
899 | |||
891 | /* This function synchronize snd mss to current pmtu/exthdr set. | 900 | /* This function synchronize snd mss to current pmtu/exthdr set. |
892 | 901 | ||
893 | tp->rx_opt.user_mss is mss set by user by TCP_MAXSEG. It does NOT counts | 902 | tp->rx_opt.user_mss is mss set by user by TCP_MAXSEG. It does NOT counts |
@@ -920,10 +929,7 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) | |||
920 | icsk->icsk_mtup.search_high = pmtu; | 929 | icsk->icsk_mtup.search_high = pmtu; |
921 | 930 | ||
922 | mss_now = tcp_mtu_to_mss(sk, pmtu); | 931 | mss_now = tcp_mtu_to_mss(sk, pmtu); |
923 | 932 | mss_now = tcp_bound_to_half_wnd(tp, mss_now); | |
924 | /* Bound mss with half of window */ | ||
925 | if (tp->max_window && mss_now > (tp->max_window >> 1)) | ||
926 | mss_now = max((tp->max_window >> 1), 68U - tp->tcp_header_len); | ||
927 | 933 | ||
928 | /* And store cached results */ | 934 | /* And store cached results */ |
929 | icsk->icsk_pmtu_cookie = pmtu; | 935 | icsk->icsk_pmtu_cookie = pmtu; |
@@ -977,10 +983,7 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) | |||
977 | inet_csk(sk)->icsk_ext_hdr_len - | 983 | inet_csk(sk)->icsk_ext_hdr_len - |
978 | tp->tcp_header_len); | 984 | tp->tcp_header_len); |
979 | 985 | ||
980 | if (tp->max_window && (xmit_size_goal > (tp->max_window >> 1))) | 986 | xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal); |
981 | xmit_size_goal = max((tp->max_window >> 1), | ||
982 | 68U - tp->tcp_header_len); | ||
983 | |||
984 | xmit_size_goal -= (xmit_size_goal % mss_now); | 987 | xmit_size_goal -= (xmit_size_goal % mss_now); |
985 | } | 988 | } |
986 | tp->xmit_size_goal = xmit_size_goal; | 989 | tp->xmit_size_goal = xmit_size_goal; |