[PATCH v1 3/6] netlink_netfilter: decode set elements
Mathis Marion
Mathis.Marion at silabs.com
Thu Jun 12 09:56:03 UTC 2025
From: Mathis Marion <mathis.marion at silabs.com>
Signed-off-by: Mathis Marion <mathis.marion at silabs.com>
---
src/netlink_netfilter.c | 36 +++++++++++++++++++++++++++++++++-
src/xlat/nft_set_elem_attrs.in | 14 +++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
create mode 100644 src/xlat/nft_set_elem_attrs.in
diff --git a/src/netlink_netfilter.c b/src/netlink_netfilter.c
index 8e5d28f00..f2556c0a5 100644
--- a/src/netlink_netfilter.c
+++ b/src/netlink_netfilter.c
@@ -292,10 +292,44 @@ static const struct nfta_decoder nfta_set_decoder = {
.size = ARRAY_SIZE(nfta_set_decoders),
};
+static bool decode_set_elem(struct tcb *tcp, kernel_ulong_t addr,
+ unsigned int len, const void *opaque_data)
+{
+ static const nla_decoder_t decoders[] = {
+ [NFTA_SET_ELEM_KEY] = decode_data,
+ [NFTA_SET_ELEM_DATA] = NULL,
+ [NFTA_SET_ELEM_FLAGS] = decode_nla_be32,
+ [NFTA_SET_ELEM_TIMEOUT] = decode_nla_be64,
+ [NFTA_SET_ELEM_EXPIRATION] = decode_nla_be64,
+ [NFTA_SET_ELEM_USERDATA] = NULL,
+ [NFTA_SET_ELEM_EXPR] = decode_expr,
+ [NFTA_SET_ELEM_PAD] = NULL,
+ [NFTA_SET_ELEM_OBJREF] = decode_nla_str,
+ [NFTA_SET_ELEM_KEY_END] = decode_data,
+ [NFTA_SET_ELEM_EXPRESSIONS] = decode_exprs,
+ };
+
+ decode_nlattr(tcp, addr, len, nft_set_elem_attrs, "NFTA_SET_ELEM_???",
+ decoders, ARRAY_SIZE(decoders), opaque_data);
+ return true;
+}
+
+static bool decode_set_elems(struct tcb *tcp, kernel_ulong_t addr,
+ unsigned int len, const void *opaque_data)
+{
+ /*
+ * Some applications use an incrementing counter
+ * as nla_type instead of NFTA_LIST_ELEM.
+ */
+ decode_nlattr_notype(tcp, addr, len, NULL, NULL,
+ decode_set_elem, opaque_data);
+ return true;
+}
+
static const nla_decoder_t nfta_set_elem_list_decoders[] = {
[NFTA_SET_ELEM_LIST_TABLE] = decode_nla_str,
[NFTA_SET_ELEM_LIST_SET] = decode_nla_str,
- [NFTA_SET_ELEM_LIST_ELEMENTS] = NULL,
+ [NFTA_SET_ELEM_LIST_ELEMENTS] = decode_set_elems,
[NFTA_SET_ELEM_LIST_SET_ID] = decode_nla_be32,
};
diff --git a/src/xlat/nft_set_elem_attrs.in b/src/xlat/nft_set_elem_attrs.in
new file mode 100644
index 000000000..dce5a5488
--- /dev/null
+++ b/src/xlat/nft_set_elem_attrs.in
@@ -0,0 +1,14 @@
+#unconditional
+#value_indexed
+NFTA_SET_ELEM_UNSPEC
+NFTA_SET_ELEM_KEY
+NFTA_SET_ELEM_DATA
+NFTA_SET_ELEM_FLAGS
+NFTA_SET_ELEM_TIMEOUT
+NFTA_SET_ELEM_EXPIRATION
+NFTA_SET_ELEM_USERDATA
+NFTA_SET_ELEM_EXPR
+NFTA_SET_ELEM_PAD
+NFTA_SET_ELEM_OBJREF
+NFTA_SET_ELEM_KEY_END
+NFTA_SET_ELEM_EXPRESSIONS
--
2.47.2
More information about the Strace-devel
mailing list