Developers' Tips and Tools
Network Captures
Problem diagnosis (aside from core dumps) usually starts with a network capture. Solaris provides the program snoop(1M) that can be used to capture SMB traffic as follows:
snoop -o mycapture1.snoop host myserver
This assumes you're running snoop on the CIFS client, and "myserver" is the name of your CIFS server.
The most convenient tool for analyzing such capture files is Wireshark. There is an effort underway to add Wireshark to OpenSolaris, but until that's completed, you'll have to get it from blastwave.
Debug Messages
There are lots of debug messages in the CIFS client code, and you can see them only by attaching DTrace probes to some internal functions that exist only for this purpose.
Here is a very simple DTrace script to let you see debug messages:
#!/usr/sbin/dtrace -s
/ This shows internal debug messages. /
sdt:nsmb::debugmsg2
{
printf("\n\t %s: %s", stringof(arg0), stringof(arg1));
}
/ This shows internal error messages. /
sdt:nsmb::debugmsg3
{
printf("\n\t %s: %s", stringof(arg0), stringof(arg1));
tracemem(arg2, 16);
}
This, and some other DTrace scripts may be downloaded from the Files area.
Digging in to the Code
The Internals presentation
is a good place to start. It describes the high-level design of the CIFS client modules, data structures, functions, and code organization. It also has some examples of how to use the mdb(1M) modules provided with the CIFS client kernel objects.
The sources may be found in the onnv-gate
Here are the locations of CIFS client components:
- usr/src/uts/common/netsmb Headers exported by smbfs kernel code to it's library
- usr/src/uts/common/fs/smbclnt/netsmb "nsmb" driver
- usr/src/uts/common/fs/smbclnt/smbfs smbfs loadable filesystem module
- usr/src/lib/libsmbfs smbfs library for smbutil, mount_smbfs
- usr/src/lib/pam_modules/smbfs PAM module for setting smbfs keychain on login
- usr/src/cmd/fs.d/smbclnt commands: smbutil, mount_smbfs
- usr/src/cmd/mdb/common/modules/nsmb mdb module for the "nsmb" driver
- usr/src/cmd/mdb/common/modules/smbfs mdb module for the "smbfs" kernel module.
Testing the Code
Vilas Deshpande of the Solaris NAS Quality Engineering group has released the CIFS client test suite.