97 lines
3.8 KiB
Diff
97 lines
3.8 KiB
Diff
|
From 1412792a443ddc696fd1c8981a6cc544272f54bf Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Moritz=20WanzenBug=20Wanzenb=C3=B6ck?=
|
||
|
<moritz.wanzenboeck@linbit.com>
|
||
|
Date: Wed, 13 Sep 2023 15:46:12 +0200
|
||
|
Subject: [PATCH] compat: genetlink: remove userhdr from struct genl_info
|
||
|
|
||
|
See also upstream Linux kernel commit
|
||
|
bffcc6882a1b ("genetlink: remove userhdr from struct genl_info")
|
||
|
|
||
|
Original message:
|
||
|
|
||
|
Only three families use info->userhdr today and going forward
|
||
|
we discourage using fixed headers in new families.
|
||
|
So having the pointer to user header in struct genl_info
|
||
|
is an overkill. Compute the header pointer at runtime.
|
||
|
---
|
||
|
.../cocci/genl_info_userhdr__no_present.cocci | 5 +++++
|
||
|
drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++
|
||
|
drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c | 7 +++++++
|
||
|
drbd/drbd_nl.c | 6 +++---
|
||
|
4 files changed, 18 insertions(+), 3 deletions(-)
|
||
|
create mode 100644 drbd/drbd-kernel-compat/cocci/genl_info_userhdr__no_present.cocci
|
||
|
create mode 100644 drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c
|
||
|
|
||
|
diff --git a/drbd/drbd-kernel-compat/cocci/genl_info_userhdr__no_present.cocci b/drbd/drbd-kernel-compat/cocci/genl_info_userhdr__no_present.cocci
|
||
|
new file mode 100644
|
||
|
index 000000000000..75e787797068
|
||
|
--- /dev/null
|
||
|
+++ b/drbd/drbd-kernel-compat/cocci/genl_info_userhdr__no_present.cocci
|
||
|
@@ -0,0 +1,5 @@
|
||
|
+@@
|
||
|
+expression info;
|
||
|
+@@
|
||
|
+- genl_info_userhdr(info)
|
||
|
++ info->userhdr
|
||
|
diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c
|
||
|
index e4a65a3c451e..b136acf3148a 100644
|
||
|
--- a/drbd/drbd-kernel-compat/gen_patch_names.c
|
||
|
+++ b/drbd/drbd-kernel-compat/gen_patch_names.c
|
||
|
@@ -574,6 +574,9 @@ int main(int argc, char **argv)
|
||
|
patch(1, "blk_mode_t", true, false,
|
||
|
COMPAT_HAVE_BLK_MODE_T, "present");
|
||
|
|
||
|
+ patch(1, "genl_info_userhdr", true, false,
|
||
|
+ COMPAT_HAVE_GENL_INFO_USERHDR, "present");
|
||
|
+
|
||
|
/* #define BLKDEV_ISSUE_ZEROOUT_EXPORTED */
|
||
|
/* #define BLKDEV_ZERO_NOUNMAP */
|
||
|
|
||
|
diff --git a/drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c b/drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c
|
||
|
new file mode 100644
|
||
|
index 000000000000..3c69dacce244
|
||
|
--- /dev/null
|
||
|
+++ b/drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c
|
||
|
@@ -0,0 +1,7 @@
|
||
|
+/* { "version": "v6.6-rc1", "commit": "bffcc6882a1bb2be8c9420184966f4c2c822078e", "comment": "genetlink: remove userhdr from struct genl_info", "author": "Jakub Kicinski <kuba@kernel.org>", "date": "Mon Aug 14 14:47:16 2023 -0700" } */
|
||
|
+#include <net/genetlink.h>
|
||
|
+
|
||
|
+void *foo(struct genl_info *info)
|
||
|
+{
|
||
|
+ return genl_info_userhdr(info);
|
||
|
+}
|
||
|
diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c
|
||
|
index 71ed4272614e..538c31202e4b 100644
|
||
|
--- a/drbd/drbd_nl.c
|
||
|
+++ b/drbd/drbd_nl.c
|
||
|
@@ -203,7 +203,7 @@ static struct drbd_path *first_path(struct drbd_connection *connection)
|
||
|
static int drbd_adm_prepare(struct drbd_config_context *adm_ctx,
|
||
|
struct sk_buff *skb, struct genl_info *info, unsigned flags)
|
||
|
{
|
||
|
- struct drbd_genlmsghdr *d_in = info->userhdr;
|
||
|
+ struct drbd_genlmsghdr *d_in = genl_info_userhdr(info);
|
||
|
const u8 cmd = info->genlhdr->cmd;
|
||
|
int err;
|
||
|
|
||
|
@@ -2106,7 +2106,7 @@ static void drbd_try_suspend_al(struct drbd_device *device)
|
||
|
|
||
|
static bool should_set_defaults(struct genl_info *info)
|
||
|
{
|
||
|
- unsigned flags = ((struct drbd_genlmsghdr*)info->userhdr)->flags;
|
||
|
+ unsigned int flags = ((struct drbd_genlmsghdr *)genl_info_userhdr(info))->flags;
|
||
|
return 0 != (flags & DRBD_GENL_F_SET_DEFAULTS);
|
||
|
}
|
||
|
|
||
|
@@ -6279,7 +6279,7 @@ out_no_unlock:
|
||
|
int drbd_adm_new_minor(struct sk_buff *skb, struct genl_info *info)
|
||
|
{
|
||
|
struct drbd_config_context adm_ctx;
|
||
|
- struct drbd_genlmsghdr *dh = info->userhdr;
|
||
|
+ struct drbd_genlmsghdr *dh = genl_info_userhdr(info);
|
||
|
struct device_conf device_conf;
|
||
|
struct drbd_resource *resource;
|
||
|
struct drbd_device *device;
|
||
|
--
|
||
|
2.42.1
|
||
|
|