Skip to content

Commit 6f7c9ca

Browse files
sbrivio-rhummakynes
authored andcommitted
netfilter: nft_set_rbtree: Introduce and use nft_rbtree_interval_start()
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 <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 0eb4b5e commit 6f7c9ca

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

net/netfilter/nft_set_rbtree.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ static bool nft_rbtree_interval_end(const struct nft_rbtree_elem *rbe)
3333
(*nft_set_ext_flags(&rbe->ext) & NFT_SET_ELEM_INTERVAL_END);
3434
}
3535

36+
static bool nft_rbtree_interval_start(const struct nft_rbtree_elem *rbe)
37+
{
38+
return !nft_rbtree_interval_end(rbe);
39+
}
40+
3641
static bool nft_rbtree_equal(const struct nft_set *set, const void *this,
3742
const struct nft_rbtree_elem *interval)
3843
{
@@ -64,7 +69,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set
6469
if (interval &&
6570
nft_rbtree_equal(set, this, interval) &&
6671
nft_rbtree_interval_end(rbe) &&
67-
!nft_rbtree_interval_end(interval))
72+
nft_rbtree_interval_start(interval))
6873
continue;
6974
interval = rbe;
7075
} else if (d > 0)
@@ -89,7 +94,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set
8994

9095
if (set->flags & NFT_SET_INTERVAL && interval != NULL &&
9196
nft_set_elem_active(&interval->ext, genmask) &&
92-
!nft_rbtree_interval_end(interval)) {
97+
nft_rbtree_interval_start(interval)) {
9398
*ext = &interval->ext;
9499
return true;
95100
}
@@ -224,9 +229,9 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
224229
p = &parent->rb_right;
225230
else {
226231
if (nft_rbtree_interval_end(rbe) &&
227-
!nft_rbtree_interval_end(new)) {
232+
nft_rbtree_interval_start(new)) {
228233
p = &parent->rb_left;
229-
} else if (!nft_rbtree_interval_end(rbe) &&
234+
} else if (nft_rbtree_interval_start(rbe) &&
230235
nft_rbtree_interval_end(new)) {
231236
p = &parent->rb_right;
232237
} else if (nft_set_elem_active(&rbe->ext, genmask)) {
@@ -317,10 +322,10 @@ static void *nft_rbtree_deactivate(const struct net *net,
317322
parent = parent->rb_right;
318323
else {
319324
if (nft_rbtree_interval_end(rbe) &&
320-
!nft_rbtree_interval_end(this)) {
325+
nft_rbtree_interval_start(this)) {
321326
parent = parent->rb_left;
322327
continue;
323-
} else if (!nft_rbtree_interval_end(rbe) &&
328+
} else if (nft_rbtree_interval_start(rbe) &&
324329
nft_rbtree_interval_end(this)) {
325330
parent = parent->rb_right;
326331
continue;

0 commit comments

Comments
 (0)