Re: more fun with procfs (netfilter)

From: Alexander Viro (viro@math.psu.edu)
Date: Tue Nov 20 2001 - 05:19:12 EST


On Tue, 20 Nov 2001, Rusty Russell wrote:

> In message <Pine.GSO.4.21.0111190156140.17210-100000@weyl.math.psu.edu> you wri
> te:
> > Reason: netfilter procfs files try to fit entire records into the user
> > buffer. Do a read shorter than record size and you've got zero. And
> > read() returning 0 means you-know-what...
>
> Yes. Don't do this.
>
> Hope that helps,

That's nice, but...

% awk '/ESTABLISHED/{print $5}' /proc/net/ip_conntrack| wc -l
26
% grep ESTABLISHED /proc/net/ip_conntrack| wc -l
56
%

- IOW, awk (both gawk and mawk) loses everything past the first 4Kb.
And yes, it's a real-world example (there was more than $5 and it was
followed by sed(1), but that doesn't affect the result - lost lines).

So the list of "don't do this" is a bit longer than just reading it
from shell.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Nov 23 2001 - 21:00:23 EST