From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft,v2 1/5] src: add EXPR_F_KERNEL to identify expression in the kernel
Date: Sun, 20 Feb 2022 01:30:20 +0100 [thread overview]
Message-ID: <20220220003024.23317-1-pablo@netfilter.org> (raw)
This allows to identify the set elements that reside in the kernel.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
v2: no changes
include/expression.h | 2 ++
src/netlink.c | 1 +
src/segtree.c | 10 ++++++++--
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/expression.h b/include/expression.h
index 742fcdd7bf75..09393f9c2372 100644
--- a/include/expression.h
+++ b/include/expression.h
@@ -190,6 +190,7 @@ const struct expr_ops *expr_ops_by_type(enum expr_types etype);
* @EXPR_F_INTERVAL_END: set member ends an open interval
* @EXPR_F_BOOLEAN: expression is boolean (set by relational expr on LHS)
* @EXPR_F_INTERVAL: expression describes a interval
+ * @EXPR_F_KERNEL: expression resides in the kernel
*/
enum expr_flags {
EXPR_F_CONSTANT = 0x1,
@@ -198,6 +199,7 @@ enum expr_flags {
EXPR_F_INTERVAL_END = 0x8,
EXPR_F_BOOLEAN = 0x10,
EXPR_F_INTERVAL = 0x20,
+ EXPR_F_KERNEL = 0x40,
};
#include <payload.h>
diff --git a/src/netlink.c b/src/netlink.c
index ac73e96f9d24..642c28773b98 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -1273,6 +1273,7 @@ key_end:
}
expr = set_elem_expr_alloc(&netlink_location, key);
+ expr->flags |= EXPR_F_KERNEL;
if (nftnl_set_elem_is_set(nlse, NFTNL_SET_ELEM_TIMEOUT))
expr->timeout = nftnl_set_elem_get_u64(nlse, NFTNL_SET_ELEM_TIMEOUT);
diff --git a/src/segtree.c b/src/segtree.c
index a61ea3d2854a..832bc7dd1402 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -1060,9 +1060,10 @@ void interval_map_decompose(struct expr *set)
mpz_and(p, expr_value(low)->value, range);
- if (!mpz_cmp_ui(range, 0))
+ if (!mpz_cmp_ui(range, 0)) {
+ low->flags |= EXPR_F_KERNEL;
compound_expr_add(set, expr_get(low));
- else if ((!range_is_prefix(range) ||
+ } else if ((!range_is_prefix(range) ||
!(i->dtype->flags & DTYPE_F_PREFIX)) ||
mpz_cmp_ui(p, 0)) {
struct expr *tmp;
@@ -1087,6 +1088,7 @@ void interval_map_decompose(struct expr *set)
} else {
interval_expr_copy(tmp, low);
}
+ tmp->flags |= EXPR_F_KERNEL;
compound_expr_add(set, tmp);
} else {
@@ -1109,6 +1111,7 @@ void interval_map_decompose(struct expr *set)
} else {
interval_expr_copy(prefix, low);
}
+ prefix->flags |= EXPR_F_KERNEL;
compound_expr_add(set, prefix);
}
@@ -1134,6 +1137,7 @@ void interval_map_decompose(struct expr *set)
i = range_expr_alloc(&low->location,
expr_clone(expr_value(low)), i);
i = set_elem_expr_alloc(&low->location, i);
+
if (low->etype == EXPR_MAPPING) {
i = mapping_expr_alloc(&i->location, i,
expr_clone(low->right));
@@ -1141,6 +1145,8 @@ void interval_map_decompose(struct expr *set)
} else {
interval_expr_copy(i, low);
}
+ i->flags |= EXPR_F_KERNEL;
+
expr_free(low);
}
--
2.30.2
next reply other threads:[~2022-02-20 0:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-20 0:30 Pablo Neira Ayuso [this message]
2022-02-20 0:30 ` [PATCH nft,v2 2/5] src: replace interval segment tree overlap and automerge Pablo Neira Ayuso
2022-02-20 0:30 ` [PATCH nft,v2 3/5] src: remove rbtree datastructure Pablo Neira Ayuso
2022-02-20 0:30 ` [PATCH nft,v2 4/5] mnl: update mnl_nft_setelem_del() to allow for more reuse Pablo Neira Ayuso
2022-02-20 0:30 ` [PATCH nft,v2 5/5] intervals: add support to automerge with kernel elements Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220220003024.23317-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).