babeld: add ubus bindings
[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 diff --git a/compat-include/net/genetlink.h b/compat-include/net/genetlink.h
16 index f16355febac42294491531a3f8049bc680560d0c..d1f80cd88503cdd11e9051f2e90ea533bee89a67 100644
17 --- a/compat-include/net/genetlink.h
18 +++ b/compat-include/net/genetlink.h
19 @@ -31,17 +31,15 @@ void batadv_genl_dump_check_consistent(struct netlink_callback *cb,
20 #endif /* LINUX_VERSION_IS_LESS(4, 15, 0) */
21
22
23 -#if LINUX_VERSION_IS_LESS(5, 10, 0)
24 -
25 #if LINUX_VERSION_IS_LESS(5, 2, 0)
26 +
27 enum genl_validate_flags {
28 GENL_DONT_VALIDATE_STRICT = BIT(0),
29 GENL_DONT_VALIDATE_DUMP = BIT(1),
30 GENL_DONT_VALIDATE_DUMP_STRICT = BIT(2),
31 };
32 -#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
33
34 -struct batadv_genl_small_ops {
35 +struct batadv_genl_ops {
36 int (*doit)(struct sk_buff *skb,
37 struct genl_info *info);
38 int (*dumpit)(struct sk_buff *skb,
39 @@ -70,9 +68,9 @@ struct batadv_genl_family {
40 struct genl_info *info);
41 void (*post_doit)(const struct genl_ops *ops, struct sk_buff *skb,
42 struct genl_info *info);
43 - const struct batadv_genl_small_ops *small_ops;
44 + const struct batadv_genl_ops *ops;
45 const struct genl_multicast_group *mcgrps;
46 - unsigned int n_small_ops;
47 + unsigned int n_ops;
48 unsigned int n_mcgrps;
49 struct module *module;
50
51 @@ -96,32 +94,24 @@ static inline int batadv_genl_register_family(struct batadv_genl_family *family)
52 family->family.pre_doit = family->pre_doit;
53 family->family.post_doit = family->post_doit;
54 family->family.mcgrps = family->mcgrps;
55 - family->family.n_ops = family->n_small_ops;
56 + family->family.n_ops = family->n_ops;
57 family->family.n_mcgrps = family->n_mcgrps;
58 family->family.module = family->module;
59
60 - ops = kzalloc(sizeof(*ops) * family->n_small_ops, GFP_KERNEL);
61 + ops = kzalloc(sizeof(*ops) * family->n_ops, GFP_KERNEL);
62 if (!ops)
63 return -ENOMEM;
64
65 for (i = 0; i < family->family.n_ops; i++) {
66 - ops[i].doit = family->small_ops[i].doit;
67 - ops[i].dumpit = family->small_ops[i].dumpit;
68 - ops[i].done = family->small_ops[i].done;
69 - ops[i].cmd = family->small_ops[i].cmd;
70 - ops[i].internal_flags = family->small_ops[i].internal_flags;
71 - ops[i].flags = family->small_ops[i].flags;
72 -#if LINUX_VERSION_IS_GEQ(5, 2, 0)
73 - ops[i].validate = family->small_ops[i].validate;
74 -#else
75 + ops[i].doit = family->ops[i].doit;
76 + ops[i].dumpit = family->ops[i].dumpit;
77 + ops[i].done = family->ops[i].done;
78 + ops[i].cmd = family->ops[i].cmd;
79 + ops[i].internal_flags = family->ops[i].internal_flags;
80 + ops[i].flags = family->ops[i].flags;
81 ops[i].policy = family->policy;
82 -#endif
83 }
84
85 -#if LINUX_VERSION_IS_GEQ(5, 2, 0)
86 - family->family.policy = family->policy;
87 -#endif
88 -
89 family->family.ops = ops;
90 family->copy_ops = ops;
91
92 @@ -136,7 +126,7 @@ typedef struct genl_ops batadv_genl_ops_old;
93 #define batadv_post_doit(__x, __y, __z) \
94 batadv_post_doit(const batadv_genl_ops_old *ops, __y, __z)
95
96 -#define genl_small_ops batadv_genl_small_ops
97 +#define genl_ops batadv_genl_ops
98 #define genl_family batadv_genl_family
99
100 #define genl_register_family(family) \
101 @@ -160,6 +150,6 @@ batadv_genl_unregister_family(struct batadv_genl_family *family)
102 genlmsg_multicast_netns(&(_family)->family, _net, _skb, _portid, \
103 _group, _flags)
104
105 -#endif /* LINUX_VERSION_IS_LESS(5, 10, 0) */
106 +#endif /* LINUX_VERSION_IS_LESS(5, 2, 0) */
107
108 #endif /* _NET_BATMAN_ADV_COMPAT_NET_GENETLINK_H_ */
109 diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c
110 index c7a55647b520e87d560bdcb29a644eef30f2855c..dc193618a761c0b451e860ca83921007d286e09b 100644
111 --- a/net/batman-adv/netlink.c
112 +++ b/net/batman-adv/netlink.c
113 @@ -1350,7 +1350,7 @@ static void batadv_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
114 }
115 }
116
117 -static const struct genl_small_ops batadv_netlink_ops[] = {
118 +static const struct genl_ops batadv_netlink_ops[] = {
119 {
120 .cmd = BATADV_CMD_GET_MESH,
121 .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
122 @@ -1484,8 +1484,8 @@ struct genl_family batadv_netlink_family __ro_after_init = {
123 .pre_doit = batadv_pre_doit,
124 .post_doit = batadv_post_doit,
125 .module = THIS_MODULE,
126 - .small_ops = batadv_netlink_ops,
127 - .n_small_ops = ARRAY_SIZE(batadv_netlink_ops),
128 + .ops = batadv_netlink_ops,
129 + .n_ops = ARRAY_SIZE(batadv_netlink_ops),
130 .mcgrps = batadv_netlink_mcgrps,
131 .n_mcgrps = ARRAY_SIZE(batadv_netlink_mcgrps),
132 };