Packet Injection within netfilter module
Is there any way to inject a newly created packet based on the captured packet inside a netfilter hook call back function? My Goal is to capture a packet change compress its tcp payload and send it. i read ipcomp.c and i used its source. when i change skb size (like len) and tail pointer kernel hangs. maybe the way to do, is to create a new packet based on captured packet and ask kernel to send it. I just don't know how to ask kernel to send a newly created packet?
Quoted 8 lines · Ali Hamidi
Is there any way to inject a newly created packet based on the captured packet inside a netfilter hook call back function? My Goal is to capture a packet change compress its tcp payload and send it. i read
ipcomp.cand i used its source. when i change skb size (like len) and tail pointer kernel hangs. maybe the way to do, is to create a new packet based on captured packet and ask kernel to send it. I just don't know how to ask kernel to send a newly created packet?
I'm not sure this will work -- it's just an idea that comes to mind. Perhaps you could use TUN to inject a newly created packet from a userspace application?
packet ---> netfilter rule with userspace target ---> userspace payload compressor ---> /dev/tunX
Signature · 4 lines
Ben Gardiner Nanometrics Inc. +1 (613) 592-6776 x239 http://www.nanometrics.ca
A message that is not in the archive (sent off-list or not yet received): [email protected]
Dear Justin,
I just want to thank you for you good reply. Your code saved my life in a school project. It is well-written and I learned many things from it, because I am a newbie in netfilter kernel modules programming. Any way Thanks again for your reply. You gave me new hope to continue.
Quoted 32 lines · Justin Yaple
Ali,
Are you sending this copied packet somewhere else? If your goal is just to modify the skb why make a copy before you modify it? I have written a kernel module that can compress/decompresses TCP payloads for traffic between any number of hosts if the traffic is routed through two systems running my module. If you want to download the source you can get it from
http://packetsqueezer.portal.codespaces.com.To send a new skb though you can do this. It assumes all the required fields are already populated correctly.
NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, skb->dst->dev, dst_output); // Sent the packet.Quoted 14 lines · Ali Hamidi
Is there any way to inject a newly created packet based on the captured packet inside a netfilter hook call back function?
My Goal is to capture a packet change compress its tcp payload and send it. i readipcomp.cand i used its source. when i change skb size (like len) and tail pointer kernel hangs. maybe the way to do, is to create a new packet based on captured packet and ask kernel to send it. I just don't know how to ask kernel to send a newly created packet?
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html