Question

The sk_buff has two places where it can store the next fragmentation data:

skb_shinfo(head)->frag_list 
skb_shinfo(head)->frags[]

May someone please explain the differences between these two ways to handle fragmentation.

Thanks and Best Regards!

Was it helpful?

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 frags[] structure starting with the 2nd fragment till nth fragment. The first fragment is always specified by the data and tail pointers. 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 arrangment

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

OTHER TIPS

skb_shinfo(head)->frags[]

If the NIC supports SG I/O __ip_append_data will copy user space data to skb_shinfo(head)->frags. 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 packet to 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;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top