skb_cloned(): 是否为克隆包。 skb_shared(): 是否被多个进程共享。 skb_share_check():当包被共享时, 建立包的克隆包, 并释放对原包的引用。 skb_unshare(): 当包被克隆时, 建立克隆包的完全拷贝, 并释放与克隆包的引用。 skb_orphan(): 使包成为不属于任何套接字的孤包。 skb协议头指针操作函数: ...
int headerlen = skb->data - skb->head;/* * Allocate the copy buffer */structsk_buff*n =alloc_skb(skb->end - skb->head + skb->data_len, gfp_mask);if(!n)returnNULL;/* Set the data pointer */skb_reserve(n, headerlen);/* Set the tail pointer and length */skb_put(n, skb...
1/**2* __pskb_copy_fclone - create copy of an sk_buff with private head.3* @skb: buffer to copy4* @headroom: headroom of new skb5* @gfp_mask: allocation priority6* @fclone: if true allocate the copy of the skb from the fclone7* cache instead of the head cache; it is recomm...
通常,当构造一个用于发送的数据包时,需要留出足够的空间给协议头,包括 TCP/UDP header, IP header 和链路层头。 对IPv4 数据包,可以从 sk->sk_prot->max_header 知道协议头的最大长度。 skb_reserve(skb, header_len); 上 图是调用 skb_reserver() 后的情况 5.3. 将用户空间数据拷贝到 buffer 中 首先...
skb_cloned(skb) || skb_clone_writable(skb, write_len)) return 0; return pskb_expand_head(skb, 0, 0, GFP_ATOMIC); } static inline int pskb_may_pull(struct sk_buff *skb, unsigned int len) { if (likely(len <= skb_headlen(skb))) return 1; if (unlikely(len > skb->len)) ...
skb->cloned = 0; skb->tail += skb->data_len; skb->data_len = 0; return 0; } 1.2 SKB_DATA_ALIGN(X) (((X) + (SMP_CACHE_BYTES - 1)) & \ ~(SMP_CACHE_BYTES - 1)) //将skb中起始offset的内容拷贝到to中,拷贝长度为len ...
20 __u16 hdr_len ; //writable header length of cloned skb 21 unsigned int truesize ; //socket buffer(套接字缓存区的大小) 22 atomic_t users ; //对当前的struct sk_buff结构体的引用次数; 23 __u32 priority ; //这个struct sk_buff结构体的优先级 ...
part only, the verifier detects writes and adds a prologue that is calling bpf_skb_pull_data to effectively unclone the skb from the very beginning in case it is indeed cloned.•A call to this helper is susceptible to change the underlying packet buffer. Therefore, at load time, all ...
- skb is cloned and queued e.g. at socket receive queue. dataref becomes 2. - On CPU 1, skb_copy_datagram_iovec is called on clone 1, is reads nr_frags and sees value > 1. - On CPU 2, __skb_linearize is now called on clone 2, it modified the ...
len,data_len,mac_len,csum;__u32 priority;__u8 local_df:1,cloned:1,ip_summed:2,nohdr:1,nfctinfo:3;__u8 pkt_type:3,