netfilter: nft_set_rbtree: Introduce and use nft_rbtree_interval_start()
[ Upstream commit 6f7c9caf01
]
Replace negations of nft_rbtree_interval_end() with a new helper,
nft_rbtree_interval_start(), wherever this helps to visualise the
problem at hand, that is, for all the occurrences except for the
comparison against given flags in __nft_rbtree_get().
This gets especially useful in the next patch.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
6259b1c1bc
commit
1c235d0eb1
|
@ -33,6 +33,11 @@ static bool nft_rbtree_interval_end(const struct nft_rbtree_elem *rbe)
|
|||
(*nft_set_ext_flags(&rbe->ext) & NFT_SET_ELEM_INTERVAL_END);
|
||||
}
|
||||
|
||||
static bool nft_rbtree_interval_start(const struct nft_rbtree_elem *rbe)
|
||||
{
|
||||
return !nft_rbtree_interval_end(rbe);
|
||||
}
|
||||
|
||||
static bool nft_rbtree_equal(const struct nft_set *set, const void *this,
|
||||
const struct nft_rbtree_elem *interval)
|
||||
{
|
||||
|
@ -64,7 +69,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set
|
|||
if (interval &&
|
||||
nft_rbtree_equal(set, this, interval) &&
|
||||
nft_rbtree_interval_end(rbe) &&
|
||||
!nft_rbtree_interval_end(interval))
|
||||
nft_rbtree_interval_start(interval))
|
||||
continue;
|
||||
interval = rbe;
|
||||
} else if (d > 0)
|
||||
|
@ -89,7 +94,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set
|
|||
|
||||
if (set->flags & NFT_SET_INTERVAL && interval != NULL &&
|
||||
nft_set_elem_active(&interval->ext, genmask) &&
|
||||
!nft_rbtree_interval_end(interval)) {
|
||||
nft_rbtree_interval_start(interval)) {
|
||||
*ext = &interval->ext;
|
||||
return true;
|
||||
}
|
||||
|
@ -224,9 +229,9 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
|
|||
p = &parent->rb_right;
|
||||
else {
|
||||
if (nft_rbtree_interval_end(rbe) &&
|
||||
!nft_rbtree_interval_end(new)) {
|
||||
nft_rbtree_interval_start(new)) {
|
||||
p = &parent->rb_left;
|
||||
} else if (!nft_rbtree_interval_end(rbe) &&
|
||||
} else if (nft_rbtree_interval_start(rbe) &&
|
||||
nft_rbtree_interval_end(new)) {
|
||||
p = &parent->rb_right;
|
||||
} else if (nft_set_elem_active(&rbe->ext, genmask)) {
|
||||
|
@ -317,10 +322,10 @@ static void *nft_rbtree_deactivate(const struct net *net,
|
|||
parent = parent->rb_right;
|
||||
else {
|
||||
if (nft_rbtree_interval_end(rbe) &&
|
||||
!nft_rbtree_interval_end(this)) {
|
||||
nft_rbtree_interval_start(this)) {
|
||||
parent = parent->rb_left;
|
||||
continue;
|
||||
} else if (!nft_rbtree_interval_end(rbe) &&
|
||||
} else if (nft_rbtree_interval_start(rbe) &&
|
||||
nft_rbtree_interval_end(this)) {
|
||||
parent = parent->rb_right;
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue