6

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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dien Nguyen
  • 2,019
  • 6
  • 30
  • 37

2 Answers2

11

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
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
bjxt
  • 178
  • 1
  • 11
4

skb_shinfo(head)->frags[]

If the NIC supports SG I/O, __ip_append_data will copy user space data to skb_shinfo(head)->frags. The NIC driver (e.g., ixgbe_add_rx_frag) can also use these frags[] to carry the received network traffic; please note that every content in frags[] is a part of a complete packet. A complete packet consists of all frags[] + (skb->data ~ skb->tail).

skb_shinfo(head)->frag_list

This member is not used by IP fragmentation directly. In __ip_make_skb(), the frag_list is used to collect all skbs from sk->sk_write_queue; some NIC drivers also use this frag_list for carrying a packet to the upper network stack. Every content/skb in frag_list is also not a complete packet; tcp_v4_send_ack -> ip_send_unicast_reply -> ip_push_pending_frames -> ip_finish_skb -> __ip_make_skb;

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
firo
  • 1,002
  • 12
  • 20