net: add a minimal framework to intercept incoming packets
We add the ability to register/unregister an interceptor on the Rx
path of any netdevice. The function is called with the packet, and
it returns a verdict (drop/pass/xmit).
The interceptor works in the napi context but since it only considers
the dev weight for returned packets, it's not much of a problem.
At the moment only the mvneta driver uses it. It registers its own
interceptor that it provides because it's easier this way for now
(no refcount etc...). The function is able to block 1.4 Mpps with
only 9% of 1 CPU core on the AX3 :
root@ax3:~# dmesg|tail -1; sleep 10; dmesg|tail -1
eth2:DROP:c0=34209792 l=66 d=c7553302: 000a:8507:0d16 0101:0203:0405 0800:4500
eth2:DROP:c0=48119808 l=66 d=c74aba42: 000a:8507:0d16 0101:0203:0405 0800:4500
root@ax3:~# echo $(((48119808-34209792)/10))
1391001
It's worth noting that the sender couldn't send faster.
root@ax3:~# vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 0 3079248 4484 7740 0 0 0 0 38273 244 0 8 92 0
0 0 0 3079280 4484 7740 0 0 0 0 38642 249 0 9 91 0
2 files changed