Just a journey

IP 分片

IP Fragmentation

IP 分片

IP协议允许Datagram进行分片(英语:fragmentation,又译分段),将Datagram分割成更小的单位。
这样的话,当数据包比链路最大传输单元(MTU)大时,就可以被分解为很多的足够小片段,以便能
够在其上进行传输。

结构体 skb_shared_info

skb_shared_info

skb_shared_info 的定义

/* 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 short  nr_frags;
    unsigned short  gso_size;
    /* Warning: this field is not always filled in (UFO)! */
    unsigned short  gso_segs;
    unsigned short  gso_type;
    __be32          ip6_frag_id;
    struct sk_buff  *frag_list;
    skb_frag_t  frags[MAX_SKB_FRAGS];
};

用于skb clone的字段:
dataref : This field contains the reference count for this skb. It is incremented each time the buffer is cloned.
用于TCP 分段的字段:
nr_frags : the number of fragments in this packet. This field is used by TCP segmentation.
frags : the array of page table entries. Each entry is actually a TCP segment.
用于IP 分片的字段:
frag_list : This field points to the list of fragments for this packet if it is fragmented.

skb_shared_info 内存中的位置

This structure is placed at the end of the attached data buffer and pointed to by the end field
in the socket buffer structure(struct sk_buff), which points to the end of the data portion of the packet.

 430 #ifdef NET_SKBUFF_DATA_USES_OFFSET
 431 static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
 432 {
 433     return skb->head + skb->end;
 434 }
 435 #else
 436 static inline unsigned char *skb_end_pointer(const struct sk_buff *skb)
 437 {
 438     return skb->end;
 439 }
 440 #endif
 441 
 442 /* Internal */
 443 #define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB)))

skb_shared_info 的作用

  1. IP分片
  2. TCP分段
  3. 记录SKB的clone次数
  4. TODO GSO

TODO GRO

hello markdown

hello world

枯荣大师问道:“你在一阳指上的修为,已到第几品境界?
”本因额头出汗,答道:“弟子根钝,又兼未能精进,只修得
到第四品。”枯荣大师再问:“以你所见,大理段氏的一阳指
与少林拈花指、多罗叶指、无相劫指三项指法相较,孰优
孰劣?”本因道:“指法无优劣,功力有高下。”枯荣大师道:
“不错。咱们的一阳指若能练到第一品,那便如何?”本因
道:“渊深难测,弟子不敢妄说。”枯荣道:“倘若你再活一
百岁,能练到第几品?”本因额上汗水涔涔而下,颤声道:
“弟子不知。”枯荣道:“能修到第一品吗?”
本因道:“决计不能。”枯荣大师就此不再说话。
本因道:“师叔指点甚是,咱们自己的一阳指尚自修习不
得周全,要旁人的武学奇经作甚?

你好,世界

  

你好,世界

我的第一篇文章

08 Jan 2016

Example 2

• example

Basic

Neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit.

  1. dolor
  2. sit

Example

• example

Basic

Neque porro quisquam est, qui dolorem ipsum, quia dolor sit, amet, consectetur, adipisci velit.

  1. dolor
  2. sit
First Header Second Header
Table Cell Table Cell

Blockquote

They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.

Benjamin Franklin

Code

static void asyncEnabled(Dict* args, void* vAdmin, String* txid, struct Allocator* requestAlloc)
{
    struct Admin* admin = Identity_check((struct Admin*) vAdmin);
    int64_t enabled = admin->asyncEnabled;
    Dict d = Dict_CONST(String_CONST("asyncEnabled"), Int_OBJ(enabled), NULL);
    Admin_sendMessage(&d, txid, admin);
}