【文章內(nèi)容簡介】
}.c ? protocol: Packet protocol from driver ? truesize: Buffer size ? head: Head of buffer ? data: Data head pointer ? tail: Tail pointer ? end: End pointer ? destructor: Destruct function ? mark: generic packet mark ? nfct: Associated connection, if any ? ipvs_property: skbuff is owned by ipvs ? peeked: packet was looked at ? nf_trace: filter packet trace flag ? nfctinfo: Connection tracking info ? nfct_reasm: Netfilter conntrack reass ptr ? nf_bridge: Saved data for bridged frame ? tc_index: Traffic control index ? tc_verd: Traffic control verdict ? dma_cookie: DMA operation cookie ? secmark: Security marking for LSM ? And many more! sk_buff fields 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. ? alloc_skb(size, gfp_mask) ? Tries to reuse a sk_buff in the skb_fclone_cache queue。 if not successful, tries to obtain a packet from the central socketbuffer cache (skbuff_head_cache) with kmem_cache_alloc(). ? If neither is successful, then invoke kmalloc() to reserve memory. ? dev_alloc_skb(size) ? Same as alloc_skb but uses GFP_ATOMIC and reserves 32 bytes of headroom ? dev_alloc_skb(device, size) ? Same as dev_alloc_skb but uses a particular device (., NUMA machines) Creating Socket Buffers ? skb_copy(skb,gfp_mask): creates a copy of the socket buffer skb, copying both the sk_buff structure and the packet data. ? skb_copy_expand(skb,newheadroom, newtailroom, gfp_mask): creates a new copy of the socket buffer and packet data, and in addition, reserves a larger space before and after the packet data. Creating Socket Buffers (2) next prev ... head sk_buff data tail end Packet data UDPData UDPHeader IPHeader next prev ... head sk_buff data tail end Packet data UDPData UDPHeader IPHeader next prev ... head sk_buff data tail end Packet data UDPData UDPHeader IPHeader dataref: 1 dataref: 1 dataref: 1 skb_copy() Copying Socket Buffers ? skb_clone(): creates a new socket buffer sk_buff, but not the packet data. Pointers in both sk_buffs point t