netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Varsha Rao <rvarsha016@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft v2] src: Pass stateless, numeric, ip2name and handle variables as structure members.
Date: Thu, 15 Jun 2017 21:34:48 +0200	[thread overview]
Message-ID: <20170615193448.GA25403@salvia> (raw)
In-Reply-To: <5942c2bd.ca40620a.63e1d.3001@mx.google.com>

Hi Varsha,

Almost there, comments below.

On Thu, Jun 15, 2017 at 10:54:06PM +0530, Varsha Rao wrote:
> diff --git a/src/cli.c b/src/cli.c
> index a74411a..777b300 100644
> --- a/src/cli.c
> +++ b/src/cli.c
> @@ -39,6 +39,7 @@ static const struct input_descriptor indesc_cli = {
>  };
>  
>  static struct parser_state *state;
> +struct output_ctx octx;

Hm. I see...

We have to set this dummy to what we get from main.c, ie.

        dummy_octx = *octx;

somewhere in the code, so nft -i regards all options that has been
passed.

>  static void *scanner;
>  
>  static char histfile[PATH_MAX];
> @@ -129,7 +130,7 @@ static void cli_complete(char *line)
>  
>  	parser_init(state, &msgs);
>  	scanner_push_buffer(scanner, &indesc_cli, line);
> -	nft_run(scanner, state, &msgs);
> +	nft_run(scanner, state, &msgs, &octx);
>  	erec_print_list(stdout, &msgs);
>  	xfree(line);
>  	cache_release();
[...]
> diff --git a/src/evaluate.c b/src/evaluate.c
> index 311c86c..ef7075b 100644
> --- a/src/evaluate.c
> +++ b/src/evaluate.c
> @@ -30,7 +30,8 @@
>  #include <utils.h>
>  #include <xt.h>
>  
> -static int expr_evaluate(struct eval_ctx *ctx, struct expr **expr);
> +static int expr_evaluate(struct eval_ctx *ctx, struct expr **expr,
> +			  struct output_ctx *octx);

Why do we need this in evaluate?

>  static const char *byteorder_names[] = {
>  	[BYTEORDER_INVALID]		= "invalid",
> @@ -130,7 +131,7 @@ static int byteorder_conversion(struct eval_ctx *ctx, struct expr **expr,
>  	else {
>  		op = byteorder_conversion_op(*expr, byteorder);
>  		*expr = unary_expr_alloc(&(*expr)->location, op, *expr);
> -		if (expr_evaluate(ctx, expr) < 0)
> +		if (expr_evaluate(ctx, expr, NULL) < 0)

This is all NULL. I guess this has to be with debug?

In such case, you can define a:

        static struct output_ctx octx_debug_dummy;

And use it from code under #ifdef DEBUG.

>  			return -1;
>  	}
>  	return 0;

      reply	other threads:[~2017-06-15 19:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15 17:24 [PATCH nft v2] src: Pass stateless, numeric, ip2name and handle variables as structure members Varsha Rao
2017-06-15 19:34 ` 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=20170615193448.GA25403@salvia \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=rvarsha016@gmail.com \
    /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).