netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Bligh <alex@alex.org.uk>
To: netfilter@vger.kernel.org
Cc: Alex Bligh <alex@alex.org.uk>
Subject: How to programatically atomically write one CHAIN (not table)
Date: Thu, 05 May 2011 13:14:39 +0100	[thread overview]
Message-ID: <0960E691FF860DE35219EA38@nimrod.local> (raw)

What is the best way to programatically atomic add/replace an
entire chain. Assume the table has lots and lots of chains.

Calling "iptables" itself is non-atomic.

I could build an entire replacement chain with a different name
(through repeated calling of iptables -A), then change the
jump statement that calls it. But that seems horribly
inefficient.

Opening a pipe to iptables-restore with "-n" passed
is an option provided I prefix the chains concerned
with "-F <chainname>" (I can't pass the whole thing
and avoid -n as the chain might have (say) 10 rules,
but there might be 100 chains, so this will
be grossly inefficient). However, looking at the
source, it appears merely to call do_command to
parse each line, and I can't see how this can be
atomic. Also, I'd like to avoid the fork().

The FAQ seems to suggest calling any form of library API
is bad.

Any ideas?

-- 
Alex Bligh

             reply	other threads:[~2011-05-05 12:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05 12:14 Alex Bligh [this message]
2011-05-05 14:08 ` How to programatically atomically write one CHAIN (not table) Jan Engelhardt
2011-05-05 15:17   ` Alex Bligh

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=0960E691FF860DE35219EA38@nimrod.local \
    --to=alex@alex.org.uk \
    --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;
as well as URLs for NNTP newsgroup(s).