Difference between skbuff frags and frag_list

fragmentation, linux, linux-device-driver, linux-kernel

Solution

Both are used for different cases.

frags[]

When your device supports scatter-gather I/O, and you want it to do the combining of data, etc., you can populate the `frags[]` structure starting with the second fragment till the nth fragment. The first fragment is always specified by the `data` and `tail` pointers. The rest of the fragments are filled in the `frags[]` structure. If you don't use scatter gather, this variable is empty.

frag_list

This is the list of IP fragments. This will be filled during `ip_push_pending_frames`.

Say your `sk_buffs` are in this arrangement,

sk_buff0->next = sk_buff1
sk_buff1->next = sk_buff2
...
sk_buffn-1->next = sk_buffn

After `ip_push_pending_frames` is called

sk_buff0->frag_list = sk_buff1
sk_buff1->next = sk_buff2
...
sk_buffn-1->next = sk_buffn

Simply put

- `frags[]` are for scatter-gather I/O buffers

- `frag_list` is for IP fragments

Problem

The sk_buff has two places where it can store the next fragmentation data: ``` skb_shinfo(head)->frag_list skb_shinfo(head)->frags[] ``` What are the differences between these two ways to handle fragmentation?

Original source