Netfilter-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH nft] cache: fix --echo with index/position
@ 2019-09-05 17:09 Pablo Neira Ayuso
  2019-09-05 20:44 ` Eric Garver
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2019-09-05 17:09 UTC (permalink / raw)
  To: netfilter-devel; +Cc: eric

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);
-- 
2.11.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH nft] cache: fix --echo with index/position
  2019-09-05 17:09 [PATCH nft] cache: fix --echo with index/position Pablo Neira Ayuso
@ 2019-09-05 20:44 ` Eric Garver
  2019-09-05 23:27   ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Garver @ 2019-09-05 20:44 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH nft] cache: fix --echo with index/position
  2019-09-05 20:44 ` Eric Garver
@ 2019-09-05 23:27   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2019-09-05 23:27 UTC (permalink / raw)
  To: Eric Garver, netfilter-devel

On Thu, Sep 05, 2019 at 04:44:32PM -0400, Eric Garver wrote:
> 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.

That's fine too, yes. Would you formally submit this patch? Thanks.

> 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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05 17:09 [PATCH nft] cache: fix --echo with index/position Pablo Neira Ayuso
2019-09-05 20:44 ` Eric Garver
2019-09-05 23:27   ` Pablo Neira Ayuso

Netfilter-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netfilter-devel/0 netfilter-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netfilter-devel netfilter-devel/ https://lore.kernel.org/netfilter-devel \
		netfilter-devel@vger.kernel.org netfilter-devel@archiver.kernel.org
	public-inbox-index netfilter-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netfilter-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox