- skb_pull(): 缩小数据区空间。headroom空间增大,tailroom空间不变,skb->data指针下移,skb->tail指针不变。 - skb_reserve(): 数据区空间大小不变,headroom空间增大,tailroom空间降低,skb->data和skb->tail同时下移。 对于带有frag page的分片skb,不能使用上述函数,必须使用以下函数: ...
skb_tailroom(skb)+16,GFP_ATOMIC);4if(!nskb)5{6printk("low memory.../n");7dev_kfree_skb(skb);8return-1;9}1011else12{13kfree_skb(skb);//注意,如果此时是钩子函数钩出来的,则skb不能在这里释放,否则会造成死机。1415skb =nskb;16}1718memcpy(skb_put(skb,16),ipbuf,16);//ipbuf为要...
为了给协议头预留空间,可以使用skb_reserve(skb, head_len)方法,该方法会根据参数将data 指针后移,扩展headroom. 可以通过skb_put(skb, data_len) 方法移动tail 指针,扩展用户数据空间。该方法同时会增加skb->len. 这些空间都是从tailroom “挤”出来的,因此需要保证tailroom 有足够的空间。另外要注意skb_put() ...
· void skb_reserve(struct sk_buff *skb, unsigned int len) · int skb_tailroom(const struct sk_buff *skb) · int skb_headroom(const struct sk_buff *skb) · int skb_pagelen(const struct sk_buff *skb) · int skb_headlen(const struct sk_buff *skb) · int skb_is_nonlinear(const st...
int skb_tailroom(const struct sk_buff * skb) skb为要检查的缓冲区 返回&sk_buff尾部空闲空间的字节数 skb_reserve 调整头部的空间 void skb_reserve(struct sk_buff * skb, unsigned int len) skb为要改变的缓冲区,len为要删除的字节数 通过减少尾部空间,增加一个空&sk_buff的首部空间。这仅仅适用于空缓...
linux协议栈skb操作函数
nskb=skb_copy_expand(skb,skb_headroom(skb),skb_tailroom(skb)+16,GFP_ATOMIC); if(!nskb) { printk("low memory.../n"); dev_kfree_skb(skb); return-1; } else { kfree_skb(skb);// 注意,如果此时是钩子函数钩出来的,则skb不能在这里释放,否则会造成死机。 skb...
skb->end = size;// 线性区大小为[data - data+size],所以实际新添加的数据在tailroom off= nhead; #else skb->end = skb->head + size; #endif skb->tail +=off; // data 和 tail同步在原来值上加off skb_headers_offset_update(skb, nhead); ...
·int skb_tailroom(const struct sk_buff *skb) ·int skb_headroom(const struct sk_buff *skb) ·int skb_pagelen(const struct sk_buff *skb) ·int skb_headlen(const struct sk_buff *skb) ·int skb_is_nonlinear(const struct sk_buff *skb) ...
This is what a new SKB looks like rightafter you allocate it using alloc_skb() As you can see, the head, data, and tailpointers all point to the beginning of the data buffer. And the end pointerpoints to the end of it. Note that all of the data area is considered tailroom. ...