From: Paul Evans <paul@mxtelecom.com>
To: netfilter@vger.kernel.org
Subject: Atomic get-and-watch of conntrack table
Date: Mon, 1 Jun 2009 18:36:00 +0100 [thread overview]
Message-ID: <20090601183600.579332c1@nacelle.mxtelecom.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1309 bytes --]
I'd like to write a long-running program that regularly reports
statistics on conntrack usage (total number of connections, number of
NATs, etc...). To do this, the program needs to start up, grab the
current state of the table, and be informed of updates.
This presents a problem. You can't pass conntrack -L -E together.
So either:
a: I run "conntrack -L", then watch "conntrack -E", with the inherent
race condition inbetween where state might change while I'm not
looking
or
b: I start watching "conntrack -E", then run "conntrack -L", with more
subtle race conditions involved in the fact that I might get events
from the -E command which set the state I've already seen by the -L
list; so having to filter those out somehow.
Is there any alternative to this; can I atomically get the current
table, and watch for updates to it? If not I guess I'll have to go for
a careful implementation of case b- start watching, scrape the current
table, and be prepared for "DELETE" or "UPDATE" events to touch items
in the table I don't yet know about, or "NEW" or "UPDATE" events to set
state that I've now already seen... tricky indeed...
--
Paul Evans <paul@mxtelecom.com>
Tel: +44 (0) 845 666 7778
Fax: +44 (0) 870 163 4694
http://www.mxtelecom.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next reply other threads:[~2009-06-01 17:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-01 17:36 Paul Evans [this message]
2009-06-01 20:28 ` Atomic get-and-watch of conntrack table Eric Leblond
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090601183600.579332c1@nacelle.mxtelecom.com \
--to=paul@mxtelecom.com \
--cc=netfilter@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox