Bug 175793

Summary: [libc] modfind(2) doesn't understand modules with underscores
Product: Base System Reporter: Enji Cooper <ngie>
Component: kernAssignee: Antoine Brodin <antoine>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 9.1-STABLE   
Hardware: Any   
OS: Any   

Description Enji Cooper freebsd_committer freebsd_triage 2013-02-03 04:40:00 UTC
Tried to use kldstat -m to determine whether or not a networking module is loaded, and FWIW it appears to not work as expected:

$ kldstat 
Id Refs Address            Size     Name
 1   30 0xffffffff80200000 91e2d8   kernel
 2    1 0xffffffff80b1f000 264378   zfs.ko
 3    5 0xffffffff80d84000 25e38    krpc.ko
 4    2 0xffffffff80daa000 60d8     opensolaris.ko
 5    1 0xffffffff80e12000 7afb     aio.ko
 6    1 0xffffffff80e1a000 a5bf     if_re.ko
 7    1 0xffffffff80e25000 303fd    nfsd.ko
 8    1 0xffffffff80e56000 110b8    nfscommon.ko
 9    2 0xffffffff80e68000 3ff      nfssvc.ko
10    2 0xffffffff80e69000 faf      nfslock.ko
11    1 0xffffffff80e6a000 e235     nfslockd.ko
12    1 0xffffffff80e79000 2860a    kqemu.ko
$ kldstat -m if_re
kldstat: can't find module if_re: No such file or directory
$ kldstat -m kqemu
Id  Refs Name
198    1 kqemu
$ kldstat -m re   
kldstat: can't find module re: No such file or directory

Not sure why, but this code in kern_module appears to be broken, or just doesn't represent data consistent to expectations from the printouts provided by kldstat:

From kern_module.c:

217 module_t
218 module_lookupbyname(const char *name)
219 {
220         module_t mod;
221         int err;
222 
223         MOD_LOCK_ASSERT;
224 
225         TAILQ_FOREACH(mod, &modules, link) {
226                 err = strcmp(mod->name, name);
227                 if (err == 0)
228                         return (mod);
229         }
230         return (NULL);
231 }

From if_re.c:

 337 DRIVER_MODULE(re, pci, re_driver, re_devclass, 0, 0);

I've seen similar issues with bge(4) on a work machine, so I don't think it's isolated to re(4)...

How-To-Repeat: kldstat -m if_<foo>
Comment 1 Enji Cooper freebsd_committer freebsd_triage 2013-02-03 04:41:40 UTC
	Weird. It just appears to be some networking modules, but not =
others (in particular, if_bge, if_em, if_igb, if_re). if_firewire and =
mpt_cam on the otherhand function as expected :/.
Thanks,
-Garrett=
Comment 2 Glen Barber freebsd_committer freebsd_triage 2013-02-03 04:50:46 UTC
On Sun, Feb 03, 2013 at 04:37:23AM +0000, Garrett Cooper wrote:
> I've seen similar issues with bge(4) on a work machine, so I don't think it's isolated to re(4)...

Definitely not isolated to re(4), nor networking drivers alone.

gjb@nucleus:~ % kldstat -m acpi_asus
kldstat: can't find module acpi_asus: No such file or directory
gjb@nucleus:~ % kldstat -m geom_eli
kldstat: can't find module geom_eli: No such file or directory
gjb@nucleus:~ % kldstat | egrep "(acpi_asus|geom_eli)"
 4    1 0xffffffff81220000 1fc48    geom_eli.ko
 9    1 0xffffffff8138b000 8b10     acpi_asus.ko

Glen
Comment 3 Enji Cooper freebsd_committer freebsd_triage 2013-02-03 04:56:53 UTC
	Yeah.. it's a bit unexpected. I would need to do more digging, =
but my guess is that it's an inconsistency in module naming and =
representation as the loop I showed in the original bug report is simple =
enough >_>=85
Thanks for the info though!
-Garrett=
Comment 4 Antoine Brodin freebsd_committer freebsd_triage 2013-05-23 16:57:15 UTC
State Changed
From-To: open->closed

Close: 
there is no bug 
For drivers using DRIVER_MODULE, the module name is #busname "/" #name 
so for instance pci/re 
% kldstat -m pci/re 
Id  Refs Name 
242    1 pci/re 


Comment 5 Antoine Brodin freebsd_committer freebsd_triage 2013-05-23 16:57:15 UTC
Responsible Changed
From-To: freebsd-bugs->antoine

Track