I want to push skb to prerouting
point of Linux network stack. Is there any way to do this?
I used dev_queue_xmit()
and netif_rx()
functions, but I don't think they can push skb in prerouting
point of Linux network stack.
I'm not entirely clear where this skb originates from. In userland, there are two ways to do this. One is to use a tun
device (and simply write the packet in). The other is to use libpcap
(which has the little known feature of sending raw packets hidden amongst all the receive stuff).
You say you want to do this by registering an ioctl
(presumably meaning adding your own ioctl
) then calling the ioctl
from user space. It isn't immediately obvious why you would want to do that when you can already achieve this without modifying the kernel. However, if you did want to do this, what I'd do is follow the path the tun
driver uses, and do the equivalent of write()
-ing to the tun
device in your new ioctl
. That might mean having a tun
-like interface hanging around to act as the source for the packets. I suspect packets in the system need a source interface of sorts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With