sk_buff源码
Linux 2.6.26内核中sk_buff结构的定义如下:
struct sk_buff <include/linux/skbuff.h>
- /**
- * struct sk_buff - socket buffer
- * @next: Next buffer in list
- * @prev: Previous buffer in list
- * @sk: Socket we are owned by
- * @tstamp: Time we arrived
- * @dev: Device we arrived on/are leaving by
- * @transport_header: Transport layer header
- * @network_header: Network layer header
- * @mac_header: Link layer header
- * @dst: destination entry
- * @sp: the security path, used for xfrm
- * @cb: Control buffer. Free for use by every layer. Put private vars here
- * @len: Length of actual data
- * @data_len: Data length
- * @mac_len: Length of link layer header
- * @hdr_len: writable header length of cloned skb
- * @csum: Checksum (must include start/offset pair)
- * @csum_start: Offset from skb->head where checksumming should start
- * @csum_offset: Offset from csum_start where checksum should be stored
- * @local_df: allow local fragmentation
- * @cloned: Head may be cloned (check refcnt to be sure)
- * @nohdr: Payload reference only, must not modify header
- * @pkt_type: Packet class
- * @fclone: skbuff clone status
- * @ip_summed: Driver fed us an IP checksum
- * @priority: Packet queueing priority
- * @users: User count - see {datagram,tcp}.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: this packet has been seen already, so stats have been
- * done for it, don’t do them again
- * @nf_trace: netfilter packet trace flag
- * @nfctinfo: Relationship of this skb to the connection
- * @nfct_reasm: netfilter conntrack re-assembly pointer
- * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
- * @iif: ifindex of device we arrived on
- * @queue_mapping: Queue mapping for multiqueue devices
- * @tc_index: Traffic control index
- * @tc_verd: traffic control verdict
- * @ndisc_nodetype: router type (from link layer)
- * @dma_cookie: a cookie to one of several possible DMA operations
- * done by skb DMA functions
- * @secmark: security marking
- */
- struct sk_buff {
- /* These two members must be first. */
- struct sk_buff *next;
- struct sk_buff *prev;
- struct sock *sk;
- ktime_t tstamp;
- struct net_device *dev;
- union {
- struct dst_entry *dst;
- struct rtable *rtable;
- };
- struct sec_path *sp;
- /*
- * This is the control buffer. It is free to use for every
- * layer. Please put your private variables there. If you
- * want to keep them across layers you have to do a skb_clone()
- * first. This is owned by whoever has the skb queued ATM.
- */
- char cb[48];
- unsigned int len,
- data_len;
- __u16 mac_len,
- hdr_len;
- union {
- __wsum csum;
- struct {
- __u16 csum_start;
- __u16 csum_offset;
- };
- };
- __u32 priority;
- __u8 local_df:1,
- cloned:1,
- ip_summed:2,
- nohdr:1,
- nfctinfo:3;
- __u8 pkt_type:3,
- fclone:2,
- ipvs_property:1,
- peeked:1,
- nf_trace:1;
- __be16 protocol;
- void (*destructor)(struct sk_buff *skb);
- #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
- struct nf_conntrack *nfct;
- struct sk_buff *nfct_reasm;
- #endif
- #ifdef CONFIG_BRIDGE_NETFILTER
- struct nf_bridge_info *nf_bridge;
- #endif
- int iif;
- #ifdef CONFIG_NETDEVICES_MULTIQUEUE
- __u16 queue_mapping;
- #endif
- #ifdef CONFIG_NET_SCHED
- __u16 tc_index; /* traffic control index */
- #ifdef CONFIG_NET_CLS_ACT
- __u16 tc_verd; /* traffic control verdict */
- #endif
- #endif
- #ifdef CONFIG_IPV6_NDISC_NODETYPE
- __u8 ndisc_nodetype:2;
- #endif
- /* 14 bit hole */
- #ifdef CONFIG_NET_DMA
- dma_cookie_t dma_cookie;
- #endif
- #ifdef CONFIG_NETWORK_SECMARK
- __u32 secmark;
- #endif
- __u32 mark;
- sk_buff_data_t transport_header;
- sk_buff_data_t network_header;
- sk_buff_data_t mac_header;
- /* These elements must be at the end, see alloc_skb() for details. */
- sk_buff_data_t tail;
- sk_buff_data_t end;
- unsigned char *head,
- *data;
- unsigned int truesize;
- atomic_t users;
- };
This entry was posted in Software Development. Bookmark the permalink.
No comments:
Post a Comment