[PATCH 07/12] backport: Add genl_callback_extack() function

Hauke Mehrtens <[email protected]>
Newsgroups org.kernel.vger.backports
Message-ID <[email protected]>
The struct netlink_callback got a new extack attribute in commit
4a19edb60d02 ("netlink: Pass extack to dump handlers") in kernel 4.20.
Use a function instead of directly accessing it to return NULL on older
kernel versions, the code should handle NULL.

Signed-off-by: Hauke Mehrtens <[email protected]>
---
 backport/backport-include/net/genetlink.h | 10 ++++++++++
 patches/0078-genl-extack.cocci            |  6 ++++++
 2 files changed, 16 insertions(+)

diff --git a/backport/backport-include/net/genetlink.h b/backport/backport-include/net/genetlink.h
index 772f10f0..747b6dac 100644
--- a/backport/backport-include/net/genetlink.h
+++ b/backport/backport-include/net/genetlink.h
@@ -34,6 +34,16 @@ static inline struct netlink_ext_ack *genl_info_extack(struct genl_info *info)
 #endif
 }
 
+/* this is for patches we apply */
+static inline struct netlink_ext_ack *genl_callback_extack(struct netlink_callback *cb)
+{
+#if LINUX_VERSION_IS_GEQ(4,20,0)
+	return cb->extack;
+#else
+	return NULL;
+#endif
+}
+
 /* this gets put in place of info->userhdr, since we use that above */
 static inline void *genl_info_userhdr(struct genl_info *info)
 {
diff --git a/patches/0078-genl-extack.cocci b/patches/0078-genl-extack.cocci
index 5560e09d..860d68b4 100644
--- a/patches/0078-genl-extack.cocci
+++ b/patches/0078-genl-extack.cocci
@@ -9,3 +9,9 @@ struct genl_info *info;
 @@
 -info->userhdr
 +genl_info_userhdr(info)
+
+@@
+struct netlink_callback *cb;
+@@
+-cb->extack
++genl_callback_extack(cb)
-- 
2.20.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.