[PATCH 12/20] headers: add genl_small_ops backport for kernels < 5.10

Yi Cong <[email protected]> Wed, 24 Jun 2026 15:38:36 +0800
Newsgroups org.kernel.vger.backports
Message-ID <[email protected]>
From: Yi Cong <[email protected]>

genl_small_ops was introduced in v5.10 as a more compact
representation of genl_ops. For older kernels, alias genl_small_ops
to genl_ops and map small_ops/n_small_ops struct fields to ops/n_ops.

Signed-off-by: Yi Cong <[email protected]>
---
 backport/backport-include/net/genetlink.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/backport/backport-include/net/genetlink.h b/backport/backport-include/net/genetlink.h
index b98d7110..a57cd200 100644
--- a/backport/backport-include/net/genetlink.h
+++ b/backport/backport-include/net/genetlink.h
@@ -7,6 +7,18 @@
 #define genl_split_ops genl_ops
 #endif
 
+#if LINUX_VERSION_IS_LESS(5,10,0)
+/*
+ * genl_small_ops was introduced in v5.10 to allow a more compact
+ * representation of genl_ops.  For older kernels, just alias it to
+ * genl_ops and map the struct genl_family small_ops/n_small_ops
+ * fields to ops/n_ops.
+ */
+#define genl_small_ops genl_ops
+#define small_ops ops
+#define n_small_ops n_ops
+#endif
+
 /* this is for patches we apply */
 static inline struct netlink_ext_ack *genl_callback_extack(struct netlink_callback *cb)
 {
-- 
2.43.0