I’ve been experimenting with WinpkFilter running with Fast I/O in C++ and I wanted to ask how to properly clean it up.
The examples I see in the repo just reset the adapter mode flags, flush the queues, then free the memory for the Fast I/O section and the packet buffers. To be honest, I was expecting some ioctl to notify the driver that we no longer wish to use the shared memory (which by this point is meant to be free’d anyway).
Am I missing anything?
Also, if I only wanted to disable Fast I/O temporarily (stop the capture altogether) and re-enable it later, should I keep the FAST_IO_SECTION around and re-use it? Calling InitializeFastIo the second time fails (returns FALSE), so it doesn’t seem like it’s the intended way.
Note that Fast I/O is an experimental API and is only useful under certain conditions. For example, when you need minimal packet capture latency, and you can dedicate one (or more) CPU cores to poll packets from the driver. Historically, I added it at the request of a user who needed it for an arbitrage trading platform. And it is generally focused on server applications, where you manage and control all available resources. For client-side solutions, I would recommend using traditional I/O.
Regarding your questions, please note that only one driver file object (one instance of CNdisApi) is allowed to use Fast I/O. And once you no longer want to use Fast I/O, just close the corresponding driver file object (destroy the CNdisApi instance) and the driver will do all the necessary cleanup. If you only want to pause packet capture, simply clear the adapter mode flags. To re-enable packet capture, just set appropriate flags back again.
Please let me know if you have any further questions.