building af_packet as a kernel module

valdis.kletnieks at vt.edu valdis.kletnieks at vt.edu
Mon Jul 3 13:53:38 EDT 2017


On Mon, 03 Jul 2017 16:36:01 +0200, Kamil Konieczny said:
> https://stackoverflow.com/questions/448999/is-there-a-way-to-figure-out-what-is-using-a-linux-kernel-module

> and short answer is to use 'lsof' command (ls open files),
> if lsmod fails to give ref info

That's the short - and incorrect - answer.  The long and *much* more
correct answer is on that link, and talks about the kernel tracing facility.

lsof only helps if the module is in use due to a direct reference on a
filesystem object (something you can /bin/ls).

So for instance, if you're trying to figure out why a serial driver
won't unload, finding that somebody has /dev/ttyUSB0 open may help.

But it *won't* help if it's a an indirect reference (a filesystem object is
open, but it's a filesystem on a USB memory device, and  the mount of /dev/sdb1
ends up taking a reference on the SCSI driver which ends up taking its own
reference on the USB driver(s) involved), or a reference via a non-filesystem
opbject.  And on Linux, network interfaces aren't filesystem objects - there
isn't a /dev/eth0 for your ethernet.  That's why you have to use netlink to
enumerate your interfaces.

The *correct* short answer is, of course, "use trace-cmd or kernelshark to
trace calls to module_get for the problem module". :)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 486 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20170703/629a705c/attachment.bin 


More information about the Kernelnewbies mailing list