aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-06-28 14:06:41 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-29 22:41:43 -0400
commit6828b92bd21acd65113dfe0541f19f5df0d9668f (patch)
treebe9b1009500891d7598a2c19a63fad9c0a28f17c /net
parent8e5b9dda99cc86bdbd822935fcc37c5808e271b3 (diff)
tcp: Do not tack on TSO data to non-TSO packet
If a socket starts out on a non-TSO route, and then switches to a TSO route, then we will tack on data to the tail of the tx queue even if it started out life as non-TSO. This is suboptimal because all of it will then be copied and checksummed unnecessarily. This patch fixes this by ensuring that skb->ip_summed is set to CHECKSUM_PARTIAL before appending extra data beyond the MSS. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/tcp.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 17b89c523f9d..7870a535dac6 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -903,13 +903,17 @@ int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
903 iov++; 903 iov++;
904 904
905 while (seglen > 0) { 905 while (seglen > 0) {
906 int copy; 906 int copy = 0;
907 int max = size_goal;
907 908
908 skb = tcp_write_queue_tail(sk); 909 skb = tcp_write_queue_tail(sk);
910 if (tcp_send_head(sk)) {
911 if (skb->ip_summed == CHECKSUM_NONE)
912 max = mss_now;
913 copy = max - skb->len;
914 }
909 915
910 if (!tcp_send_head(sk) || 916 if (copy <= 0) {
911 (copy = size_goal - skb->len) <= 0) {
912
913new_segment: 917new_segment:
914 /* Allocate new segment. If the interface is SG, 918 /* Allocate new segment. If the interface is SG,
915 * allocate skb fitting to single page. 919 * allocate skb fitting to single page.
@@ -930,6 +934,7 @@ new_segment:
930 934
931 skb_entail(sk, skb); 935 skb_entail(sk, skb);
932 copy = size_goal; 936 copy = size_goal;
937 max = size_goal;
933 } 938 }
934 939
935 /* Try to append data to the end of skb. */ 940 /* Try to append data to the end of skb. */
@@ -1028,7 +1033,7 @@ new_segment:
1028 if ((seglen -= copy) == 0 && iovlen == 0) 1033 if ((seglen -= copy) == 0 && iovlen == 0)
1029 goto out; 1034 goto out;
1030 1035
1031 if (skb->len < size_goal || (flags & MSG_OOB)) 1036 if (skb->len < max || (flags & MSG_OOB))
1032 continue; 1037 continue;
1033 1038
1034 if (forced_push(tp)) { 1039 if (forced_push(tp)) {