【正文】
checks if list == listnext ? skb_queue_len(list): returns length of the queue. ? skb_queue_head(list, skb): inserts the socket buffer skb at the head of the queue and increment list?qlen by one. ? skb_queue_tail(list, skb): appends the socket buffer skb to the end of the queue and increment list?qlen by one. Managing Socket Buffer Queues ? skb_dequeue(list): removes the top skb from the queue and returns the pointer to the skb. ? skb_dequeue_tail(list): removes the last packet from the queue and returns the pointer to the packet. ? skb_queue_purge(): empties the queue list。 need to check the headroom size. ? skb_pull(skb,len): truncates len bytes at the beginning of a packet. ? skb_trim(skb,len): trim skb to len bytes (if necessary) Manipulating sk_buffs ? skb_tailroom(skb): returns the size of the tailroom (in bytes). ? skb_headroom(skb): returns the size of the headroom (datahead) ? skb_realloc_headroom(skb,newheadroom) creates a new socket buffer with a headroom of size newheadroom. ? skb_reserve(skb,len): increases headroom by len bytes. Manipulating sk_buffs (2) Outline ? Intro to socket buffers ? The sk_buff data structure ? APIs for creating, releasing, and duplicating socket buffers. ? APIs for manipulating parameters within the sk_buff structure ? APIs for managing the socket buffer queue. ? Socket buffers are arranged in a dualconcatenated ring structure. struct sk_buff_head { struct sk_buff *next。 increments the pointer tail and skb?len by len。 Socket Buffer Queues next prev ... head sk_buff data tail end Packetdata next prev ... head sk_buff data tail end Packetdata next prev ... head sk_buff data tail end Packetdata next prev qlen: 3 sk_buff_head Socket Buffer Queues ? skb_queue_head_init(list): initializes an skb_queue_head structure ? prev = next = self。 if the list is empty, returns NULL. ? Leaves buffer on the list Managing Socket Buffer Queues Backup sk_buff Alignment ? CPUs often take a performance hit when accessing unaligned memory locations. ? Since an Ether header is 14 bytes, work drivers often end up with the IP header at an unaligned offset. ? The IP header can be aligned by shifting the start