A simple kernel module for skb trace analysis (and a user mode program to receive the data).
It is just a prototype.
-
Build a
linux-4.14.170kernel, overwrite the source codeskbuff.hto/usr/src/linux-4.14.170/include/linux/skbuff.handskbuff.cto/usr/src/linux-4.14.170/net/core/skbuff.c. -
Rebuild the kernel.
-
Compile the kernel module
pktshark.cd pktshark makeThen you can get a kernel module called
pktshark.ko. -
Install the kernel module
pktshark.ko:insmod pktshark.ko
You can use command
dmesg | tailto show the kernel module is installed and running. -
Build the user mode program pktshark-monitor. This program is modified from https://github.com/nhorman/dropwatch. You should install the dependencies of
dropwatchand use autotools to build (same todropwatch):cd pktshark_monitor ./autogen.sh ./configure makeThen you get a executable file in
/pktshark_monitor/src. -
Run it.
This module is just a prototype hooking only 3 easy-to-hook function ip_do_fragment, ip_output, ip_send_skb to test its basic functionalities by using jprobe.
To trace more functions, you should build the module into the kernel and manually add the pktshark_tracepoint into the kernel code.