Re: data of skbuff

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 28 August 2006 12:34, Hayim Shaul wrote:
> On Fri, 25 Aug 2006, Octavian Purdila wrote:
> > On Friday 25 August 2006 11:15, Hayim Shaul wrote:
> >> Hi,
> >>
> >> I have written a module that registers a netfilter hook on
> >> NF_IP_POST_ROUTING (that is , everything that goes out of the machine).
> >> When I look at the skbuff I get the headers (IP/TCP) look fine, but the
> >> data seems to be missing!?!
> >>
> >> The content of the buffer following the end of the TCP header has no
> >> correlation to what is actually being sent over the net.
> >>
> >> I thought it might be fragmanted and I see only one fragment but
> >> skb_shinfo(sb)->frag_list is NULL.
> >>
> >> Can anyone please explain what I am missing?
> >
> > AFAIK, you should check skb_shinfo(skb)->nr_frags. You can use
> > skb_copy_bits() to see all the data of an skb. Also, see if the interface
> > has the scatter-gather feature enabled (ethtool -k).
>
> You were right:
>
> 1. skb_shinfo(skb)->nr_frags should be checked
> 2. disabling scatter/gather made the problem go away
> 3. skb_copy_bits solved the problem
>
> Thanks.
>
> BTW, what's the idea behind scatter/gather?
> What do you benefit from keeping the buffer in different places???
>

Scatter/gather is usefull for implementing zero-copying networking. 

Let's take the gather functionality. Normally, when the application sends data 
the stack will need to create an skb and then copy the user data into this 
skb. With the gather approach, the stack will just create the skb and fill 
the header part, while the data from the application is linked in to the skb 
as a fragment.

The NFS in kernel implementation uses this approach. It is also used by the 
sendfile system call.  Using the gather facilities in kernel is straight 
forward (see tcp_sendpage) and provides great performance improvements.

On the receive side (scatter), it is usefull to get the header and data on 
different pages, so that it is possible to have zero-copying on the receive 
side also. If the data is put in a separate page, then the kernel can map 
that respective page in user-space, without the need to copy the data. 

AFAIK scatter/gather does not work with the current socket API, due to lack of 
buffer management in the API. Maybe someone more experienced can comment more 
on this.

Thanks,
tavi

    




--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux