[collectd] [PATCH] Make tcpconns run on OpenBSD

Florian Forster octo at verplant.org
Mon Aug 18 17:27:00 CEST 2008


Hi Michael,

I'm just looking through your patch and I need your help..

On Sat, Aug 09, 2008 at 02:44:37PM +0200, Michael Stapelberg wrote:
> +  prev = head = (struct inpcb *)&CIRCLEQ_FIRST(&((struct inpcbtable *)off)->inpt_queue);

If I understand this correctly,
  &((struct inpcbtable *)off)->inpt_queue
points to the _last_ entry in the queue. You later use 
  next = CIRCLEQ_FIRST(&table.inpt_queue);
to get a pointer to the first entry in the queue. Then you iterate over
that queue.

Shouldn't the `CIRCLEQ_FIRST' be skipped in the code above? I've found a
version of OpenBSD's netstat (1.29) and it doesn't do that
`CIRCLEQ_FIRST' when initializing `head'. Also, isn't this `&' before
the macro one indirection too many?

Also, I've dropped `prev' completely because it's never used.

> +    if (inet_lnaof(inpcb.inp_laddr) == INADDR_ANY)
> +      continue;

This looks a lot as if you're ignoring entries, where the local address
is the any address. My guess is that you want to skip unconnected
sockets, right? From the netstat code I have this looks like the way to
go. However, shouldn't we check for IPv6, too? The code I see here does:
  if ((inpcb.inp_flags & INP_IPV6)
      && IN6_IS_ADDR_UNSPECIFIED(&inpcb.inp_laddr6))
    continue;

Last but not least: When running `configure', you should get a line
like:
  Checking for kernel type (???).. unknown
That line should be one of the first. Could you tell me what's in the
parenthesis?

Regards,
-octo
-- 
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080818/ee8567e7/attachment.pgp 


More information about the collectd mailing list