Skip to content

Commit 31d44a3

Browse files
committed
Florian Westphal says: ==================== netfilter: updates for net-next There is an issue with interval matching in nftables rbtree set type: When userspace sends us set updates, there is a brief window where false negative lookups may occur from the data plane. Quoting Pablos original cover letter: This series addresses this issue by translating the rbtree, which keeps the intervals in order, to binary search. The array is published to packet path through RCU. The idea is to keep using the rbtree datastructure for control plane, which needs to deal with updates, then generate an array using this rbtree for binary search lookups. Patch linuxppc#1 allows to call .remove in case .abort is defined, which is needed by this new approach. Only pipapo needs to skip .remove to speed. Patch linuxppc#2 add the binary search array approach for interval matching. Patch linuxppc#3 updates .get to use the binary search array to find for (closest or exact) interval matching. Patch linuxppc#4 removes seqcount_rwlock_t as it is not needed anymore (new in this series). * tag 'nf-next-26-01-22' of https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next: netfilter: nft_set_rbtree: remove seqcount_rwlock_t netfilter: nft_set_rbtree: use binary search array in get command netfilter: nft_set_rbtree: translate rbtree to array for binary search netfilter: nf_tables: add .abort_skip_removal flag for set types ==================== Link: https://patch.msgid.link/20260122162935.8581-1-fw@strlen.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents b00a7b3 + 5599fa8 commit 31d44a3

4 files changed

Lines changed: 291 additions & 145 deletions

File tree

include/net/netfilter/nf_tables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ struct nft_set_ext;
451451
* @init: initialize private data of new set instance
452452
* @destroy: destroy private data of set instance
453453
* @gc_init: initialize garbage collection
454+
* @abort_skip_removal: skip removal of elements from abort path
454455
* @elemsize: element private size
455456
*
456457
* Operations lookup, update and delete have simpler interfaces, are faster
@@ -508,6 +509,7 @@ struct nft_set_ops {
508509
const struct nft_set *set);
509510
void (*gc_init)(const struct nft_set *set);
510511

512+
bool abort_skip_removal;
511513
unsigned int elemsize;
512514
};
513515

net/netfilter/nf_tables_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7807,7 +7807,8 @@ static bool nft_trans_elems_new_abort(const struct nft_ctx *ctx,
78077807
continue;
78087808
}
78097809

7810-
if (!te->set->ops->abort || nft_setelem_is_catchall(te->set, te->elems[i].priv))
7810+
if (!te->set->ops->abort_skip_removal ||
7811+
nft_setelem_is_catchall(te->set, te->elems[i].priv))
78117812
nft_setelem_remove(ctx->net, te->set, te->elems[i].priv);
78127813

78137814
if (!nft_setelem_is_catchall(te->set, te->elems[i].priv))

net/netfilter/nft_set_pipapo.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,7 @@ const struct nft_set_type nft_set_pipapo_type = {
23702370
.gc_init = nft_pipapo_gc_init,
23712371
.commit = nft_pipapo_commit,
23722372
.abort = nft_pipapo_abort,
2373+
.abort_skip_removal = true,
23732374
.elemsize = offsetof(struct nft_pipapo_elem, ext),
23742375
},
23752376
};
@@ -2394,6 +2395,7 @@ const struct nft_set_type nft_set_pipapo_avx2_type = {
23942395
.gc_init = nft_pipapo_gc_init,
23952396
.commit = nft_pipapo_commit,
23962397
.abort = nft_pipapo_abort,
2398+
.abort_skip_removal = true,
23972399
.elemsize = offsetof(struct nft_pipapo_elem, ext),
23982400
},
23992401
};

0 commit comments

Comments
 (0)