* [PATCH net-next 04/14] netlink: add macro for checking dump ctx size
[not found] <20230104041636.226398-1-kuba@kernel.org>
@ 2023-01-04 4:16 ` Jakub Kicinski
2023-01-04 9:51 ` Jiri Pirko
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2023-01-04 4:16 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, jacob.e.keller, jiri, Jakub Kicinski,
pablo, kadlec, fw, johannes, ecree.xilinx, netfilter-devel,
coreteam
We encourage casting struct netlink_callback::ctx to a local
struct (in a comment above the field). Provide a convenience
macro for checking if the local struct fits into the ctx.
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: pablo@netfilter.org
CC: kadlec@netfilter.org
CC: fw@strlen.de
CC: johannes@sipsolutions.net
CC: ecree.xilinx@gmail.com
CC: netfilter-devel@vger.kernel.org
CC: coreteam@netfilter.org
---
include/linux/netlink.h | 4 ++++
net/netfilter/nf_conntrack_netlink.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index d81bde5a5844..38f6334f408c 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -263,6 +263,10 @@ struct netlink_callback {
};
};
+#define NL_ASSET_DUMP_CTX_FITS(type_name) \
+ BUILD_BUG_ON(sizeof(type_name) > \
+ sizeof_field(struct netlink_callback, ctx))
+
struct netlink_notify {
struct net *net;
u32 portid;
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 1286ae7d4609..90672e293e57 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -3866,7 +3866,7 @@ static int __init ctnetlink_init(void)
{
int ret;
- BUILD_BUG_ON(sizeof(struct ctnetlink_list_dump_ctx) > sizeof_field(struct netlink_callback, ctx));
+ NL_ASSET_DUMP_CTX_FITS(struct ctnetlink_list_dump_ctx);
ret = nfnetlink_subsys_register(&ctnl_subsys);
if (ret < 0) {
--
2.38.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next 04/14] netlink: add macro for checking dump ctx size
2023-01-04 4:16 ` [PATCH net-next 04/14] netlink: add macro for checking dump ctx size Jakub Kicinski
@ 2023-01-04 9:51 ` Jiri Pirko
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Pirko @ 2023-01-04 9:51 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, jacob.e.keller, pablo, kadlec,
fw, johannes, ecree.xilinx, netfilter-devel, coreteam
Wed, Jan 04, 2023 at 05:16:26AM CET, kuba@kernel.org wrote:
>We encourage casting struct netlink_callback::ctx to a local
>struct (in a comment above the field). Provide a convenience
>macro for checking if the local struct fits into the ctx.
>
>Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
>Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-04 9:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230104041636.226398-1-kuba@kernel.org>
2023-01-04 4:16 ` [PATCH net-next 04/14] netlink: add macro for checking dump ctx size Jakub Kicinski
2023-01-04 9:51 ` Jiri Pirko
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).