Skip to contentSkip to conversation

sk_buff allocation

DISCUSSION Emmanuel Varagnat 2 participants 3 messages Jun 12, 2001

lore
Share & tools
lore
#0 lore raw

I'm writing a module that is able to modify outgoing packets. This is done by registering a new entry in ptype_all. But my problem is that in dev_queue_xmit_nit the sk_buff is cloned and that my function get this clone. So my modification on skb->data isn't take into account by the ethernet driver.

My idea was to do my modifications and then copy all my datas starting at skb->data so that nothing in the sk_buff is modified.

But what am I doing if the buffer doesn't have enough room to support the new/modified data ?
skb_cow or skb_copy_expand, for example, will return me a new sk_buff with a new buffer but how could I tell the system that it must "replace" the old sk_buff by this one ?

Thanks

-Emmanuel Varagnat

#1 lore raw
Quoted 5 lines

I'm writing a module that is able to modify outgoing packets. This is done by registering a new entry in ptype_all. But my problem is that in dev_queue_xmit_nit the sk_buff is cloned and that my function get this clone. So my modification on skb->data isn't take into account by the ethernet driver.

Why don't you use netfilter hooks? Write your hook for NF_IP_POST_ROUTING; it will receive sk_buff **pskb, so you can completely replace old skbuff with new.

Signature · 1 line
Alexey
#2 lore raw
In reply to Emmanuel Varagnat
Quoted 3 lines · Alexey Vyskubov

Why don't you use netfilter hooks? Write your hook for NF_IP_POST_ROUTING; it will receive sk_buff **pskb, so you can completely replace old skbuff with new.

Because, it doesn't seems to fit my needs.
The hardware header must present.

But I could have missed something looking at the kernel code.

Thanks a lot

-Manu