netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* skb_segment() questions
@ 2009-03-05  0:08 James Huang
  0 siblings, 0 replies; 12+ messages in thread
From: James Huang @ 2009-03-05  0:08 UTC (permalink / raw)
  To: netdev

Hi all,

    After spending hours trying to understand how GSO and GRO works in the 
latest Linux kernel (net-next-2.6.git), I am still quite confused about 
the implementation of skb_segment():

(1) Comments about the roles of some critical variables in the routine will 
help. Among them, len, hsize, and offset are not as confusing and I figured 
they have the following meanings:

len: amount of payload to "copy" into nskb
hsize: amount of payload to copy into nskb's head buffer 
offset: offset (from L2 header) of skb's payload to start "copy" into nskb

However, the variable "pos" is quite ambiguous. The value of "pos" at the 
beginning of each iteration of the do loop seems to depend on the current 
fragment being processed.  If current fragment is the head buffer of skb, pos 
is set to offset(end of the head buffer).  But if the current fragment is a 
page entry in skb or a skb in the frag_list, then pos is set to offset
(beginning of the current fragment).

(2) What is the purpose of the following check?

`    if (pos >= offset + len)
        continue;

     If the payload in the head buffer of skb has at least mss bytes, this 
check will succeed and no payload in skb’s head buffer will be copy into nskb 
through a call to skb_copy_from_linear_data_offset(). Something seems to be 
wrong here.

(3) Variable "hsize" seems to have a new meaning within the following if 
statement:

       if (!hsize && i >= nfrags) {
                      :
                      :
	   hsize = skb_end_pointer(nskb) - nskb->head;
	   if (skb_cow_head(nskb, doffset + headroom)) {
	 	kfree_skb(nskb);
		goto err;
	   }

	   nskb->truesize += skb_end_pointer(nskb) - nskb->head - 
hsize;                :
                      :
       }

    If so, it will be better to use a different variable here.

(4) When will the if condition (if (pos < offset + len)) just before 
skip_faglist become true?  When the if condition is true, nskb will have a non-
null frag_list. How do we know that the output interface's driver will support 
such a skb?

(5) There are some assumptions about the input skb. These assumptions are 
asserted by BUG_ON() statements throughout the routine.  It will help to list 
those assumptions at the very beginning of skb_segment().


Thanks,
James Huang




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-04-20 11:57 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <f0ed9b110903041912v6fba381fm4da792d49b1cbb91@mail.gmail.com>
2009-03-29  2:07 ` skb_segment() questions Herbert Xu
2009-03-29  6:39   ` David Miller
2009-03-30  8:50     ` Mark McLoughlin
2009-03-30 20:57       ` David Miller
2009-04-20 11:12         ` Mark McLoughlin
2009-04-20 11:57           ` David Miller
2009-04-01  9:18   ` [PATCH] " Jarek Poplawski
2009-04-01  9:24     ` Herbert Xu
2009-04-01  9:50       ` Jarek Poplawski
2009-04-01  9:53         ` Herbert Xu
2009-04-01 10:02           ` Jarek Poplawski
2009-03-05  0:08 James Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).