Re: a problem about non-linear sk_buff

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

 




AFAIK, Non-linear skb is 2.4.x-ac thing with zero-copy patch
added. In traditional (2.2.x, 2.4.x) skb, "header followed by data" is the
rule, i.e., the header and data  are contiguous in physical memory. Now,
thats a bit of a constraint. So, some area in physical memory 
(== sizeof(struct skb_shared_info) + ) is kept
after skb->end in the first fragment, where pointers to other
fragments are kept. This is done using
skb_shared_info structure. I.e., that extra memory is casted to struct
skb_shared_info, and you keep the fragment information there.  
A cut and paste from 2.4.2-ac9 patch may clear some of the things (the
name of the patch here may be wrong, I think ;) but it is available on
the net easily).

+
+typedef struct skb_frag_struct skb_frag_t;
+
+struct skb_frag_struct
+{
+	struct page *page;
+	__u16 page_offset;
+	__u16 size;
+};
+
+/* This data is invariant across clones and lives at
+ * the end of the header data, ie. at skb->end.
+ */
+struct skb_shared_info {
+	atomic_t	dataref;
+	unsigned int	nr_frags;
+	struct sk_buff	*frag_list;
+	skb_frag_t	frags[MAX_SKB_FRAGS];
+};
+

__ AND ___

+#define skb_shinfo(SKB)		((struct skb_shared_info
*)((SKB)->end))
 
So, you need not have to carry other pointers in the main skb
structure, but still you are tracking multiple fragments!! 
An excellent hack indeed :)

Those cards which can do scatter gather DMA (with hardware checksum
support) can do a gather from multiple locations. So, data can go directly
from page cache, giving you perhaps zero-copy sendfile call. 

This is what I could understand looking at the above patch. Deep down in
TCP code when linearization etc happen, .... the code is your friend I
guess, I haven't studied those parts thoroughly yet.

HTH
sourav
--------------------------------------------------------------------------------
SOURAV SEN    MSc(Engg.) CSA IISc BANGALORE URL : www2.csa.iisc.ernet.in/~sourav 
--------------------------------------------------------------------------------
"Systems research cannot be just science; there must be engineering, 
design, and art"                                          - Rob Pike

On Thu, 11 Oct 2001, Jianyong Zhang wrote:

> Hi,
> 
>   I'm a newcomer of this list.  I want to understand the tcp/ip stack's
> implementaion, and hope that I can get your help.
> 
>   I find that that sk_buff can be fragmented, and it's called nonlinear.
> What's the meaning of nonlinear?  And what are the meaning of sk_buff's
> fields: skb->data_len and skb_shinfo(skb)?  I have no idea about them.
> May you explain them?  Thank you.
> 
>   By the way, as far as I knew, maybe these fields have three usage:
> 1 when skb->len > mss_now, the function tcp_fragment() will call, these
> fields will be used;
> 2. system call sys_sendfile();
> 3. zero-copy networking.
> 
>   But my understanding is very unclear.  May you give a clear explanation?
> 
> Jianyong Zhang
> 
> -
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> IRC Channel:   irc.openprojects.net / #kernelnewbies
> Web Page:      http://www.kernelnewbies.org/
> 




-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[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