False reading of /proc/net/ip_conntrack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Suppose we want to count connections. We might use wc, grep, sed, awk, or dd.

It turns out that only cat reads 100% of the records in the file.

wc, grep, and sed each read exactly about every other line.

awk reads 75%.

dd reads 80%.



Is this generally known?  Is it generally so?


The system I'm working with is a WRT54GL router running Tomato v1.23, Busybox v1.12.3, Linux 2.4.20 mips


Here's a transcript:

wc -l /proc/net/ip_conntrack 73 /proc/net/ ip_conntrack
wc -l < /proc/net/ip_conntrack                     73
cat /proc/net/ip_conntrack | wc -l                 138

grep -c '' /proc/net/ip_conntrack                  73
grep -c '' < /proc/net/ip_conntrack                73
cat /proc/net/ip_conntrack | grep -c ''            138

sed n '$=' /proc/net/ip_conntrack                  73
sed -n'$=' < /proc/net/ip_conntrack                73
cat /proc/net/ip_conntrack | sed -n '$='           137

awk 'END{print NR}' /proc/net/ip_conntrack         97
awk 'END{print NR}' < /proc/net/ip_conntrack       97
cat /proc/net/ip_conntrack | awk 'END{print NR}'   136

wc -l /proc/net/ip_conntrack 72 /proc/net/ ip_conntrack



Peter
--
To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux