netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Garver <eric@garver.life>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft] cache: fix --echo with index/position
Date: Thu, 5 Sep 2019 16:44:32 -0400	[thread overview]
Message-ID: <20190905204432.h2nv4zs5ysxlxhnq@egarver.localdomain> (raw)
In-Reply-To: <20190905170939.4132-1-pablo@netfilter.org>

On Thu, Sep 05, 2019 at 07:09:39PM +0200, Pablo Neira Ayuso wrote:
> Check for the index/position in case the echo flag is set on. Set the
> NFT_CACHE_UPDATE flag in this case to enable incremental cache updates.
> 
> Reported-by: Eric Garver <eric@garver.life>
> Fixes: 01e5c6f0ed03 ("src: add cache level flags")
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
>  src/cache.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/src/cache.c b/src/cache.c
> index cffcbb623ced..71d16a0fbeed 100644
> --- a/src/cache.c
> +++ b/src/cache.c
> @@ -106,6 +106,9 @@ unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds)
>  		case CMD_CREATE:
>  			if (nft_output_echo(&nft->output)) {
>  				flags = NFT_CACHE_FULL;
> +				if (cmd->handle.index.id ||
> +				    cmd->handle.position.id)
> +					flags |= NFT_CACHE_UPDATE;
>  				break;
>  			}
>  			flags = evaluate_cache_add(cmd, flags);

We can keep the special cases isolated to evaluate_cache_add() by always
calling it.

diff --git a/src/cache.c b/src/cache.c
index cffcbb623ced..f7ca8fe9068f 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -104,11 +104,10 @@ unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds)
                case CMD_ADD:
                case CMD_INSERT:
                case CMD_CREATE:
+                       flags = evaluate_cache_add(cmd, flags);
                        if (nft_output_echo(&nft->output)) {
-                               flags = NFT_CACHE_FULL;
-                               break;
+                               flags |= NFT_CACHE_FULL;
                        }
-                       flags = evaluate_cache_add(cmd, flags);
                        break;
                case CMD_REPLACE:
                        flags = NFT_CACHE_FULL;

  reply	other threads:[~2019-09-05 20:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05 17:09 [PATCH nft] cache: fix --echo with index/position Pablo Neira Ayuso
2019-09-05 20:44 ` Eric Garver [this message]
2019-09-05 23:27   ` Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190905204432.h2nv4zs5ysxlxhnq@egarver.localdomain \
    --to=eric@garver.life \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).