I am filtering packets using netfilter. Now, I need to place those packet-data into file. I know that we can not directly read/write files from kernel (infect, we should not), but recently I come to know that we can do this using the splice.
Previously, I tried to copy all the packets to user space and then dump them into a file, but it was having very slow operation and I was missing packets. I tried using the netlink and also tried using standard udp sockets to copy from kernel space to user space. I got no good results using this methods because I have very high packet rate.
Please suggest me one good way to write packets to file within kernel space. If anyone having idea/example of using the splice, it would be very much appreciated. thnx.