netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Jiri Popelka <jpopelka@redhat.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v2] iptables: add optional [seconds] argument to -w
Date: Fri, 25 Jul 2014 19:08:21 +0200	[thread overview]
Message-ID: <20140725170821.GA5618@salvia> (raw)
In-Reply-To: <1404481841-20084-1-git-send-email-jpopelka@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 692 bytes --]

On Fri, Jul 04, 2014 at 03:50:41PM +0200, Jiri Popelka wrote:
> This patch adds an optional numeric argument
> to -w option (added with 93587a0) so one can
> specify how long to wait for an exclusive lock.
> 
> If the value isn't specified it works as before,
> i.e. program waits indefinitely.
> 
> If user specifies it, program exits after
> the given time interval passes.
> 
> This patch also adds the -w/--wait to nftables
> compat code, so the parser doesn't complain.

Applied.

I had to fix iptables-compat though:

# iptables-compat -I INPUT -w 3 -j ACCEPT
Bad argument `3'
Try `iptables -h' or 'iptables --help' for more information.

I have collapsed the following patch to yours.

[-- Attachment #2: x --]
[-- Type: text/plain, Size: 986 bytes --]

diff --git a/iptables/xtables.c b/iptables/xtables.c
index f7b1a75..d661dd1 100644
--- a/iptables/xtables.c
+++ b/iptables/xtables.c
@@ -684,6 +684,7 @@ int do_commandx(struct nft_handle *h, int argc, char *argv[], char **table,
 {
 	struct iptables_command_state cs;
 	int verbose = 0;
+	int wait = 0;
 	const char *chain = NULL;
 	const char *policy = NULL, *newname = NULL;
 	unsigned int rulenum = 0, command = 0;
@@ -1008,6 +1009,15 @@ int do_commandx(struct nft_handle *h, int argc, char *argv[], char **table,
 					      "You cannot use `-w' from "
 					      "iptables-restore");
 			}
+			if (optarg) {
+				if (sscanf(optarg, "%i", &wait) != 1)
+					xtables_error(PARAMETER_PROBLEM,
+						      "wait seconds not numeric");
+			} else if (optind < argc && argv[optind][0] != '-'
+				   && argv[optind][0] != '!')
+				if (sscanf(argv[optind++], "%i", &wait) != 1)
+					xtables_error(PARAMETER_PROBLEM,
+						      "wait seconds not numeric");
 			break;
 
 		case '0':

      reply	other threads:[~2014-07-25 17:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-04 13:50 [PATCH v2] iptables: add optional [seconds] argument to -w Jiri Popelka
2014-07-25 17:08 ` Pablo Neira Ayuso [this message]

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=20140725170821.GA5618@salvia \
    --to=pablo@netfilter.org \
    --cc=jpopelka@redhat.com \
    --cc=netfilter-devel@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).