Skip to content

Commit

Permalink
tcp: Do not tack on TSO data to non-TSO packet
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
herbertx authored and davem330 committed Jun 30, 2009
1 parent 8e5b9dd commit 6828b92
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,13 +903,17 @@ int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
iov++;

while (seglen > 0) {
int copy;
int copy = 0;
int max = size_goal;

skb = tcp_write_queue_tail(sk);
if (tcp_send_head(sk)) {
if (skb->ip_summed == CHECKSUM_NONE)
max = mss_now;
copy = max - skb->len;
}

if (!tcp_send_head(sk) ||
(copy = size_goal - skb->len) <= 0) {

if (copy <= 0) {
new_segment:
/* Allocate new segment. If the interface is SG,
* allocate skb fitting to single page.
Expand All @@ -930,6 +934,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,

skb_entail(sk, skb);
copy = size_goal;
max = size_goal;
}

/* Try to append data to the end of skb. */
Expand Down Expand Up @@ -1028,7 +1033,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg,
if ((seglen -= copy) == 0 && iovlen == 0)
goto out;

if (skb->len < size_goal || (flags & MSG_OOB))
if (skb->len < max || (flags & MSG_OOB))
continue;

if (forced_push(tp)) {
Expand Down

0 comments on commit 6828b92

Please sign in to comment.