Re: building af_packet as a kernel module

2017-07-03 Thread valdis . kletnieks
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". :)



pgpet7C1RIZYr.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: building af_packet as a kernel module

2017-07-03 Thread Kamil Konieczny
Hi,

On 30.06.2017 06:06, Kevin Wilson wrote:
> [...]
> I am using Ubuntu 16.04.
> 
> After reboot, the af_packet.ko kernel module is loaded:
> lsmod

> af_packet  45056  2
> 
> But I cannot remove it:
> rmmod af_packet
> rmmod: ERROR: Module af_packet is in use
> 
> I want to be able to rmmod it, for adding debug printing, etc.
> [...]
I googled this:

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

-- 
Best regards,
Kamil Konieczny
Samsung R Institute Poland


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: building af_packet as a kernel module

2017-07-03 Thread Kamil Konieczny


On 03.07.2017 16:02, Aruna Hewapathirane wrote:
> [...]
> enable internet by running : /sbin/ifconfig etho0 down

sudo /sbin/ifconfig eno1 up

or eth0 or whatever your system names its ethernet devices

> [...]

List net interfaces with:

sudo /sbin/ifconfig

-- 
Best regards,
Kamil Konieczny
Samsung R Institute Poland

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: building af_packet as a kernel module

2017-07-03 Thread Aruna Hewapathirane
> On Fri, Jun 30, 2017 at 12:06 AM, Kevin Wilson  wrote:
> Hello,
> I have tried to set CONFIG_PACKET=m in kernel 4.11 and rebuilt the
> kernel and rebooted.
> I am using Ubuntu 16.04.

> After reboot, the af_packet.ko kernel module is loaded:
> lsmod
> shows:
> af_packet  45056  2

> But I cannot remove it:
> rmmod af_packet
> rmmod: ERROR: Module af_packet is in use

> I want to be able to rmmod it, for adding debug printing, etc.

> How can I find which applications uses it ? (So I will be able to stop
> them, rmmod af_packet, and then insmod it again)?

> Regards,
> Kevin

Hello Kevin,

Quick fix and short answer to your problem is to disable internet.

run this in a shell/terminal: /sbin/ifconfig etho0 down

Now check lsmod again, once internet is disabled the used by column which
lsmod reports as af_packet being used by 2 devices/processes/whatever...
will show 0.

Now when you sbin/rmmod af-packet it will work and unload af_packet.

Do whatever debug printing you have to

sbin/insmod af_packet

enable internet by running : /sbin/ifconfig etho0 down

now check dmesg or what ever you use. Wash, rinse then repeat as needed.

The answer to your question "How can I find which applications uses it ?"
 is something "I" have been trying to figure out for the last 9 odd years.
Maybe folks with more experience can shed some light on how to go about
doing this ?

More experienced equates to = Valdis / Gregkh / DerRichard / Realtime
localmodconfig Steve Rostedt  and too many others to name :)

Hope this helps - Aruna
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


building af_packet as a kernel module

2017-06-29 Thread Kevin Wilson
Hello,
I have tried to set CONFIG_PACKET=m in kernel 4.11 and rebuilt the
kernel and rebooted.
I am using Ubuntu 16.04.

After reboot, the af_packet.ko kernel module is loaded:
lsmod
shows:
af_packet  45056  2

But I cannot remove it:
rmmod af_packet
rmmod: ERROR: Module af_packet is in use

I want to be able to rmmod it, for adding debug printing, etc.

How can I find which applications uses it ? (So I will be able to stop
them, rmmod af_packet, and then insmod it again)?


Regards,
Kevin

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies