diff options
-rw-r--r-- | include/linux/tcp.h | 1 | ||||
-rw-r--r-- | net/ipv4/tcp.c | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/include/linux/tcp.h b/include/linux/tcp.h index ad2021ccc55a..9d5078bd23a3 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h | |||
@@ -248,6 +248,7 @@ struct tcp_sock { | |||
248 | /* inet_connection_sock has to be the first member of tcp_sock */ | 248 | /* inet_connection_sock has to be the first member of tcp_sock */ |
249 | struct inet_connection_sock inet_conn; | 249 | struct inet_connection_sock inet_conn; |
250 | u16 tcp_header_len; /* Bytes of tcp header to send */ | 250 | u16 tcp_header_len; /* Bytes of tcp header to send */ |
251 | u16 xmit_size_goal_segs; /* Goal for segmenting output packets */ | ||
251 | 252 | ||
252 | /* | 253 | /* |
253 | * Header prediction flags | 254 | * Header prediction flags |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 886596ff0aae..0db9f3b984f7 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -665,7 +665,7 @@ static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now, | |||
665 | int large_allowed) | 665 | int large_allowed) |
666 | { | 666 | { |
667 | struct tcp_sock *tp = tcp_sk(sk); | 667 | struct tcp_sock *tp = tcp_sk(sk); |
668 | u32 xmit_size_goal; | 668 | u32 xmit_size_goal, old_size_goal; |
669 | 669 | ||
670 | xmit_size_goal = mss_now; | 670 | xmit_size_goal = mss_now; |
671 | 671 | ||
@@ -676,7 +676,17 @@ static unsigned int tcp_xmit_size_goal(struct sock *sk, u32 mss_now, | |||
676 | tp->tcp_header_len); | 676 | tp->tcp_header_len); |
677 | 677 | ||
678 | xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal); | 678 | xmit_size_goal = tcp_bound_to_half_wnd(tp, xmit_size_goal); |
679 | xmit_size_goal -= (xmit_size_goal % mss_now); | 679 | |
680 | /* We try hard to avoid divides here */ | ||
681 | old_size_goal = tp->xmit_size_goal_segs * mss_now; | ||
682 | |||
683 | if (likely(old_size_goal <= xmit_size_goal && | ||
684 | old_size_goal + mss_now > xmit_size_goal)) { | ||
685 | xmit_size_goal = old_size_goal; | ||
686 | } else { | ||
687 | tp->xmit_size_goal_segs = xmit_size_goal / mss_now; | ||
688 | xmit_size_goal = tp->xmit_size_goal_segs * mss_now; | ||
689 | } | ||
680 | } | 690 | } |
681 | 691 | ||
682 | return xmit_size_goal; | 692 | return xmit_size_goal; |