Reputation: 1823
i m writing a module for linux kernel & it try to steal the packet & its related sk_buff. to do so i want to use struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t gfp_mask)
& then pass the return type to the kernel as packet is dropped.
so when kernel gets the info about packet drop it try to free the sk_buff. here my question comes will it affect my newly copied skb & its pointed data of the packet? or now i can play with my new sk_buff?
or is it possible to use skb_clone() & use the packet data part without deleting the referenced data by old sk_buff because it will reduse copying cost of the packet.
Upvotes: 4
Views: 8621
Reputation: 17085
Using skb_copy
will copy both the sk_buff
and the packet to new memory. Meaning when the kernel frees the other one, the copy will not be affected.
skb_clone
in the other hand copies the sk_buff
structure to new memory, but not the packet. Meaning when the old one is freed, your copy will have the packet also freed.
Here are some links:
http://docs.blackfin.uclinux.org/kernel/generated/networking/re68.html (skb_clone)
http://oss.org.cn/ossdocs/gnu_linux/kernel-api/r8086.html (skb_copy)
Upvotes: 5