* (tcpmib|ipmib|linuxmib)_filter_key function use and operation in tcpmib.stp, linuxmib.stp, and ipmib.stp
@ 2011-09-02 15:03 William Cohen
0 siblings, 0 replies; only message in thread
From: William Cohen @ 2011-09-02 15:03 UTC (permalink / raw)
To: SystemTAP
I am cleaning up the documentation for PR13101 ("Networking tapsets should have structured comment"), and the operation of the (tcpmib|ipmib|linuxmib)_filter_key functions looks a bit odd. The functions either return the op or 0. The return value is used as a key if it is non-zero. for example tcpmib-filter-default.stp has:
function tcpmib_filter_key:long (sk:long, op:long)
{
if (!sk) return 0
return op
}
In most cases op is 1, but here is an example use in tcpmib.stp that doesn't follow that:
tcpmib.CurrEstab = kernel.function("tcp_set_state").call ?
{
sk = $sk;
state = $state;
oldstate = tcpmib_get_state($sk);
TCP_ESTABLISHED = 1;
if ( oldstate == TCP_ESTABLISHED ) {
op = -1;
key = tcpmib_filter_key($sk,op);
if ( key ) CurrEstab[key] += op;
} else {
if ( state == TCP_ESTABLISHED ) {
op = 1;
key = tcpmib_filter_key($sk,op);
if ( key ) CurrEstab[key] += op;
}
}
}
The value of op is used both as the key for the associative array and the value to accumulate, which seems a bit odd. The values in linux /proc/net/snmp are scalars: http://lxr.linux.no/#linux+v3.0.4/net/ipv4/proc.c . Any insight to why this tcpmib.stp, and linuxmib.stp, and ipmib.stp use associative arrays in those cases?
-Will
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-09-02 15:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-02 15:03 (tcpmib|ipmib|linuxmib)_filter_key function use and operation in tcpmib.stp, linuxmib.stp, and ipmib.stp William Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).