Tuesday, April 05, 2005

snooping gld-based NIC drivers using dtrace

Hi.
I have just posted a script at http://www.bruningsystems.com/rtlsio.p
that allows one to snoop incoming/outgoing packets on a Realtek NIC.
The script is very easy to change for any other GLD-based NIC (see
the comment at the beginning of the script to determine what needs
to be changed.)
To run the script, save it and then:

# dtrace -q -C -s ./rtlsio.p

Let me know what you think.

max

2 comments:

Anonymous said...

Interesting script.. I noticed in your comments you wanted a way to print out the payload. This is easily done with the tracemem() function.

Here's a short script I call mblk.d, which takes a function name as the first arg, and an argument place as the second. Only shows 48 bytes, but that's configurable.. Usage:

# mblk.d ip_rput arg1


#!/usr/sbin/dtrace -Fs

$1:entry
{
mp = (mblk_t *) $2;

tracemem(mp->b_rptr, 48);
}


It's very handy to debug :)

Max Bruning said...

Thanks Yuzo!
To print the entire data,
use:

tracemen(mp->b_rptr, mp->b_wptr-mp->b_rptr);

max