.. | .. |
---|
181 | 181 | struct tipc_nl_compat_msg *msg, |
---|
182 | 182 | struct sk_buff *arg) |
---|
183 | 183 | { |
---|
| 184 | + struct genl_dumpit_info info; |
---|
184 | 185 | int len = 0; |
---|
185 | 186 | int err; |
---|
186 | 187 | struct sk_buff *buf; |
---|
187 | 188 | struct nlmsghdr *nlmsg; |
---|
188 | 189 | struct netlink_callback cb; |
---|
| 190 | + struct nlattr **attrbuf; |
---|
189 | 191 | |
---|
190 | 192 | memset(&cb, 0, sizeof(cb)); |
---|
191 | 193 | cb.nlh = (struct nlmsghdr *)arg->data; |
---|
192 | 194 | cb.skb = arg; |
---|
| 195 | + cb.data = &info; |
---|
193 | 196 | |
---|
194 | 197 | buf = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); |
---|
195 | 198 | if (!buf) |
---|
.. | .. |
---|
201 | 204 | return -ENOMEM; |
---|
202 | 205 | } |
---|
203 | 206 | |
---|
| 207 | + attrbuf = kcalloc(tipc_genl_family.maxattr + 1, |
---|
| 208 | + sizeof(struct nlattr *), GFP_KERNEL); |
---|
| 209 | + if (!attrbuf) { |
---|
| 210 | + err = -ENOMEM; |
---|
| 211 | + goto err_out; |
---|
| 212 | + } |
---|
| 213 | + |
---|
| 214 | + info.attrs = attrbuf; |
---|
| 215 | + err = nlmsg_parse_deprecated(cb.nlh, GENL_HDRLEN, attrbuf, |
---|
| 216 | + tipc_genl_family.maxattr, |
---|
| 217 | + tipc_genl_family.policy, NULL); |
---|
| 218 | + if (err) |
---|
| 219 | + goto err_out; |
---|
| 220 | + |
---|
204 | 221 | do { |
---|
205 | 222 | int rem; |
---|
206 | 223 | |
---|
207 | 224 | len = (*cmd->dumpit)(buf, &cb); |
---|
208 | 225 | |
---|
209 | 226 | nlmsg_for_each_msg(nlmsg, nlmsg_hdr(buf), len, rem) { |
---|
210 | | - struct nlattr **attrs; |
---|
211 | | - |
---|
212 | | - err = tipc_nlmsg_parse(nlmsg, &attrs); |
---|
| 227 | + err = nlmsg_parse_deprecated(nlmsg, GENL_HDRLEN, |
---|
| 228 | + attrbuf, |
---|
| 229 | + tipc_genl_family.maxattr, |
---|
| 230 | + tipc_genl_family.policy, |
---|
| 231 | + NULL); |
---|
213 | 232 | if (err) |
---|
214 | 233 | goto err_out; |
---|
215 | 234 | |
---|
216 | | - err = (*cmd->format)(msg, attrs); |
---|
| 235 | + err = (*cmd->format)(msg, attrbuf); |
---|
217 | 236 | if (err) |
---|
218 | 237 | goto err_out; |
---|
219 | 238 | |
---|
.. | .. |
---|
231 | 250 | err = 0; |
---|
232 | 251 | |
---|
233 | 252 | err_out: |
---|
| 253 | + kfree(attrbuf); |
---|
234 | 254 | tipc_dump_done(&cb); |
---|
235 | 255 | kfree_skb(buf); |
---|
236 | 256 | |
---|
.. | .. |
---|
340 | 360 | if (err) |
---|
341 | 361 | goto doit_out; |
---|
342 | 362 | |
---|
343 | | - err = nla_parse(attrbuf, tipc_genl_family.maxattr, |
---|
344 | | - (const struct nlattr *)trans_buf->data, |
---|
345 | | - trans_buf->len, NULL, NULL); |
---|
| 363 | + err = nla_parse_deprecated(attrbuf, tipc_genl_family.maxattr, |
---|
| 364 | + (const struct nlattr *)trans_buf->data, |
---|
| 365 | + trans_buf->len, NULL, NULL); |
---|
346 | 366 | if (err) |
---|
347 | 367 | goto doit_out; |
---|
348 | 368 | |
---|
.. | .. |
---|
391 | 411 | if (!attrs[TIPC_NLA_BEARER]) |
---|
392 | 412 | return -EINVAL; |
---|
393 | 413 | |
---|
394 | | - err = nla_parse_nested(bearer, TIPC_NLA_BEARER_MAX, |
---|
395 | | - attrs[TIPC_NLA_BEARER], NULL, NULL); |
---|
| 414 | + err = nla_parse_nested_deprecated(bearer, TIPC_NLA_BEARER_MAX, |
---|
| 415 | + attrs[TIPC_NLA_BEARER], NULL, NULL); |
---|
396 | 416 | if (err) |
---|
397 | 417 | return err; |
---|
398 | 418 | |
---|
.. | .. |
---|
412 | 432 | |
---|
413 | 433 | b = (struct tipc_bearer_config *)TLV_DATA(msg->req); |
---|
414 | 434 | |
---|
415 | | - bearer = nla_nest_start(skb, TIPC_NLA_BEARER); |
---|
| 435 | + bearer = nla_nest_start_noflag(skb, TIPC_NLA_BEARER); |
---|
416 | 436 | if (!bearer) |
---|
417 | 437 | return -EMSGSIZE; |
---|
418 | 438 | |
---|
.. | .. |
---|
432 | 452 | return -EMSGSIZE; |
---|
433 | 453 | |
---|
434 | 454 | if (ntohl(b->priority) <= TIPC_MAX_LINK_PRI) { |
---|
435 | | - prop = nla_nest_start(skb, TIPC_NLA_BEARER_PROP); |
---|
| 455 | + prop = nla_nest_start_noflag(skb, TIPC_NLA_BEARER_PROP); |
---|
436 | 456 | if (!prop) |
---|
437 | 457 | return -EMSGSIZE; |
---|
438 | 458 | if (nla_put_u32(skb, TIPC_NLA_PROP_PRIO, ntohl(b->priority))) |
---|
.. | .. |
---|
454 | 474 | |
---|
455 | 475 | name = (char *)TLV_DATA(msg->req); |
---|
456 | 476 | |
---|
457 | | - bearer = nla_nest_start(skb, TIPC_NLA_BEARER); |
---|
| 477 | + bearer = nla_nest_start_noflag(skb, TIPC_NLA_BEARER); |
---|
458 | 478 | if (!bearer) |
---|
459 | 479 | return -EMSGSIZE; |
---|
460 | 480 | |
---|
.. | .. |
---|
531 | 551 | if (!attrs[TIPC_NLA_LINK]) |
---|
532 | 552 | return -EINVAL; |
---|
533 | 553 | |
---|
534 | | - err = nla_parse_nested(link, TIPC_NLA_LINK_MAX, attrs[TIPC_NLA_LINK], |
---|
535 | | - NULL, NULL); |
---|
| 554 | + err = nla_parse_nested_deprecated(link, TIPC_NLA_LINK_MAX, |
---|
| 555 | + attrs[TIPC_NLA_LINK], NULL, NULL); |
---|
536 | 556 | if (err) |
---|
537 | 557 | return err; |
---|
538 | 558 | |
---|
539 | 559 | if (!link[TIPC_NLA_LINK_PROP]) |
---|
540 | 560 | return -EINVAL; |
---|
541 | 561 | |
---|
542 | | - err = nla_parse_nested(prop, TIPC_NLA_PROP_MAX, |
---|
543 | | - link[TIPC_NLA_LINK_PROP], NULL, NULL); |
---|
| 562 | + err = nla_parse_nested_deprecated(prop, TIPC_NLA_PROP_MAX, |
---|
| 563 | + link[TIPC_NLA_LINK_PROP], NULL, |
---|
| 564 | + NULL); |
---|
544 | 565 | if (err) |
---|
545 | 566 | return err; |
---|
546 | 567 | |
---|
547 | 568 | if (!link[TIPC_NLA_LINK_STATS]) |
---|
548 | 569 | return -EINVAL; |
---|
549 | 570 | |
---|
550 | | - err = nla_parse_nested(stats, TIPC_NLA_STATS_MAX, |
---|
551 | | - link[TIPC_NLA_LINK_STATS], NULL, NULL); |
---|
| 571 | + err = nla_parse_nested_deprecated(stats, TIPC_NLA_STATS_MAX, |
---|
| 572 | + link[TIPC_NLA_LINK_STATS], NULL, |
---|
| 573 | + NULL); |
---|
552 | 574 | if (err) |
---|
553 | 575 | return err; |
---|
554 | 576 | |
---|
.. | .. |
---|
666 | 688 | if (!attrs[TIPC_NLA_LINK]) |
---|
667 | 689 | return -EINVAL; |
---|
668 | 690 | |
---|
669 | | - err = nla_parse_nested(link, TIPC_NLA_LINK_MAX, attrs[TIPC_NLA_LINK], |
---|
670 | | - NULL, NULL); |
---|
| 691 | + err = nla_parse_nested_deprecated(link, TIPC_NLA_LINK_MAX, |
---|
| 692 | + attrs[TIPC_NLA_LINK], NULL, NULL); |
---|
671 | 693 | if (err) |
---|
672 | 694 | return err; |
---|
673 | 695 | |
---|
.. | .. |
---|
702 | 724 | struct nlattr *prop; |
---|
703 | 725 | struct nlattr *media; |
---|
704 | 726 | struct tipc_link_config *lc; |
---|
705 | | - int len; |
---|
706 | 727 | |
---|
707 | 728 | lc = (struct tipc_link_config *)TLV_DATA(msg->req); |
---|
708 | 729 | |
---|
709 | | - media = nla_nest_start(skb, TIPC_NLA_MEDIA); |
---|
| 730 | + media = nla_nest_start_noflag(skb, TIPC_NLA_MEDIA); |
---|
710 | 731 | if (!media) |
---|
711 | 732 | return -EMSGSIZE; |
---|
712 | | - |
---|
713 | | - len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_MEDIA_NAME); |
---|
714 | | - if (!string_is_valid(lc->name, len)) |
---|
715 | | - return -EINVAL; |
---|
716 | 733 | |
---|
717 | 734 | if (nla_put_string(skb, TIPC_NLA_MEDIA_NAME, lc->name)) |
---|
718 | 735 | return -EMSGSIZE; |
---|
719 | 736 | |
---|
720 | | - prop = nla_nest_start(skb, TIPC_NLA_MEDIA_PROP); |
---|
| 737 | + prop = nla_nest_start_noflag(skb, TIPC_NLA_MEDIA_PROP); |
---|
721 | 738 | if (!prop) |
---|
722 | 739 | return -EMSGSIZE; |
---|
723 | 740 | |
---|
.. | .. |
---|
734 | 751 | struct nlattr *prop; |
---|
735 | 752 | struct nlattr *bearer; |
---|
736 | 753 | struct tipc_link_config *lc; |
---|
737 | | - int len; |
---|
738 | 754 | |
---|
739 | 755 | lc = (struct tipc_link_config *)TLV_DATA(msg->req); |
---|
740 | 756 | |
---|
741 | | - bearer = nla_nest_start(skb, TIPC_NLA_BEARER); |
---|
| 757 | + bearer = nla_nest_start_noflag(skb, TIPC_NLA_BEARER); |
---|
742 | 758 | if (!bearer) |
---|
743 | 759 | return -EMSGSIZE; |
---|
744 | | - |
---|
745 | | - len = min_t(int, TLV_GET_DATA_LEN(msg->req), TIPC_MAX_MEDIA_NAME); |
---|
746 | | - if (!string_is_valid(lc->name, len)) |
---|
747 | | - return -EINVAL; |
---|
748 | 760 | |
---|
749 | 761 | if (nla_put_string(skb, TIPC_NLA_BEARER_NAME, lc->name)) |
---|
750 | 762 | return -EMSGSIZE; |
---|
751 | 763 | |
---|
752 | | - prop = nla_nest_start(skb, TIPC_NLA_BEARER_PROP); |
---|
| 764 | + prop = nla_nest_start_noflag(skb, TIPC_NLA_BEARER_PROP); |
---|
753 | 765 | if (!prop) |
---|
754 | 766 | return -EMSGSIZE; |
---|
755 | 767 | |
---|
.. | .. |
---|
769 | 781 | |
---|
770 | 782 | lc = (struct tipc_link_config *)TLV_DATA(msg->req); |
---|
771 | 783 | |
---|
772 | | - link = nla_nest_start(skb, TIPC_NLA_LINK); |
---|
| 784 | + link = nla_nest_start_noflag(skb, TIPC_NLA_LINK); |
---|
773 | 785 | if (!link) |
---|
774 | 786 | return -EMSGSIZE; |
---|
775 | 787 | |
---|
776 | 788 | if (nla_put_string(skb, TIPC_NLA_LINK_NAME, lc->name)) |
---|
777 | 789 | return -EMSGSIZE; |
---|
778 | 790 | |
---|
779 | | - prop = nla_nest_start(skb, TIPC_NLA_LINK_PROP); |
---|
| 791 | + prop = nla_nest_start_noflag(skb, TIPC_NLA_LINK_PROP); |
---|
780 | 792 | if (!prop) |
---|
781 | 793 | return -EMSGSIZE; |
---|
782 | 794 | |
---|
.. | .. |
---|
832 | 844 | |
---|
833 | 845 | name = (char *)TLV_DATA(msg->req); |
---|
834 | 846 | |
---|
835 | | - link = nla_nest_start(skb, TIPC_NLA_LINK); |
---|
| 847 | + link = nla_nest_start_noflag(skb, TIPC_NLA_LINK); |
---|
836 | 848 | if (!link) |
---|
837 | 849 | return -EMSGSIZE; |
---|
838 | 850 | |
---|
.. | .. |
---|
865 | 877 | }; |
---|
866 | 878 | |
---|
867 | 879 | ntq = (struct tipc_name_table_query *)TLV_DATA(msg->req); |
---|
868 | | - if (TLV_GET_DATA_LEN(msg->req) < sizeof(struct tipc_name_table_query)) |
---|
| 880 | + if (TLV_GET_DATA_LEN(msg->req) < (int)sizeof(struct tipc_name_table_query)) |
---|
869 | 881 | return -EINVAL; |
---|
870 | 882 | |
---|
871 | 883 | depth = ntohl(ntq->depth); |
---|
.. | .. |
---|
894 | 906 | if (!attrs[TIPC_NLA_NAME_TABLE]) |
---|
895 | 907 | return -EINVAL; |
---|
896 | 908 | |
---|
897 | | - err = nla_parse_nested(nt, TIPC_NLA_NAME_TABLE_MAX, |
---|
898 | | - attrs[TIPC_NLA_NAME_TABLE], NULL, NULL); |
---|
| 909 | + err = nla_parse_nested_deprecated(nt, TIPC_NLA_NAME_TABLE_MAX, |
---|
| 910 | + attrs[TIPC_NLA_NAME_TABLE], NULL, |
---|
| 911 | + NULL); |
---|
899 | 912 | if (err) |
---|
900 | 913 | return err; |
---|
901 | 914 | |
---|
902 | 915 | if (!nt[TIPC_NLA_NAME_TABLE_PUBL]) |
---|
903 | 916 | return -EINVAL; |
---|
904 | 917 | |
---|
905 | | - err = nla_parse_nested(publ, TIPC_NLA_PUBL_MAX, |
---|
906 | | - nt[TIPC_NLA_NAME_TABLE_PUBL], NULL, NULL); |
---|
| 918 | + err = nla_parse_nested_deprecated(publ, TIPC_NLA_PUBL_MAX, |
---|
| 919 | + nt[TIPC_NLA_NAME_TABLE_PUBL], NULL, |
---|
| 920 | + NULL); |
---|
907 | 921 | if (err) |
---|
908 | 922 | return err; |
---|
909 | 923 | |
---|
.. | .. |
---|
962 | 976 | if (!attrs[TIPC_NLA_PUBL]) |
---|
963 | 977 | return -EINVAL; |
---|
964 | 978 | |
---|
965 | | - err = nla_parse_nested(publ, TIPC_NLA_PUBL_MAX, attrs[TIPC_NLA_PUBL], |
---|
966 | | - NULL, NULL); |
---|
| 979 | + err = nla_parse_nested_deprecated(publ, TIPC_NLA_PUBL_MAX, |
---|
| 980 | + attrs[TIPC_NLA_PUBL], NULL, NULL); |
---|
967 | 981 | if (err) |
---|
968 | 982 | return err; |
---|
969 | 983 | |
---|
.. | .. |
---|
998 | 1012 | return -EMSGSIZE; |
---|
999 | 1013 | } |
---|
1000 | 1014 | |
---|
1001 | | - nest = nla_nest_start(args, TIPC_NLA_SOCK); |
---|
| 1015 | + nest = nla_nest_start_noflag(args, TIPC_NLA_SOCK); |
---|
1002 | 1016 | if (!nest) { |
---|
1003 | 1017 | kfree_skb(args); |
---|
1004 | 1018 | return -EMSGSIZE; |
---|
.. | .. |
---|
1032 | 1046 | if (!attrs[TIPC_NLA_SOCK]) |
---|
1033 | 1047 | return -EINVAL; |
---|
1034 | 1048 | |
---|
1035 | | - err = nla_parse_nested(sock, TIPC_NLA_SOCK_MAX, attrs[TIPC_NLA_SOCK], |
---|
1036 | | - NULL, NULL); |
---|
| 1049 | + err = nla_parse_nested_deprecated(sock, TIPC_NLA_SOCK_MAX, |
---|
| 1050 | + attrs[TIPC_NLA_SOCK], NULL, NULL); |
---|
1037 | 1051 | if (err) |
---|
1038 | 1052 | return err; |
---|
1039 | 1053 | |
---|
.. | .. |
---|
1044 | 1058 | u32 node; |
---|
1045 | 1059 | struct nlattr *con[TIPC_NLA_CON_MAX + 1]; |
---|
1046 | 1060 | |
---|
1047 | | - err = nla_parse_nested(con, TIPC_NLA_CON_MAX, |
---|
1048 | | - sock[TIPC_NLA_SOCK_CON], NULL, NULL); |
---|
| 1061 | + err = nla_parse_nested_deprecated(con, TIPC_NLA_CON_MAX, |
---|
| 1062 | + sock[TIPC_NLA_SOCK_CON], |
---|
| 1063 | + NULL, NULL); |
---|
1049 | 1064 | |
---|
1050 | 1065 | if (err) |
---|
1051 | 1066 | return err; |
---|
.. | .. |
---|
1084 | 1099 | if (!attrs[TIPC_NLA_MEDIA]) |
---|
1085 | 1100 | return -EINVAL; |
---|
1086 | 1101 | |
---|
1087 | | - err = nla_parse_nested(media, TIPC_NLA_MEDIA_MAX, |
---|
1088 | | - attrs[TIPC_NLA_MEDIA], NULL, NULL); |
---|
| 1102 | + err = nla_parse_nested_deprecated(media, TIPC_NLA_MEDIA_MAX, |
---|
| 1103 | + attrs[TIPC_NLA_MEDIA], NULL, NULL); |
---|
1089 | 1104 | if (err) |
---|
1090 | 1105 | return err; |
---|
1091 | 1106 | |
---|
.. | .. |
---|
1104 | 1119 | if (!attrs[TIPC_NLA_NODE]) |
---|
1105 | 1120 | return -EINVAL; |
---|
1106 | 1121 | |
---|
1107 | | - err = nla_parse_nested(node, TIPC_NLA_NODE_MAX, attrs[TIPC_NLA_NODE], |
---|
1108 | | - NULL, NULL); |
---|
| 1122 | + err = nla_parse_nested_deprecated(node, TIPC_NLA_NODE_MAX, |
---|
| 1123 | + attrs[TIPC_NLA_NODE], NULL, NULL); |
---|
1109 | 1124 | if (err) |
---|
1110 | 1125 | return err; |
---|
1111 | 1126 | |
---|
.. | .. |
---|
1125 | 1140 | |
---|
1126 | 1141 | val = ntohl(*(__be32 *)TLV_DATA(msg->req)); |
---|
1127 | 1142 | |
---|
1128 | | - net = nla_nest_start(skb, TIPC_NLA_NET); |
---|
| 1143 | + net = nla_nest_start_noflag(skb, TIPC_NLA_NET); |
---|
1129 | 1144 | if (!net) |
---|
1130 | 1145 | return -EMSGSIZE; |
---|
1131 | 1146 | |
---|
.. | .. |
---|
1151 | 1166 | if (!attrs[TIPC_NLA_NET]) |
---|
1152 | 1167 | return -EINVAL; |
---|
1153 | 1168 | |
---|
1154 | | - err = nla_parse_nested(net, TIPC_NLA_NET_MAX, attrs[TIPC_NLA_NET], |
---|
1155 | | - NULL, NULL); |
---|
| 1169 | + err = nla_parse_nested_deprecated(net, TIPC_NLA_NET_MAX, |
---|
| 1170 | + attrs[TIPC_NLA_NET], NULL, NULL); |
---|
1156 | 1171 | if (err) |
---|
1157 | 1172 | return err; |
---|
1158 | 1173 | |
---|
.. | .. |
---|
1322 | 1337 | return err; |
---|
1323 | 1338 | } |
---|
1324 | 1339 | |
---|
1325 | | -static const struct genl_ops tipc_genl_compat_ops[] = { |
---|
| 1340 | +static const struct genl_small_ops tipc_genl_compat_ops[] = { |
---|
1326 | 1341 | { |
---|
1327 | 1342 | .cmd = TIPC_GENL_CMD, |
---|
| 1343 | + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, |
---|
1328 | 1344 | .doit = tipc_nl_compat_recv, |
---|
1329 | 1345 | }, |
---|
1330 | 1346 | }; |
---|
.. | .. |
---|
1336 | 1352 | .maxattr = 0, |
---|
1337 | 1353 | .netnsok = true, |
---|
1338 | 1354 | .module = THIS_MODULE, |
---|
1339 | | - .ops = tipc_genl_compat_ops, |
---|
1340 | | - .n_ops = ARRAY_SIZE(tipc_genl_compat_ops), |
---|
| 1355 | + .small_ops = tipc_genl_compat_ops, |
---|
| 1356 | + .n_small_ops = ARRAY_SIZE(tipc_genl_compat_ops), |
---|
1341 | 1357 | }; |
---|
1342 | 1358 | |
---|
1343 | 1359 | int __init tipc_netlink_compat_start(void) |
---|