All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nft] evaluate: force full cache update on rule index translation
@ 2019-05-01 16:35 Eric Garver
  2019-05-05 22:18 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Garver @ 2019-05-01 16:35 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Phil Sutter

If we've done a partial fetch of the cache and the genid is the same the
cache update will be skipped without fetching the rules. This causes the
index to handle lookup to fail. To remedy the situation we flush the
cache and force a full update.

Fixes: 816d8c7659c1 ("Support 'add/insert rule index <IDX>'")
Signed-off-by: Eric Garver <eric@garver.life>
---
 src/evaluate.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/evaluate.c b/src/evaluate.c
index 3593eb80a6a6..a2585291e7c4 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -3182,7 +3182,11 @@ static int rule_translate_index(struct eval_ctx *ctx, struct rule *rule)
 	struct rule *r;
 	int ret;
 
-	/* update cache with CMD_LIST so that rules are fetched, too */
+	/* Update cache with CMD_LIST so that rules are fetched, too. The explicit
+	 * release is necessary because the genid may be the same, in which case
+	 * the update would be a no-op.
+	 */
+	cache_release(&ctx->nft->cache);
 	ret = cache_update(ctx->nft, CMD_LIST, ctx->msgs);
 	if (ret < 0)
 		return ret;
-- 
2.20.1


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

* Re: [PATCH nft] evaluate: force full cache update on rule index translation
  2019-05-01 16:35 [PATCH nft] evaluate: force full cache update on rule index translation Eric Garver
@ 2019-05-05 22:18 ` Pablo Neira Ayuso
  2019-05-06 13:47   ` Eric Garver
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2019-05-05 22:18 UTC (permalink / raw)
  To: Eric Garver; +Cc: netfilter-devel, Phil Sutter

On Wed, May 01, 2019 at 12:35:10PM -0400, Eric Garver wrote:
> If we've done a partial fetch of the cache and the genid is the same the
> cache update will be skipped without fetching the rules. This causes the
> index to handle lookup to fail. To remedy the situation we flush the
> cache and force a full update.

@Eric: Would you mind to post a reproducer? I'd like to make a test
for tests/shell/ infrastructure to make sure future changes don't
break this.

@Phil: Not related to this, but do you think it would be good to
rework rule index insertion to support for NFTA_RULE_POSITION_ID?

Thanks!

> Fixes: 816d8c7659c1 ("Support 'add/insert rule index <IDX>'")
> Signed-off-by: Eric Garver <eric@garver.life>
> ---
>  src/evaluate.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/evaluate.c b/src/evaluate.c
> index 3593eb80a6a6..a2585291e7c4 100644
> --- a/src/evaluate.c
> +++ b/src/evaluate.c
> @@ -3182,7 +3182,11 @@ static int rule_translate_index(struct eval_ctx *ctx, struct rule *rule)
>  	struct rule *r;
>  	int ret;
>  
> -	/* update cache with CMD_LIST so that rules are fetched, too */
> +	/* Update cache with CMD_LIST so that rules are fetched, too. The explicit
> +	 * release is necessary because the genid may be the same, in which case
> +	 * the update would be a no-op.
> +	 */
> +	cache_release(&ctx->nft->cache);
>  	ret = cache_update(ctx->nft, CMD_LIST, ctx->msgs);
>  	if (ret < 0)
>  		return ret;
> -- 
> 2.20.1
> 

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

* Re: [PATCH nft] evaluate: force full cache update on rule index translation
  2019-05-05 22:18 ` Pablo Neira Ayuso
@ 2019-05-06 13:47   ` Eric Garver
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Garver @ 2019-05-06 13:47 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Phil Sutter

On Mon, May 06, 2019 at 12:18:47AM +0200, Pablo Neira Ayuso wrote:
> On Wed, May 01, 2019 at 12:35:10PM -0400, Eric Garver wrote:
> > If we've done a partial fetch of the cache and the genid is the same the
> > cache update will be skipped without fetching the rules. This causes the
> > index to handle lookup to fail. To remedy the situation we flush the
> > cache and force a full update.
> 
> @Eric: Would you mind to post a reproducer? I'd like to make a test
> for tests/shell/ infrastructure to make sure future changes don't
> break this.

I'll post a v2 with test additions.

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

end of thread, other threads:[~2019-05-06 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 16:35 [PATCH nft] evaluate: force full cache update on rule index translation Eric Garver
2019-05-05 22:18 ` Pablo Neira Ayuso
2019-05-06 13:47   ` Eric Garver

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.