2
0

007-revert-genetlink-changes.patch 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. --- a/net/wireless/nl80211.c
  2. +++ b/net/wireless/nl80211.c
  3. @@ -32,8 +32,22 @@ static int nl80211_crypto_settings(struc
  4. struct cfg80211_crypto_settings *settings,
  5. int cipher_limit);
  6. +static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb,
  7. + struct genl_info *info);
  8. +static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb,
  9. + struct genl_info *info);
  10. +
  11. /* the netlink family */
  12. -static struct genl_family nl80211_fam;
  13. +static struct genl_family nl80211_fam = {
  14. + .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
  15. + .name = NL80211_GENL_NAME, /* have users key off the name instead */
  16. + .hdrsize = 0, /* no private header */
  17. + .version = 1, /* no particular meaning now */
  18. + .maxattr = NL80211_ATTR_MAX,
  19. + .netnsok = true,
  20. + .pre_doit = nl80211_pre_doit,
  21. + .post_doit = nl80211_post_doit,
  22. +};
  23. /* multicast groups */
  24. enum nl80211_multicast_groups {
  25. @@ -549,14 +563,13 @@ static int nl80211_prepare_wdev_dump(str
  26. if (!cb->args[0]) {
  27. err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
  28. - genl_family_attrbuf(&nl80211_fam),
  29. - nl80211_fam.maxattr, nl80211_policy);
  30. + nl80211_fam.attrbuf, nl80211_fam.maxattr,
  31. + nl80211_policy);
  32. if (err)
  33. goto out_unlock;
  34. - *wdev = __cfg80211_wdev_from_attrs(
  35. - sock_net(skb->sk),
  36. - genl_family_attrbuf(&nl80211_fam));
  37. + *wdev = __cfg80211_wdev_from_attrs(sock_net(skb->sk),
  38. + nl80211_fam.attrbuf);
  39. if (IS_ERR(*wdev)) {
  40. err = PTR_ERR(*wdev);
  41. goto out_unlock;
  42. @@ -1903,7 +1916,7 @@ static int nl80211_dump_wiphy_parse(stru
  43. struct netlink_callback *cb,
  44. struct nl80211_dump_wiphy_state *state)
  45. {
  46. - struct nlattr **tb = genl_family_attrbuf(&nl80211_fam);
  47. + struct nlattr **tb = nl80211_fam.attrbuf;
  48. int ret = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
  49. tb, nl80211_fam.maxattr, nl80211_policy);
  50. /* ignore parse errors for backward compatibility */
  51. @@ -7733,7 +7746,6 @@ static int nl80211_send_survey(struct sk
  52. static int nl80211_dump_survey(struct sk_buff *skb, struct netlink_callback *cb)
  53. {
  54. - struct nlattr **attrbuf = genl_family_attrbuf(&nl80211_fam);
  55. struct survey_info survey;
  56. struct cfg80211_registered_device *rdev;
  57. struct wireless_dev *wdev;
  58. @@ -7746,7 +7758,7 @@ static int nl80211_dump_survey(struct sk
  59. return res;
  60. /* prepare_wdev_dump parsed the attributes */
  61. - radio_stats = attrbuf[NL80211_ATTR_SURVEY_RADIO_STATS];
  62. + radio_stats = nl80211_fam.attrbuf[NL80211_ATTR_SURVEY_RADIO_STATS];
  63. if (!wdev->netdev) {
  64. res = -EINVAL;
  65. @@ -8594,14 +8606,14 @@ static int nl80211_testmode_dump(struct
  66. */
  67. phy_idx = cb->args[0] - 1;
  68. } else {
  69. - struct nlattr **attrbuf = genl_family_attrbuf(&nl80211_fam);
  70. -
  71. err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
  72. - attrbuf, nl80211_fam.maxattr, nl80211_policy);
  73. + nl80211_fam.attrbuf, nl80211_fam.maxattr,
  74. + nl80211_policy);
  75. if (err)
  76. goto out_err;
  77. - rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk), attrbuf);
  78. + rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk),
  79. + nl80211_fam.attrbuf);
  80. if (IS_ERR(rdev)) {
  81. err = PTR_ERR(rdev);
  82. goto out_err;
  83. @@ -8609,8 +8621,9 @@ static int nl80211_testmode_dump(struct
  84. phy_idx = rdev->wiphy_idx;
  85. rdev = NULL;
  86. - if (attrbuf[NL80211_ATTR_TESTDATA])
  87. - cb->args[1] = (long)attrbuf[NL80211_ATTR_TESTDATA];
  88. + if (nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA])
  89. + cb->args[1] =
  90. + (long)nl80211_fam.attrbuf[NL80211_ATTR_TESTDATA];
  91. }
  92. if (cb->args[1]) {
  93. @@ -10814,7 +10827,8 @@ static int handle_nan_filter(struct nlat
  94. i = 0;
  95. nla_for_each_nested(attr, attr_filter, rem) {
  96. - filter[i].filter = nla_memdup(attr, GFP_KERNEL);
  97. + filter[i].filter = kmemdup(nla_data(attr), nla_len(attr),
  98. + GFP_KERNEL);
  99. filter[i].len = nla_len(attr);
  100. i++;
  101. }
  102. @@ -11450,7 +11464,6 @@ static int nl80211_prepare_vendor_dump(s
  103. struct cfg80211_registered_device **rdev,
  104. struct wireless_dev **wdev)
  105. {
  106. - struct nlattr **attrbuf = genl_family_attrbuf(&nl80211_fam);
  107. u32 vid, subcmd;
  108. unsigned int i;
  109. int vcmd_idx = -1;
  110. @@ -11486,28 +11499,31 @@ static int nl80211_prepare_vendor_dump(s
  111. }
  112. err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize,
  113. - attrbuf, nl80211_fam.maxattr, nl80211_policy);
  114. + nl80211_fam.attrbuf, nl80211_fam.maxattr,
  115. + nl80211_policy);
  116. if (err)
  117. goto out_unlock;
  118. - if (!attrbuf[NL80211_ATTR_VENDOR_ID] ||
  119. - !attrbuf[NL80211_ATTR_VENDOR_SUBCMD]) {
  120. + if (!nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_ID] ||
  121. + !nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_SUBCMD]) {
  122. err = -EINVAL;
  123. goto out_unlock;
  124. }
  125. - *wdev = __cfg80211_wdev_from_attrs(sock_net(skb->sk), attrbuf);
  126. + *wdev = __cfg80211_wdev_from_attrs(sock_net(skb->sk),
  127. + nl80211_fam.attrbuf);
  128. if (IS_ERR(*wdev))
  129. *wdev = NULL;
  130. - *rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk), attrbuf);
  131. + *rdev = __cfg80211_rdev_from_attrs(sock_net(skb->sk),
  132. + nl80211_fam.attrbuf);
  133. if (IS_ERR(*rdev)) {
  134. err = PTR_ERR(*rdev);
  135. goto out_unlock;
  136. }
  137. - vid = nla_get_u32(attrbuf[NL80211_ATTR_VENDOR_ID]);
  138. - subcmd = nla_get_u32(attrbuf[NL80211_ATTR_VENDOR_SUBCMD]);
  139. + vid = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_ID]);
  140. + subcmd = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_SUBCMD]);
  141. for (i = 0; i < (*rdev)->wiphy.n_vendor_commands; i++) {
  142. const struct wiphy_vendor_command *vcmd;
  143. @@ -11531,9 +11547,9 @@ static int nl80211_prepare_vendor_dump(s
  144. goto out_unlock;
  145. }
  146. - if (attrbuf[NL80211_ATTR_VENDOR_DATA]) {
  147. - data = nla_data(attrbuf[NL80211_ATTR_VENDOR_DATA]);
  148. - data_len = nla_len(attrbuf[NL80211_ATTR_VENDOR_DATA]);
  149. + if (nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_DATA]) {
  150. + data = nla_data(nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_DATA]);
  151. + data_len = nla_len(nl80211_fam.attrbuf[NL80211_ATTR_VENDOR_DATA]);
  152. }
  153. /* 0 is the first index - add 1 to parse only once */
  154. @@ -12795,21 +12811,6 @@ static __genl_const struct genl_ops nl80
  155. },
  156. };
  157. -static struct genl_family nl80211_fam __ro_after_init = {
  158. - .name = NL80211_GENL_NAME, /* have users key off the name instead */
  159. - .hdrsize = 0, /* no private header */
  160. - .version = 1, /* no particular meaning now */
  161. - .maxattr = NL80211_ATTR_MAX,
  162. - .netnsok = true,
  163. - .pre_doit = nl80211_pre_doit,
  164. - .post_doit = nl80211_post_doit,
  165. - .module = THIS_MODULE,
  166. - .ops = nl80211_ops,
  167. - .n_ops = ARRAY_SIZE(nl80211_ops),
  168. - .mcgrps = nl80211_mcgrps,
  169. - .n_mcgrps = ARRAY_SIZE(nl80211_mcgrps),
  170. -};
  171. -
  172. /* notification functions */
  173. void nl80211_notify_wiphy(struct cfg80211_registered_device *rdev,
  174. @@ -14759,11 +14760,12 @@ void nl80211_send_ap_stopped(struct wire
  175. /* initialisation/exit functions */
  176. -int __init nl80211_init(void)
  177. +int nl80211_init(void)
  178. {
  179. int err;
  180. - err = genl_register_family(&nl80211_fam);
  181. + err = genl_register_family_with_ops_groups(&nl80211_fam, nl80211_ops,
  182. + nl80211_mcgrps);
  183. if (err)
  184. return err;
  185. --- a/drivers/net/wireless/mac80211_hwsim.c
  186. +++ b/drivers/net/wireless/mac80211_hwsim.c
  187. @@ -587,8 +587,15 @@ struct hwsim_radiotap_ack_hdr {
  188. __le16 rt_chbitmask;
  189. } __packed;
  190. -/* MAC80211_HWSIM netlink family */
  191. -static struct genl_family hwsim_genl_family;
  192. +/* MAC80211_HWSIM netlinf family */
  193. +static struct genl_family hwsim_genl_family = {
  194. + .id = GENL_ID_GENERATE,
  195. + .hdrsize = 0,
  196. + .name = "MAC80211_HWSIM",
  197. + .version = 1,
  198. + .maxattr = HWSIM_ATTR_MAX,
  199. + .netnsok = true,
  200. +};
  201. enum hwsim_multicast_groups {
  202. HWSIM_MCGRP_CONFIG,
  203. @@ -3250,18 +3257,6 @@ static __genl_const struct genl_ops hwsi
  204. },
  205. };
  206. -static struct genl_family hwsim_genl_family __ro_after_init = {
  207. - .name = "MAC80211_HWSIM",
  208. - .version = 1,
  209. - .maxattr = HWSIM_ATTR_MAX,
  210. - .netnsok = true,
  211. - .module = THIS_MODULE,
  212. - .ops = hwsim_ops,
  213. - .n_ops = ARRAY_SIZE(hwsim_ops),
  214. - .mcgrps = hwsim_mcgrps,
  215. - .n_mcgrps = ARRAY_SIZE(hwsim_mcgrps),
  216. -};
  217. -
  218. static void destroy_radio(struct work_struct *work)
  219. {
  220. struct mac80211_hwsim_data *data =
  221. @@ -3309,13 +3304,15 @@ static struct notifier_block hwsim_netli
  222. .notifier_call = mac80211_hwsim_netlink_notify,
  223. };
  224. -static int __init hwsim_init_netlink(void)
  225. +static int hwsim_init_netlink(void)
  226. {
  227. int rc;
  228. printk(KERN_INFO "mac80211_hwsim: initializing netlink\n");
  229. - rc = genl_register_family(&hwsim_genl_family);
  230. + rc = genl_register_family_with_ops_groups(&hwsim_genl_family,
  231. + hwsim_ops,
  232. + hwsim_mcgrps);
  233. if (rc)
  234. goto failure;