BPF – In-kernel virtual machine [pdf]
events.linuxfoundation.org
events.linuxfoundation.org
https://www.usenix.org/system/files/conference/osdi14/osdi14...
Actually you could have stateful loops too. Make each packet duplicated at iptables and each time increment the counter. Send one to 127.0.0.1 (true, continue) and one to 127.0.0.2 (false, stop). The right answer is accepted, wrong dropped.