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

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

 



On Thu, May 09, 2019 at 01:33:58PM +0200, Fernando Fernandez Mancera wrote:
> This patch introduces the use of nft input files variables in 'jump'
> statements, e.g.
> 
> define dest = chainame
> 
> add rule ip filter input jump $dest

You need two patches to achieve this.

First patch should replace the chain string by an expression, ie.

diff --git a/include/expression.h b/include/expression.h
index 6416ac090d9f..d3de4abfd435 100644
--- a/include/expression.h
+++ b/include/expression.h
@@ -240,7 +240,7 @@ struct expr {
                struct {
                        /* EXPR_VERDICT */
                        int                     verdict;
-                       const char              *chain;
+                       struct expr             *chain;
                };
                struct {
                        /* EXPR_VALUE */

Then, this first patch should also update the whole codebase to use
this new chain expression. From the parser, you will have to call
constant_expr_alloc() using the string_type datatype to store the
chain string. Still from this initial patch, you also have to call
expr_evaluate() from stmt_evaluate_verdict() on this new chain
expression field. You will also need to update the netlink_delinearize
path to allocate the constant expression so ruleset listing does not
break.

Then, the second patch only needs to update the parser to allocate the
symbol expression, very much like you did in this WIP patch and things
will just work out of the box, given that first patch is now calling
expr_evaluate() :).



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

  Powered by Linux