I want to call my function to process the user data af开发者_高级运维ter tcp processing of the packet is completed and before packet is given to the user space (or added to the socket receive queue). Is there any way to do the same in linux kernel? Thanks
First of all, packets aren't sent to userspace by TCP
. Only data is sent (bytes). If you want to intercept data you can:
- Write your own kernel code and intercept system calls (and possibly internal TCP functions such as
tcp_input
) - Use Netlink sockets that let you intercept packets (with all their headers)
- Use Divert sockets (same as above) if you have them
- Use raw sockets (you get copies of the packets, and you can't change them or stop them from propagating)
精彩评论