The problem is with your Makefile, specifically the sniffer-objs := proto_handler.o
line.
When you specify object, you must specify all objects that are to be included as part of the ko module object. In addition, it seems that if you have multiple source files, the names of the source files must not match the final object name. ie. sniffer.o represents the final linked object comprising both of the source objects. So, instead of having a sniffer.c and a proto_handler.c, change the name to sniffer_main.c.
With your current makefile, sniffer.o will only contain the contents of proto_handler.o which doesn't include any of the module initialisation or exit code, nor the license details.
Here's a dump of nm sniffer.o
with your current makefile, notice the lack of init_module
functions and other module related symbols:
0000000000000000 r ____versions
0000000000000009 r __mod_vermagic5
0000000000000000 r __module_depends
0000000000000000 D __this_module
U printk
0000000000000000 T test_handler
Now, with your source files renamed to sniffer_main.c and proto_handler.c, and the following makefile change:
sniffer-objs := sniffer_main.o proto_handler.o
The final sniffer.o
object contents now includes all the necessary symbols.
nm sniffer.o
:
000000000000000 c r __mod_author13
0000000000000000 r __mod_license14
0000000000000000 T cleanup_module
0000000000000000 T init_module
U printk
0000000000000000 t sniffer_exit
0000000000000000 t sniffer_init
0000000000000000 T test_handler
You can also get some clues as to what's happening in the make output. With your original Makefile, sniffer.c is never compiled to sniffer.o.