提交 90840def 编写于 作者: I Ilpo Järvinen 提交者: David S. Miller

[TCP]: Introduce tcp_wnd_end() to reduce line lengths

Signed-off-by: NIlpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 66f5fe62
...@@ -785,6 +785,12 @@ static __inline__ __u32 tcp_max_burst(const struct tcp_sock *tp) ...@@ -785,6 +785,12 @@ static __inline__ __u32 tcp_max_burst(const struct tcp_sock *tp)
return 3; return 3;
} }
/* Returns end sequence number of the receiver's advertised window */
static inline u32 tcp_wnd_end(const struct tcp_sock *tp)
{
return tp->snd_una + tp->snd_wnd;
}
/* RFC2861 Check whether we are limited by application or congestion window /* RFC2861 Check whether we are limited by application or congestion window
* This is the inverse of cwnd check in tcp_tso_should_defer * This is the inverse of cwnd check in tcp_tso_should_defer
*/ */
......
...@@ -2921,8 +2921,7 @@ static void tcp_ack_probe(struct sock *sk) ...@@ -2921,8 +2921,7 @@ static void tcp_ack_probe(struct sock *sk)
/* Was it a usable window open? */ /* Was it a usable window open? */
if (!after(TCP_SKB_CB(tcp_send_head(sk))->end_seq, if (!after(TCP_SKB_CB(tcp_send_head(sk))->end_seq, tcp_wnd_end(tp))) {
tp->snd_una + tp->snd_wnd)) {
icsk->icsk_backoff = 0; icsk->icsk_backoff = 0;
inet_csk_clear_xmit_timer(sk, ICSK_TIME_PROBE0); inet_csk_clear_xmit_timer(sk, ICSK_TIME_PROBE0);
/* Socket must be waked up by subsequent tcp_data_snd_check(). /* Socket must be waked up by subsequent tcp_data_snd_check().
......
...@@ -89,10 +89,10 @@ static inline __u32 tcp_acceptable_seq(struct sock *sk) ...@@ -89,10 +89,10 @@ static inline __u32 tcp_acceptable_seq(struct sock *sk)
{ {
struct tcp_sock *tp = tcp_sk(sk); struct tcp_sock *tp = tcp_sk(sk);
if (!before(tp->snd_una+tp->snd_wnd, tp->snd_nxt)) if (!before(tcp_wnd_end(tp), tp->snd_nxt))
return tp->snd_nxt; return tp->snd_nxt;
else else
return tp->snd_una+tp->snd_wnd; return tcp_wnd_end(tp);
} }
/* Calculate mss to advertise in SYN segment. /* 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,7 +1024,7 @@ static unsigned int tcp_mss_split_point(struct sock *sk, struct sk_buff *skb,
struct tcp_sock *tp = tcp_sk(sk); struct tcp_sock *tp = tcp_sk(sk);
u32 needed, window, cwnd_len; u32 needed, window, cwnd_len;
window = (tp->snd_una + tp->snd_wnd - TCP_SKB_CB(skb)->seq); window = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq;
cwnd_len = mss_now * cwnd; cwnd_len = mss_now * cwnd;
if (likely(cwnd_len <= window && skb != tcp_write_queue_tail(sk))) 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,7 +1134,7 @@ static inline int tcp_snd_wnd_test(struct tcp_sock *tp, struct sk_buff *skb, uns
if (skb->len > cur_mss) if (skb->len > cur_mss)
end_seq = TCP_SKB_CB(skb)->seq + cur_mss; end_seq = TCP_SKB_CB(skb)->seq + cur_mss;
return !after(end_seq, tp->snd_una + tp->snd_wnd); return !after(end_seq, tcp_wnd_end(tp));
} }
/* This checks if the data bearing packet SKB (usually tcp_send_head(sk)) /* 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,7 +1251,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb)
BUG_ON(tcp_skb_pcount(skb) <= 1 || BUG_ON(tcp_skb_pcount(skb) <= 1 ||
(tp->snd_cwnd <= in_flight)); (tp->snd_cwnd <= in_flight));
send_win = (tp->snd_una + tp->snd_wnd) - TCP_SKB_CB(skb)->seq; send_win = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq;
/* From in_flight test above, we know that cwnd > in_flight. */ /* From in_flight test above, we know that cwnd > in_flight. */
cong_win = (tp->snd_cwnd - in_flight) * tp->mss_cache; cong_win = (tp->snd_cwnd - in_flight) * tp->mss_cache;
...@@ -1332,7 +1332,7 @@ static int tcp_mtu_probe(struct sock *sk) ...@@ -1332,7 +1332,7 @@ static int tcp_mtu_probe(struct sock *sk)
if (tp->snd_wnd < size_needed) if (tp->snd_wnd < size_needed)
return -1; return -1;
if (after(tp->snd_nxt + size_needed, tp->snd_una + tp->snd_wnd)) if (after(tp->snd_nxt + size_needed, tcp_wnd_end(tp)))
return 0; return 0;
/* Do we need to wait to drain cwnd? With none in flight, don't stall */ /* 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,7 +1687,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m
return; return;
/* Next skb is out of window. */ /* Next skb is out of window. */
if (after(TCP_SKB_CB(next_skb)->end_seq, tp->snd_una+tp->snd_wnd)) if (after(TCP_SKB_CB(next_skb)->end_seq, tcp_wnd_end(tp)))
return; return;
/* Punt if not enough space exists in the first SKB for /* 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,7 +1831,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
* case, when window is shrunk to zero. In this case * case, when window is shrunk to zero. In this case
* our retransmit serves as a zero window probe. * our retransmit serves as a zero window probe.
*/ */
if (!before(TCP_SKB_CB(skb)->seq, tp->snd_una+tp->snd_wnd) if (!before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp))
&& TCP_SKB_CB(skb)->seq != tp->snd_una) && TCP_SKB_CB(skb)->seq != tp->snd_una)
return -EAGAIN; return -EAGAIN;
...@@ -2497,10 +2497,10 @@ int tcp_write_wakeup(struct sock *sk) ...@@ -2497,10 +2497,10 @@ int tcp_write_wakeup(struct sock *sk)
struct sk_buff *skb; struct sk_buff *skb;
if ((skb = tcp_send_head(sk)) != NULL && if ((skb = tcp_send_head(sk)) != NULL &&
before(TCP_SKB_CB(skb)->seq, tp->snd_una+tp->snd_wnd)) { before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp))) {
int err; int err;
unsigned int mss = tcp_current_mss(sk, 0); unsigned int mss = tcp_current_mss(sk, 0);
unsigned int seg_size = tp->snd_una+tp->snd_wnd-TCP_SKB_CB(skb)->seq; unsigned int seg_size = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq;
if (before(tp->pushed_seq, TCP_SKB_CB(skb)->end_seq)) if (before(tp->pushed_seq, TCP_SKB_CB(skb)->end_seq))
tp->pushed_seq = TCP_SKB_CB(skb)->end_seq; tp->pushed_seq = TCP_SKB_CB(skb)->end_seq;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册