Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Vijay Subramanian <subramanian.vijay@gmail.com>
Cc: Tom Herbert <therbert@google.com>,
	Linux Netdev List <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>
Subject: Re: Bug in computing data_len in tcp_sendmsg?
Date: Fri, 02 Dec 2011 12:59:48 +0100	[thread overview]
Message-ID: <1322827188.2607.19.camel@edumazet-laptop> (raw)
In-Reply-To: <CAGK4HS84vepB-cOnjOASqXy2gLWGwx=RHnQ3PbbMPezxJ5m3QQ@mail.gmail.com>

Le jeudi 01 décembre 2011 à 22:18 -0800, Vijay Subramanian a écrit :
> >> I am looking at tcp_mtu_probe() and was wondering if this commit also
> >> impacts this function. Once the data are copied from skbs in the write
> >> queue to the probe skb, copied data are cleared from the original skbs
> >> in the write queue.
> >>
> >> It looks like the code assumes that the original skb will have data
> >> either in linear part or in paged part.  The call to
> >> __pskb_trim_head(skb, copy) for example does not clear linear part.
> >>
> >> Can someone more familiar with the code take a look? Apologies if I
> >> have read this wrong.
> >>
> >
> > tcp_mtu_probe() builds a linear skb, and populate it using
> > skb_copy_bits() [ this is frag aware, and aware of payload in header as
> > well ]
> >
> > I see no problem in it.
> >
> 
> Eric,
> I think you may have misunderstood me (I think my post was not very
> clear). Let me try again.
> 
> The MTU probe is built  correctly as a linear skb. As you point out,
> skb_copy_bits() is frag aware and copies data from both the header and
> pages.
> The issue is with the way the data is cleared from the write queue
> later in the function tcp_mtu_probe().
> 
> For example, if the MTU probe size was N bytes, then the probe is
> inserted at the front of the write_queue and N bytes are copied from
> the original write-queue skbs.
> As these N bytes are copied, if an skb is completely consumed, it is
> unlinked from the write_queue and freed. If an skb is only partially
> consumed, then the pointers are adjusted
> accordingly to erase the data. For a paged skb, fully consumed pages
> are unreferenced.
> 
> This is done as follows in tcp_mtu_probe()
> 
>            if (!skb_shinfo(skb)->nr_frags) {
>                skb_pull(skb, copy);
>                if (skb->ip_summed != CHECKSUM_PARTIAL)
>                    skb->csum = csum_partial(skb->data,
>                                 skb->len, 0);
>            } else {
>                __pskb_trim_head(skb, copy);
>                tcp_set_skb_tso_segs(sk, skb, mss_now);
>            }
> 
> It appears that the code assumes the data will either be in the linear
> part (the if condition) or in the paged part (else condition) but not
> both. Is this a correct assumption after the
> recent commit f07d960df33c5aef (tcp: avoid frag allocation for small frames)?
> 
> Since __pskb_trim_head() only only removes data from the non-linear
> part, the data in the linear part is never removed. Maybe for paged
> skbs, we need something like
> headlen = skb_headlen(skb);
> skb_pull(skb, headlen);
> __pskb_trim_head(skb, copy - headlen);
> 
> Thanks for your patience and hope this makes more sense than my previous post.
> 

Thanks for this detailed explanation !

And yes, you're probably right.

Are you willing to submit a patch to fix this ?

(If not, I can do it myself of course)

  reply	other threads:[~2011-12-02 11:59 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-01  1:48 Bug in computing data_len in tcp_sendmsg? Tom Herbert
2011-12-01  3:42 ` Eric Dumazet
2011-12-01  4:06   ` Tom Herbert
2011-12-01  4:16     ` David Miller
2011-12-01  4:17     ` Eric Dumazet
2011-12-01  5:09       ` Tom Herbert
2011-12-01  9:15         ` Eric Dumazet
2011-12-01 17:29           ` Jesse Brandeburg
2011-12-01 18:04             ` David Miller
2011-12-01 20:37             ` Eric Dumazet
2011-12-01 22:18       ` Vijay Subramanian
2011-12-01 22:30         ` Eric Dumazet
2011-12-02  6:18           ` Vijay Subramanian
2011-12-02 11:59             ` Eric Dumazet [this message]
2011-12-02 15:44               ` Eric Dumazet
2011-12-02 16:05                 ` Eric Dumazet
2011-12-02 18:13                   ` David Miller
2011-12-02 18:36                     ` Eric Dumazet
2011-12-02 18:40                       ` David Miller
2011-12-02 20:22                         ` Eric Dumazet
2011-12-02 20:24                           ` David Miller
2011-12-02 20:45                             ` Eric Dumazet
2011-12-02 20:48                               ` Eric Dumazet
2011-12-02 21:30                               ` David Miller
2011-12-03 15:09                                 ` Eric Dumazet
2011-12-04  7:39                                   ` [PATCH] tcp: take care of misalignments Eric Dumazet
2011-12-04 18:21                                     ` David Miller
2011-12-04 18:51                                       ` Eric Dumazet
2011-12-05 23:45                                         ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1322827188.2607.19.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=subramanian.vijay@gmail.com \
    --cc=therbert@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox