On Thu, Aug 02, 2018 at 06:49:59PM +0200, Máté Eckl wrote:
> On Wed, Aug 01, 2018 at 06:50:14PM +0200, Máté Eckl wrote:
> [...]
> > > > > >
> > > > > > Could you store the string plus offset instead of building this
> > > > > > string that you need to parse again from the evaluation phase?
> > > > > >
> > > > > > Probably you could reuse the existing priority integer field, then,
> > > > > > if
> > > > > > the label is non-NULL, then it means the priority integer becomes an
> > > > > > offset.
>
> I tried another way of doing this. I think it will be good if you don't mind
> adding a new attribute to the parser's union. I have attached the diff for the
> parser, I'd like to test it a bit more before sending a new version of the
> patch.
>
> I also changed the chain and flowtable priority attributes to prio_spec and
> this
> way it is quite simple in the parser and in evaluate.c.
Thanks, this looks fine indeed.
> diff --git a/src/parser_bison.y b/src/parser_bison.y
> index 98bfeba..73af3bc 100644
> --- a/src/parser_bison.y
> +++ b/src/parser_bison.y
> @@ -153,6 +153,7 @@ int nft_lex(void *, void *, void *);
> const struct datatype *datatype;
> struct handle_spec handle_spec;
> struct position_spec position_spec;
> + struct prio_spec prio_spec;
> const struct exthdr_desc *exthdr_desc;
> }
>
> @@ -182,6 +183,8 @@ int nft_lex(void *, void *, void *);
> %token AT "@"
> %token VMAP "vmap"
>
> +%token PLUS "+"
> +
> %token INCLUDE "include"
> %token DEFINE "define"
> %token REDEFINE "redefine"
> @@ -522,6 +525,7 @@ int nft_lex(void *, void *, void *);
> %type <handle> set_spec setid_spec set_identifier
> flowtable_identifier obj_spec objid_spec obj_identifier
> %destructor { handle_free(&$$); } set_spec setid_spec set_identifier
> obj_spec objid_spec obj_identifier
> %type <val> family_spec family_spec_explicit chain_policy
> prio_spec
> +%type <prio_spec> extended_prio_spec
>
> %type <string> dev_spec quota_unit
> %destructor { xfree($$); } dev_spec quota_unit
> @@ -1633,7 +1637,7 @@ flowtable_block_alloc : /* empty */
> flowtable_block : /* empty */ { $$ = $<flowtable>-1; }
> | flowtable_block common_block
> | flowtable_block stmt_separator
> - | flowtable_block HOOK STRING
> PRIORITY prio_spec stmt_separator
> + | flowtable_block HOOK STRING
> PRIORITY extended_prio_spec stmt_separator
> {
> $$->hookstr = chain_hookname_lookup($3);
> if ($$->hookstr == NULL) {
> @@ -1766,7 +1770,7 @@ type_identifier : STRING { $$ = $1; }
> | CLASSID { $$ = xstrdup("classid"); }
> ;
>
> -hook_spec : TYPE STRING HOOK
> STRING dev_spec PRIORITY prio_spec
> +hook_spec : TYPE STRING HOOK
> STRING dev_spec PRIORITY extended_prio_spec
> {
> const char *chain_type =
> chain_type_name_lookup($2);
>
> @@ -1788,9 +1792,37 @@ hook_spec : TYPE STRING
> HOOK STRING dev_spec PRIORITY
> prio_spec
> }
> xfree($4);
>
> - $<chain>0->dev = $5;
> - $<chain>0->priority = $7;
> - $<chain>0->flags |= CHAIN_F_BASECHAIN;
> + $<chain>0->dev = $5;
> + $<chain>0->priority = $7;
> + $<chain>0->flags |= CHAIN_F_BASECHAIN;
> + }
> + ;
> +
> +extended_prio_spec : prio_spec
> + {
> + struct prio_spec spec = {0};
> + spec.num = $1;
> + $$ = spec;
> + }
> + | STRING
> + {
> + struct prio_spec spec = {0};
> + spec.str = xstrdup($1);
> + $$ = spec;
> + }
> + | STRING PLUS NUM
> + {
> + struct prio_spec spec = {0};
> + spec.num = $3;
> + spec.str = xstrdup($1);
> + $$ = spec;
> + }
> + | STRING DASH NUM
> + {
> + struct prio_spec spec = {0};
> + spec.num = -$3;
> + spec.str = xstrdup($1);
> + $$ = spec;
> }
> ;
>
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html