From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 2/2] debug: include kernel set information on cache fill
Date: Wed, 20 Nov 2024 11:02:16 +0100 [thread overview]
Message-ID: <20241120100221.11001-2-fw@strlen.de> (raw)
In-Reply-To: <20241120100221.11001-1-fw@strlen.de>
Honor --debug=netlink flag also when doing initial set dump
from the kernel.
With recent libnftnl update this will include the chosen
set backend name that is used by the kernel.
Because set names are scoped by table and protocol family,
also include the family protocol number.
Dumping this information breaks tests/py as the recorded
debug output no longer matches, this is fixed in previous
change.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/mnl.c | 15 +++++++++++++--
src/netlink.c | 3 +++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/mnl.c b/src/mnl.c
index 828006c4d6bf..24a7487a5b5b 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -1386,9 +1386,15 @@ int mnl_nft_set_del(struct netlink_ctx *ctx, struct cmd *cmd)
return 0;
}
+struct set_cb_args {
+ struct netlink_ctx *ctx;
+ struct nftnl_set_list *list;
+};
+
static int set_cb(const struct nlmsghdr *nlh, void *data)
{
- struct nftnl_set_list *nls_list = data;
+ struct set_cb_args *args = data;
+ struct nftnl_set_list *nls_list = args->list;
struct nftnl_set *s;
if (check_genid(nlh) < 0)
@@ -1401,6 +1407,8 @@ static int set_cb(const struct nlmsghdr *nlh, void *data)
if (nftnl_set_nlmsg_parse(nlh, s) < 0)
goto err_free;
+ netlink_dump_set(s, args->ctx);
+
nftnl_set_list_add_tail(s, nls_list);
return MNL_CB_OK;
@@ -1419,6 +1427,7 @@ mnl_nft_set_dump(struct netlink_ctx *ctx, int family,
struct nlmsghdr *nlh;
struct nftnl_set *s;
int ret;
+ struct set_cb_args args;
s = nftnl_set_alloc();
if (s == NULL)
@@ -1440,7 +1449,9 @@ mnl_nft_set_dump(struct netlink_ctx *ctx, int family,
if (nls_list == NULL)
memory_allocation_error();
- ret = nft_mnl_talk(ctx, nlh, nlh->nlmsg_len, set_cb, nls_list);
+ args.list = nls_list;
+ args.ctx = ctx;
+ ret = nft_mnl_talk(ctx, nlh, nlh->nlmsg_len, set_cb, &args);
if (ret < 0 && errno != ENOENT)
goto err;
diff --git a/src/netlink.c b/src/netlink.c
index 36140fb63d6f..f3a5fa2e4309 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -832,10 +832,13 @@ static const struct datatype *dtype_map_from_kernel(enum nft_data_types type)
void netlink_dump_set(const struct nftnl_set *nls, struct netlink_ctx *ctx)
{
FILE *fp = ctx->nft->output.output_fp;
+ uint32_t family;
if (!(ctx->nft->debug_mask & NFT_DEBUG_NETLINK) || !fp)
return;
+ family = nftnl_set_get_u32(nls, NFTNL_SET_FAMILY);
+ fprintf(fp, "family %d ", family);
nftnl_set_fprintf(fp, nls, 0, 0);
fprintf(fp, "\n");
}
--
2.47.0
next prev parent reply other threads:[~2024-11-20 11:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 10:02 [PATCH nft 1/2] tests/py: prepare for set debug change Florian Westphal
2024-11-20 10:02 ` Florian Westphal [this message]
2024-11-20 23:29 ` [PATCH nft 2/2] debug: include kernel set information on cache fill Pablo Neira Ayuso
2024-11-20 23:38 ` Florian Westphal
2024-11-21 9:24 ` Florian Westphal
2024-11-21 10:00 ` Pablo Neira Ayuso
2024-11-21 12:02 ` Florian Westphal
2024-11-21 15:12 ` Pablo Neira Ayuso
2024-11-21 17:19 ` Florian Westphal
2024-11-22 13:35 ` Pablo Neira Ayuso
2024-11-22 13:43 ` Florian Westphal
2024-11-22 14:01 ` Pablo Neira Ayuso
2024-11-22 14:38 ` Florian Westphal
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=20241120100221.11001-2-fw@strlen.de \
--to=fw@strlen.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.