- 论坛徽章:
- 0
|
skb_share_check函数中,会判断skb->use是否等于1,如果不等于1,克隆skb包,创建新的skb结构体,并回收原有skb结构体
从收包角度看,什么情况下,use不等于1?
从发包角度看,什么情况下,use不等于1?
上述情况下,为什么要克隆skb包,回收原有skb结构体,如果仅仅脱离SOCKET,为什么不做Update操作?非得复制一份再删除?
还请各位高手多多帮忙!
- int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
- {
- struct iphdr *iph;
- u32 len;
- /* When the interface is in promisc. mode, drop all the crap
- * that it receives, do not try to analyse it.
- */
- if (skb->pkt_type == PACKET_OTHERHOST)
- goto drop;
- if ((skb = skb_share_check(skb, CSP_GFP_ATOMIC)) == NULL) {
- IP_INC_STATS_BH(IPSTATS_MIB_INDISCARDS);
- goto out;
- }
- ....
- }
- static inline struct sk_buff *skb_share_check(struct sk_buff *skb,
- CSP_gfp_t pri)
- {
- might_sleep_if(pri & __GFP_WAIT);
- if (skb_shared(skb)) {
- struct sk_buff *nskb = skb_clone(skb, pri);
- kfree_skb(skb);
- skb = nskb;
- }
- return skb;
- }
复制代码 |
|