Repository : ssh://git@diktynna/batman-adv
On branch : master
>---------------------------------------------------------------
commit 725b4ef5be840cfcd0ca33b9393c14dee40c10f7
Author: Jakub Kicinski <kuba(a)kernel.org>
Date: Thu Oct 8 20:16:12 2020 +0200
batman-adv: genetlink: move to smaller ops wherever possible
Bulk of the genetlink users can use smaller ops, move them.
Signed-off-by: Jakub Kicinski <kuba(a)kernel.org>
Reviewed-by: Johannes Berg <johannes(a)sipsolutions.net>
Signed-off-by: David S. Miller <davem(a)davemloft.net>
[sven(a)narfation.org: Add compat code]
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
725b4ef5be840cfcd0ca33b9393c14dee40c10f7
compat-include/net/genetlink.h | 38 ++++++++++++++++++++++++--------------
net/batman-adv/netlink.c | 6 +++---
2 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h
index d1f80cd8..f16355fe 100644
--- a/compat-include/net/genetlink.h
+++ b/compat-include/net/genetlink.h
@@ -31,15 +31,17 @@ void batadv_genl_dump_check_consistent(struct netlink_callback *cb,
#endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */
-#if LINUX_VERSION_IS_LESS(5, 2, 0)
+#if LINUX_VERSION_IS_LESS(5, 10, 0)
+#if LINUX_VERSION_IS_LESS(5, 2, 0)
enum genl_validate_flags {
GENL_DONT_VALIDATE_STRICT = BIT(0),
GENL_DONT_VALIDATE_DUMP = BIT(1),
GENL_DONT_VALIDATE_DUMP_STRICT = BIT(2),
};
+#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
-struct batadv_genl_ops {
+struct batadv_genl_small_ops {
int (*doit)(struct sk_buff *skb,
struct genl_info *info);
int (*dumpit)(struct sk_buff *skb,
@@ -68,9 +70,9 @@ struct batadv_genl_family {
struct genl_info *info);
void (*post_doit)(const struct genl_ops *ops, struct sk_buff *skb,
struct genl_info *info);
- const struct batadv_genl_ops *ops;
+ const struct batadv_genl_small_ops *small_ops;
const struct genl_multicast_group *mcgrps;
- unsigned int n_ops;
+ unsigned int n_small_ops;
unsigned int n_mcgrps;
struct module *module;
@@ -94,24 +96,32 @@ static inline int batadv_genl_register_family(struct batadv_genl_family *family)
family->family.pre_doit = family->pre_doit;
family->family.post_doit = family->post_doit;
family->family.mcgrps = family->mcgrps;
- family->family.n_ops = family->n_ops;
+ family->family.n_ops = family->n_small_ops;
family->family.n_mcgrps = family->n_mcgrps;
family->family.module = family->module;
- ops = kzalloc(sizeof(*ops) * family->n_ops, GFP_KERNEL);
+ ops = kzalloc(sizeof(*ops) * family->n_small_ops, GFP_KERNEL);
if (!ops)
return -ENOMEM;
for (i = 0; i < family->family.n_ops; i++) {
- ops[i].doit = family->ops[i].doit;
- ops[i].dumpit = family->ops[i].dumpit;
- ops[i].done = family->ops[i].done;
- ops[i].cmd = family->ops[i].cmd;
- ops[i].internal_flags = family->ops[i].internal_flags;
- ops[i].flags = family->ops[i].flags;
+ ops[i].doit = family->small_ops[i].doit;
+ ops[i].dumpit = family->small_ops[i].dumpit;
+ ops[i].done = family->small_ops[i].done;
+ ops[i].cmd = family->small_ops[i].cmd;
+ ops[i].internal_flags = family->small_ops[i].internal_flags;
+ ops[i].flags = family->small_ops[i].flags;
+#if LINUX_VERSION_IS_GEQ(5, 2, 0)
+ ops[i].validate = family->small_ops[i].validate;
+#else
ops[i].policy = family->policy;
+#endif
}
+#if LINUX_VERSION_IS_GEQ(5, 2, 0)
+ family->family.policy = family->policy;
+#endif
+
family->family.ops = ops;
family->copy_ops = ops;
@@ -126,7 +136,7 @@ typedef struct genl_ops batadv_genl_ops_old;
#define batadv_post_doit(__x, __y, __z) \
batadv_post_doit(const batadv_genl_ops_old *ops, __y, __z)
-#define genl_ops batadv_genl_ops
+#define genl_small_ops batadv_genl_small_ops
#define genl_family batadv_genl_family
#define genl_register_family(family) \
@@ -150,6 +160,6 @@ batadv_genl_unregister_family(struct batadv_genl_family *family)
genlmsg_multicast_netns(&(_family)->family, _net, _skb, _portid, \
_group, _flags)
-#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
+#endif /* LINUX_VERSION_IS_LESS(5, 10, 0) */
#endif /* _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_ */
diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c
index dc193618..c7a55647 100644
--- a/net/batman-adv/netlink.c
+++ b/net/batman-adv/netlink.c
@@ -1350,7 +1350,7 @@ static void batadv_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
}
}
-static const struct genl_ops batadv_netlink_ops[] = {
+static const struct genl_small_ops batadv_netlink_ops[] = {
{
.cmd = BATADV_CMD_GET_MESH,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
@@ -1484,8 +1484,8 @@ struct genl_family batadv_netlink_family __ro_after_init = {
.pre_doit = batadv_pre_doit,
.post_doit = batadv_post_doit,
.module = THIS_MODULE,
- .ops = batadv_netlink_ops,
- .n_ops = ARRAY_SIZE(batadv_netlink_ops),
+ .small_ops = batadv_netlink_ops,
+ .n_small_ops = ARRAY_SIZE(batadv_netlink_ops),
.mcgrps = batadv_netlink_mcgrps,
.n_mcgrps = ARRAY_SIZE(batadv_netlink_mcgrps),
};