All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lutz Jaenicke <ljaenicke@innominate.com>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 07/11] libipt_DNAT: use guided option parser
Date: Wed, 18 May 2011 15:58:19 +0200	[thread overview]
Message-ID: <20110518135819.GA19013@lutz.bln.innominate.local> (raw)
In-Reply-To: <1305121977-4361-8-git-send-email-jengelh@medozas.de>

Hmm.

On Wed, May 11, 2011 at 03:52:52PM +0200, Jan Engelhardt wrote:
> Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
> ---
>  extensions/libipt_DNAT.c |   88 ++++++++++++++++++++-------------------------
>  1 files changed, 39 insertions(+), 49 deletions(-)

> @@ -153,46 +161,29 @@ static int DNAT_parse(int c, char **argv, int invert, unsigned int *flags,
>  	else
>  		portok = 0;
>  
> -	switch (c) {
> -	case '1':
> -		if (xtables_check_inverse(optarg, &invert, NULL, 0, argv))
> -			xtables_error(PARAMETER_PROBLEM,
> -				   "Unexpected `!' after --to-destination");
> -
> -		if (*flags & IPT_DNAT_OPT_DEST) {
> +	xtables_option_parse(cb);
> +	switch (cb->entry->id) {
> +	case O_TO_DEST:
> +		if (cb->xflags & F_TO_DEST) {
>  			if (!kernel_version)
>  				get_kernel_version();
>  			if (kernel_version > LINUX_VERSION(2, 6, 10))
>  				xtables_error(PARAMETER_PROBLEM,
>  					   "Multiple --to-destination not supported");
>  		}
> -		*target = parse_to(optarg, portok, info);
> +		*cb->target = parse_to(cb->arg, portok, info);
>  		/* WTF do we need this for?? */
> -		if (*flags & IPT_DNAT_OPT_RANDOM)
> +		if (cb->xflags & F_RANDOM)
>  			info->mr.range[0].flags |= IP_NAT_RANGE_PROTO_RANDOM;
> -		*flags |= IPT_DNAT_OPT_DEST;
> -		return 1;

If I understand the logic correctly, cb->xflags will have F_TO_DEST set
if the --to-destination option is found. The additional option parsing
is only performed afterwards such that the (cb->xflags & F_TO_DEST) will
be triggered already on the first and valid call and a "Multiple ... not
supported" will be issued.
In the original code the *flags |= IPT_DNAT_OPT_DEST was only performed
at the end of the respective "case" section.

Best regards,
	Lutz
-- 
Dr.-Ing. Lutz Jänicke
CTO
Innominate Security Technologies AG  /protecting industrial networks/
tel: +49.30.921028-200
fax: +49.30.921028-020
Rudower Chaussee 13
D-12489 Berlin, Germany
www.innominate.com

Register Court: AG Charlottenburg, HR B 81603
Management Board: Dirk Seewald
Chairman of the Supervisory Board: Volker Bibelhausen
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-05-18 13:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-11 13:52 guided option parser, run 7 Jan Engelhardt
2011-05-11 13:52 ` [PATCH 01/11] libip6t_mh: use guided option parser Jan Engelhardt
2011-05-11 13:52 ` [PATCH 02/11] libip6t_rt: " Jan Engelhardt
2011-05-11 13:52 ` [PATCH 03/11] libxtables: XTTYPE_ETHERMAC support Jan Engelhardt
2011-05-11 13:52 ` [PATCH 04/11] libxt_mac: use guided option parser Jan Engelhardt
2011-05-11 13:52 ` [PATCH 05/11] libipt_CLUSTERIP: " Jan Engelhardt
2011-05-11 13:52 ` [PATCH 06/11] libxt_iprange: " Jan Engelhardt
2011-05-11 13:52 ` [PATCH 07/11] libipt_DNAT: " Jan Engelhardt
2011-05-18 13:58   ` Lutz Jaenicke [this message]
2011-05-18 14:00     ` Jan Engelhardt
2011-05-18 14:05       ` Lutz Jaenicke
2011-05-18 14:17         ` Jan Engelhardt
2011-05-11 13:52 ` [PATCH 08/11] libipt_SNAT: " Jan Engelhardt
2011-05-11 13:52 ` [PATCH 09/11] libipt_MASQUERADE: " Jan Engelhardt
2011-05-11 13:52 ` [PATCH 10/11] libipt_REDIRECT: " Jan Engelhardt
2011-05-11 13:52 ` [PATCH 11/11] libipt_SAME: " Jan Engelhardt
2011-05-12  9:14 ` guided option parser, run 7 Patrick McHardy

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=20110518135819.GA19013@lutz.bln.innominate.local \
    --to=ljaenicke@innominate.com \
    --cc=jengelh@medozas.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.