How can filter and/or display the name of the interface the packet has arrived from in the Kernel space?
More specifcally I want the name of the interfacen e.g eth0, wlan1 etc to be printed out in the kernel.
Secondly how can I filter packets only from a specific interface e.g eth0 only?
In the hook function, there is parameters
const struct net_device *in
andconst struct net_device *out
. You can print it by:or:
Note: You need to check if is null.
About the second question, you can use in the hook function in
strcmp(in->name, "eth0")
, and then decide drop or accept.