Re: [PATCH 2/2 nft WIP v2] jump: Allow jump to a variable when using nft input files

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

 



Hi Fernando,

On Tue, May 14, 2019 at 06:24:48PM +0200, Fernando Fernandez Mancera wrote:
> Hi Phil,
> 
> On 5/14/19 6:17 PM, Phil Sutter wrote:
> > Hi Fernando,
> > 
> > On Tue, May 14, 2019 at 05:43:39PM +0200, Fernando Fernandez Mancera wrote:
> >> This last patch does not work. The first one works fine with a string as
> >> chain name.
> >>
> > [...]
> >> [...]
> >> This error comes from symbol_parse() at expr_evaluate_symbol() after the
> >> expr_evaluate() call added in the first patch.
> > 
> > Yes, symbol_expr is used only for symbolic constants, therefore
> > symbol_parse() is very restrictive.
> > 
> > [...]>>> diff --git a/src/parser_bison.y b/src/parser_bison.y
> >>> index 69b5773..42fd71f 100644
> >>> --- a/src/parser_bison.y
> >>> +++ b/src/parser_bison.y
> >>> @@ -3841,7 +3841,13 @@ verdict_expr		:	ACCEPT
> >>>  			}
> >>>  			;
> >>>  
> >>> -chain_expr		:	identifier
> >>> +chain_expr		:	variable_expr
> >>> +			{
> >>> +				$$ = symbol_expr_alloc(&@$, SYMBOL_VALUE,
> >>> +						       current_scope(state),
> >>> +						       $1->sym->identifier);
> >>> +			}
> > 
> > I didn't test it, but you can probably just drop the curly braces and
> > everything inside here. 'variable_expr' already turns into an
> > expression (a variable_expr, not symbol_expr), which is probably what
> > you want.
> > 
> 
> I tried that first and I got the same error. I have tried it again.. and
> I am getting the same error.
> 
> file.nft:1:15-17: Error: Can't parse symbolic netfilter verdict expressions
> define dest = ber
>               ^^^

OK, at least it didn't get worse. :)

I looked at the code and it seems you need to implement a 'parse'
callback for struct verdict_type. I guess existing 'parse' callback in
struct integer_type is a good example of how to do it - basically you
need to convert the symbol expression into a constant expression.

Sorry if that's not much help, I'm not really familiar with these
details. :)

Cheers, Phil



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux