- 论坛徽章:
- 0
|
skb_put(len):用于在当前有效数据末尾添加数据
如果 tailroom 够用的话是没有问题的,不够就要扩展了
skb_put() 的具体实现是这样的
- 901 /**
- 902 * skb_put - add data to a buffer
- 903 * @skb: buffer to use
- 904 * @len: amount of data to add
- 905 *
- 906 * This function extends the used data area of the buffer. If this would
- 907 * exceed the total buffer size the kernel will panic. A pointer to the
- 908 * first byte of the extra data is returned.
- 909 */
- 910 static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
- 911 {
- 912 unsigned char *tmp = skb_tail_pointer(skb);
- 913 SKB_LINEAR_ASSERT(skb);
- 914 skb->tail += len;
- 915 skb->len += len;
- 916 if (unlikely(skb->tail > skb->end))
- 917 skb_over_panic(skb, len, current_text_addr());
- 918 return tmp;
- 919 }
复制代码
这个 len 的长度一定不会超过 tailroom,否则会出现问题,916 行就是做了这样的判断,并调用 skb_over_panic 提示错误并 hang
skb_over_panic 的处理如下
- 74 /*
- 75 * Keep out-of-line to prevent kernel bloat.
- 76 * __builtin_return_address is not used because it is not always
- 77 * reliable.
- 78 */
- 79
- 80 /**
- 81 * skb_over_panic - private function
- 82 * @skb: buffer
- 83 * @sz: size
- 84 * @here: address
- 85 *
- 86 * Out of line support code for skb_put(). Not user callable.
- 87 */
- 88 void skb_over_panic(struct sk_buff *skb, int sz, void *here)
- 89 {
- 90 printk(KERN_EMERG "skb_over_panic: text:%p len:%d put:%d head:%p "
- 91 "data:%p tail:%#lx end:%#lx dev:%s\n",
- 92 here, skb->len, sz, skb->head, skb->data,
- 93 (unsigned long)skb->tail, (unsigned long)skb->end,
- 94 skb->dev ? skb->dev->name : "<NULL>");
- 95 BUG();
- 96 }
复制代码 |
|