Re: [PATCH nft v2] src: Pass stateless, numeric, ip2name and handle variables as structure members.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux