Merge pull request #781 from ecsv/batadv-2022.0
[feed/routing.git] / batman-adv / patches / 0001-Revert-batman-adv-genetlink-move-to-smaller-ops-wher.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Sat, 24 Oct 2020 22:51:23 +0200
3 Subject: Revert "batman-adv: genetlink: move to smaller ops wherever possible"
4
5 The netlink genl_ops interface was splitted into two parts for Linux 5.10.
6 The batman-adv code changed to the new one because it doesn't use the more
7 complex policy handling of genl_ops. But the backports-5.8-1 version in
8 OpenWrt doesn't yet support the new genl_small_ops.
9
10 This patch must be dropped directly when OpenWrt switches to backports-5.10
11 or newer - otherwise it will not work as expected.
12
13 This reverts commit 725b4ef5be840cfcd0ca33b9393c14dee40c10f7.
14
15 --- a/compat-include/net/genetlink.h
16 +++ b/compat-include/net/genetlink.h
17 @@ -31,17 +31,15 @@ void batadv_genl_dump_check_consistent(s
18 #endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */
19
20
21 -#if LINUX_VERSION_IS_LESS(5, 10, 0)
22 -
23 #if LINUX_VERSION_IS_LESS(5, 2, 0)
24 +
25 enum genl_validate_flags {
26 GENL_DONT_VALIDATE_STRICT = BIT(0),
27 GENL_DONT_VALIDATE_DUMP = BIT(1),
28 GENL_DONT_VALIDATE_DUMP_STRICT = BIT(2),
29 };
30 -#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
31
32 -struct batadv_genl_small_ops {
33 +struct batadv_genl_ops {
34 int (*doit)(struct sk_buff *skb,
35 struct genl_info *info);
36 int (*dumpit)(struct sk_buff *skb,
37 @@ -70,9 +68,9 @@ struct batadv_genl_family {
38 struct genl_info *info);
39 void (*post_doit)(const struct genl_ops *ops, struct sk_buff *skb,
40 struct genl_info *info);
41 - const struct batadv_genl_small_ops *small_ops;
42 + const struct batadv_genl_ops *ops;
43 const struct genl_multicast_group *mcgrps;
44 - unsigned int n_small_ops;
45 + unsigned int n_ops;
46 unsigned int n_mcgrps;
47 struct module *module;
48
49 @@ -96,32 +94,24 @@ static inline int batadv_genl_register_f
50 family->family.pre_doit = family->pre_doit;
51 family->family.post_doit = family->post_doit;
52 family->family.mcgrps = family->mcgrps;
53 - family->family.n_ops = family->n_small_ops;
54 + family->family.n_ops = family->n_ops;
55 family->family.n_mcgrps = family->n_mcgrps;
56 family->family.module = family->module;
57
58 - ops = kzalloc(sizeof(*ops) * family->n_small_ops, GFP_KERNEL);
59 + ops = kzalloc(sizeof(*ops) * family->n_ops, GFP_KERNEL);
60 if (!ops)
61 return -ENOMEM;
62
63 for (i = 0; i < family->family.n_ops; i++) {
64 - ops[i].doit = family->small_ops[i].doit;
65 - ops[i].dumpit = family->small_ops[i].dumpit;
66 - ops[i].done = family->small_ops[i].done;
67 - ops[i].cmd = family->small_ops[i].cmd;
68 - ops[i].internal_flags = family->small_ops[i].internal_flags;
69 - ops[i].flags = family->small_ops[i].flags;
70 -#if LINUX_VERSION_IS_GEQ(5, 2, 0)
71 - ops[i].validate = family->small_ops[i].validate;
72 -#else
73 + ops[i].doit = family->ops[i].doit;
74 + ops[i].dumpit = family->ops[i].dumpit;
75 + ops[i].done = family->ops[i].done;
76 + ops[i].cmd = family->ops[i].cmd;
77 + ops[i].internal_flags = family->ops[i].internal_flags;
78 + ops[i].flags = family->ops[i].flags;
79 ops[i].policy = family->policy;
80 -#endif
81 }
82
83 -#if LINUX_VERSION_IS_GEQ(5, 2, 0)
84 - family->family.policy = family->policy;
85 -#endif
86 -
87 family->family.ops = ops;
88 family->copy_ops = ops;
89
90 @@ -136,7 +126,7 @@ typedef struct genl_ops batadv_genl_ops_
91 #define batadv_post_doit(__x, __y, __z) \
92 batadv_post_doit(const batadv_genl_ops_old *ops, __y, __z)
93
94 -#define genl_small_ops batadv_genl_small_ops
95 +#define genl_ops batadv_genl_ops
96 #define genl_family batadv_genl_family
97
98 #define genl_register_family(family) \
99 @@ -160,6 +150,6 @@ batadv_genl_unregister_family(struct bat
100 genlmsg_multicast_netns(&(_family)->family, _net, _skb, _portid, \
101 _group, _flags)
102
103 -#endif /* LINUX_VERSION_IS_LESS(5, 10, 0) */
104 +#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
105
106 #endif /* _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_ */
107 --- a/net/batman-adv/netlink.c
108 +++ b/net/batman-adv/netlink.c
109 @@ -1357,7 +1357,7 @@ static void batadv_post_doit(const struc
110 }
111 }
112
113 -static const struct genl_small_ops batadv_netlink_ops[] = {
114 +static const struct genl_ops batadv_netlink_ops[] = {
115 {
116 .cmd = BATADV_CMD_GET_MESH,
117 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
118 @@ -1491,8 +1491,8 @@ struct genl_family batadv_netlink_family
119 .pre_doit = batadv_pre_doit,
120 .post_doit = batadv_post_doit,
121 .module = THIS_MODULE,
122 - .small_ops = batadv_netlink_ops,
123 - .n_small_ops = ARRAY_SIZE(batadv_netlink_ops),
124 + .ops = batadv_netlink_ops,
125 + .n_ops = ARRAY_SIZE(batadv_netlink_ops),
126 .mcgrps = batadv_netlink_mcgrps,
127 .n_mcgrps = ARRAY_SIZE(batadv_netlink_mcgrps),
128 };