On Mon, Oct 29, 2018 at 01:09:31PM +0100, Phil Sutter wrote: > Hi, > > On Mon, Oct 29, 2018 at 12:33:37PM +0100, Pablo Neira Ayuso wrote: > > Add NFT_CTX_OUTPUT_STATELESS flag and enable stateless printing from new > > output flags interface. > > > > Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> > > --- > > v2: Add nft_output_stateless() > > Fix missing conversion to use NFT_CTX_OUTPUT_STATELESS. > > Remove stateless field from struct output_ctx. > > [...] > > > diff --git a/src/statement.c b/src/statement.c > > index e50ac706402d..162922108020 100644 > > --- a/src/statement.c > > +++ b/src/statement.c > > @@ -121,9 +121,9 @@ static void meter_stmt_print(const struct stmt *stmt, struct output_ctx *octx) > > expr_print(stmt->meter.key, octx); > > nft_print(octx, " "); > > > > - octx->stateless++; > > + octx->flags |= NFT_CTX_OUTPUT_STATELESS; > > stmt_print(stmt->meter.stmt, octx); > > - octx->stateless--; > > + octx->flags &= ~NFT_CTX_OUTPUT_STATELESS; > > > > nft_print(octx, "} "); > > > > Are you sure this is safe? If meter_stmt_print() is called with > stateless output enabled, it will be disabled when the function returns. > I guess this should backup octx->flags and restore the old value before > returning to caller. > > Same goes for other places were we do 'stateless++; something(); > stateless--'. Right, I need to annotate old flags.