Skip to content

A missing zero in fwknop

 1 min An idle fwknop daemon kept waking because a microsecond constant disagreed with the fraction written beside it.
Published

Jul 15, 2012

fwknopd was accumulating CPU time on machines with almost nothing happening. I was using it to open SSH access on demand. The packet capture loop stayed busy even when no relevant traffic arrived.

My report included this repeating pattern from strace:

nanosleep({0, 10000000}, NULL)          = 0
poll([{fd=4, events=POLLIN}], 1, 0)     = 0 (Timeout)

Ten million nanoseconds is ten milliseconds. The daemon was sleeping for about a hundredth of a second, then performing another zero-timeout poll. The same behavior appeared on a server and an ARM PandaBoard.

The upstream correction made the constant agree with its comment:

-#define DEF_PCAP_LOOP_SLEEP "10000"  /* a tenth of a second */
+#define DEF_PCAP_LOOP_SLEEP "100000" /* a tenth of a second (in microseconds) */

Spacing is condensed here; the values and comments are from the patch. It also corrected the example configuration and expanded the permitted range. The intended default had always been a tenth of a second. A missing zero made the configured loop wake roughly ten times as frequently.

This did not replace polling with an event-driven design. It repaired the existing design’s interval. The release record credits my report, while the fix itself was made upstream.