diff options
author | Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> | 2007-12-31 07:48:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:00:22 -0500 |
commit | 90840defabbd819180c7528e12d550776848f833 (patch) | |
tree | 865c98dbf50a08b35cb8b91e1348f10c87fae945 | |
parent | 66f5fe624fa5f1d4574d2dd2bc0c72a17a92079c (diff) |
[TCP]: Introduce tcp_wnd_end() to reduce line lengths
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/tcp.h | 6 | ||||
-rw-r--r-- | net/ipv4/tcp_input.c | 3 | ||||
-rw-r--r-- | net/ipv4/tcp_output.c | 20 |
3 files changed, 17 insertions, 12 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index 76286e80205a..6a732d4919fe 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -785,6 +785,12 @@ static __inline__ __u32 tcp_max_burst(const struct tcp_sock *tp) | |||
785 | return 3; | 785 | return 3; |
786 | } | 786 | } |
787 | 787 | ||
788 | /* Returns end sequence number of the receiver's advertised window */ | ||
789 | static inline u32 tcp_wnd_end(const struct tcp_sock *tp) | ||
790 | { | ||
791 | return tp->snd_una + tp->snd_wnd; | ||
792 | } | ||
793 | |||
788 | /* RFC2861 Check whether we are limited by application or congestion window | 794 | /* RFC2861 Check whether we are limited by application or congestion window |
789 | * This is the inverse of cwnd check in tcp_tso_should_defer | 795 | * This is the inverse of cwnd check in tcp_tso_should_defer |
790 | */ | 796 | */ |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 41f4b862319d..366f63ae4d5c 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -2921,8 +2921,7 @@ static void tcp_ack_probe(struct sock *sk) | |||
2921 | 2921 | ||
2922 | /* Was it a usable window open? */ | 2922 | /* Was it a usable window open? */ |
2923 | 2923 | ||
2924 | if (!after(TCP_SKB_CB(tcp_send_head(sk))->end_seq, | 2924 | if (!after(TCP_SKB_CB(tcp_send_head(sk))->end_seq, tcp_wnd_end(tp))) { |
2925 | tp->snd_una + tp->snd_wnd)) { | ||
2926 | icsk->icsk_backoff = 0; | 2925 | icsk->icsk_backoff = 0; |
2927 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_PROBE0); | 2926 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_PROBE0); |
2928 | /* Socket must be waked up by subsequent tcp_data_snd_check(). | 2927 | /* Socket must be waked up by subsequent tcp_data_snd_check(). |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 1ca638b83168..821fae271428 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -89,10 +89,10 @@ static inline __u32 tcp_acceptable_seq(struct sock *sk) | |||
89 | { | 89 | { |
90 | struct tcp_sock *tp = tcp_sk(sk); | 90 | struct tcp_sock *tp = tcp_sk(sk); |
91 | 91 | ||
92 | if (!before(tp->snd_una+tp->snd_wnd, tp->snd_nxt)) | 92 | if (!before(tcp_wnd_end(tp), tp->snd_nxt)) |
93 | return tp->snd_nxt; | 93 | return tp->snd_nxt; |
94 | else | 94 | else |
95 | return tp->snd_una+tp->snd_wnd; | 95 | return tcp_wnd_end(tp); |
96 | } | 96 | } |
97 | 97 | ||
98 | /* Calculate mss to advertise in SYN segment. | 98 | /* Calculate mss to advertise in SYN segment. |
@@ -1024,7 +1024,7 @@ static unsigned int tcp_mss_split_point(struct sock *sk, struct sk_buff *skb, | |||
1024 | struct tcp_sock *tp = tcp_sk(sk); | 1024 | struct tcp_sock *tp = tcp_sk(sk); |
1025 | u32 needed, window, cwnd_len; | 1025 | u32 needed, window, cwnd_len; |
1026 | 1026 | ||
1027 | window = (tp->snd_una + tp->snd_wnd - TCP_SKB_CB(skb)->seq); | 1027 | window = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; |
1028 | cwnd_len = mss_now * cwnd; | 1028 | cwnd_len = mss_now * cwnd; |
1029 | 1029 | ||
1030 | if (likely(cwnd_len <= window && skb != tcp_write_queue_tail(sk))) | 1030 | if (likely(cwnd_len <= window && skb != tcp_write_queue_tail(sk))) |
@@ -1134,7 +1134,7 @@ static inline int tcp_snd_wnd_test(struct tcp_sock *tp, struct sk_buff *skb, uns | |||
1134 | if (skb->len > cur_mss) | 1134 | if (skb->len > cur_mss) |
1135 | end_seq = TCP_SKB_CB(skb)->seq + cur_mss; | 1135 | end_seq = TCP_SKB_CB(skb)->seq + cur_mss; |
1136 | 1136 | ||
1137 | return !after(end_seq, tp->snd_una + tp->snd_wnd); | 1137 | return !after(end_seq, tcp_wnd_end(tp)); |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | /* This checks if the data bearing packet SKB (usually tcp_send_head(sk)) | 1140 | /* This checks if the data bearing packet SKB (usually tcp_send_head(sk)) |
@@ -1251,7 +1251,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb) | |||
1251 | BUG_ON(tcp_skb_pcount(skb) <= 1 || | 1251 | BUG_ON(tcp_skb_pcount(skb) <= 1 || |
1252 | (tp->snd_cwnd <= in_flight)); | 1252 | (tp->snd_cwnd <= in_flight)); |
1253 | 1253 | ||
1254 | send_win = (tp->snd_una + tp->snd_wnd) - TCP_SKB_CB(skb)->seq; | 1254 | send_win = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; |
1255 | 1255 | ||
1256 | /* From in_flight test above, we know that cwnd > in_flight. */ | 1256 | /* From in_flight test above, we know that cwnd > in_flight. */ |
1257 | cong_win = (tp->snd_cwnd - in_flight) * tp->mss_cache; | 1257 | cong_win = (tp->snd_cwnd - in_flight) * tp->mss_cache; |
@@ -1332,7 +1332,7 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1332 | 1332 | ||
1333 | if (tp->snd_wnd < size_needed) | 1333 | if (tp->snd_wnd < size_needed) |
1334 | return -1; | 1334 | return -1; |
1335 | if (after(tp->snd_nxt + size_needed, tp->snd_una + tp->snd_wnd)) | 1335 | if (after(tp->snd_nxt + size_needed, tcp_wnd_end(tp))) |
1336 | return 0; | 1336 | return 0; |
1337 | 1337 | ||
1338 | /* Do we need to wait to drain cwnd? With none in flight, don't stall */ | 1338 | /* Do we need to wait to drain cwnd? With none in flight, don't stall */ |
@@ -1687,7 +1687,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m | |||
1687 | return; | 1687 | return; |
1688 | 1688 | ||
1689 | /* Next skb is out of window. */ | 1689 | /* Next skb is out of window. */ |
1690 | if (after(TCP_SKB_CB(next_skb)->end_seq, tp->snd_una+tp->snd_wnd)) | 1690 | if (after(TCP_SKB_CB(next_skb)->end_seq, tcp_wnd_end(tp))) |
1691 | return; | 1691 | return; |
1692 | 1692 | ||
1693 | /* Punt if not enough space exists in the first SKB for | 1693 | /* Punt if not enough space exists in the first SKB for |
@@ -1831,7 +1831,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) | |||
1831 | * case, when window is shrunk to zero. In this case | 1831 | * case, when window is shrunk to zero. In this case |
1832 | * our retransmit serves as a zero window probe. | 1832 | * our retransmit serves as a zero window probe. |
1833 | */ | 1833 | */ |
1834 | if (!before(TCP_SKB_CB(skb)->seq, tp->snd_una+tp->snd_wnd) | 1834 | if (!before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp)) |
1835 | && TCP_SKB_CB(skb)->seq != tp->snd_una) | 1835 | && TCP_SKB_CB(skb)->seq != tp->snd_una) |
1836 | return -EAGAIN; | 1836 | return -EAGAIN; |
1837 | 1837 | ||
@@ -2497,10 +2497,10 @@ int tcp_write_wakeup(struct sock *sk) | |||
2497 | struct sk_buff *skb; | 2497 | struct sk_buff *skb; |
2498 | 2498 | ||
2499 | if ((skb = tcp_send_head(sk)) != NULL && | 2499 | if ((skb = tcp_send_head(sk)) != NULL && |
2500 | before(TCP_SKB_CB(skb)->seq, tp->snd_una+tp->snd_wnd)) { | 2500 | before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp))) { |
2501 | int err; | 2501 | int err; |
2502 | unsigned int mss = tcp_current_mss(sk, 0); | 2502 | unsigned int mss = tcp_current_mss(sk, 0); |
2503 | unsigned int seg_size = tp->snd_una+tp->snd_wnd-TCP_SKB_CB(skb)->seq; | 2503 | unsigned int seg_size = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; |
2504 | 2504 | ||
2505 | if (before(tp->pushed_seq, TCP_SKB_CB(skb)->end_seq)) | 2505 | if (before(tp->pushed_seq, TCP_SKB_CB(skb)->end_seq)) |
2506 | tp->pushed_seq = TCP_SKB_CB(skb)->end_seq; | 2506 | tp->pushed_seq = TCP_SKB_CB(skb)->end_seq; |