Недавно я читал Linux код сетевого стека ядра, но теперь я застрял в нескольких строках функции skb_segment (), я уже понял все виды разгрузок TSO / UFO / GSO / GRO , но я просто не могу понять, как эти строки имеют смысл.
код:
/**
* skb_segment - Perform protocol segmentation on skb.
* @head_skb: buffer to segment
* @features: features for the output path (see dev->features)
*
* This function performs segmentation on the given skb. It returns
* a pointer to the first in a list of new skbs for the segments.
* In case of error it returns ERR_PTR(err).
*/
struct sk_buff *skb_segment(struct sk_buff *head_skb,
netdev_features_t features)
{
... ...
if (list_skb && !list_skb->head_frag && skb_headlen(list_skb) &&
(skb_shinfo(head_skb)->gso_type & SKB_GSO_DODGY)) {
/* gso_size is untrusted, and we have a frag_list with a linear
* non head_frag head.
*
* (we assume checking the first list_skb member suffices;
* i.e if either of the list_skb members have non head_frag
* head, then the first one has too).
*
* If head_skb's headlen does not fit requested gso_size, it
* means that the frag_list members do NOT terminate on exact
* gso_size boundaries. Hence we cannot perform skb_frag_t page
* sharing. Therefore we must fallback to copying the frag_list
* skbs; we do so by disabling SG.
*/
if (mss != GSO_BY_FRAGS && mss != skb_headlen(head_skb))
features &= ~NETIF_F_SG;
}
... ...
* If head_skb's headlen does not fit requested gso_size, it
* means that the frag_list members do NOT terminate on exact
* gso_size boundaries.
Я не понимаю, почему заголовок head_skb должен соответствовать запрошенному gso_size, и если это не так, как это может означать, что «члены frag_list НЕ заканчиваются на точных границах gso_size»
Не может head_skb иметь данные нескольких размеров gso_size и данные имеет немного (не в gso_size) в головной части sk_buff? и код в skb_segment (), похоже, копирует этот бит данных в головной части независимо от проверок gso_size.
skb_copy_from_linear_data_offset(head_skb, offset,
skb_put(nskb, hsize), hsize);
У кого-нибудь есть идеи?
Спасибо.