| @@ -17,6 +17,7 @@ · 16 unmodified lines |
| 17 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
| 18 | #include <linux/bitmap.h> | 18 | #include <linux/bitmap.h> |
| 19 | #include <linux/rwsem.h> | 19 | #include <linux/rwsem.h> |
| | 20 | #include <linux/idr.h> |
| 20 | #include <net/sock.h> | 21 | #include <net/sock.h> |
| 21 | #include <net/genetlink.h> | 22 | #include <net/genetlink.h> |
| 22 | | 23 | |
| @@ -58,10 +59,8 @@ static void genl_unlock_all(void) · 35 unmodified lines |
| 58 | up_write(&cb_lock); | 59 | up_write(&cb_lock); |
| 59 | } | 60 | } |
| 60 | | 61 | |
| 61 | #define GENL_FAM_TAB_SIZE 16 | 62 | static DEFINE_IDR(genl_fam_idr); |
| 62 | #define GENL_FAM_TAB_MASK (GENL_FAM_TAB_SIZE - 1) | | |
| 63 | | 63 | |
| 64 | static struct list_head family_ht[GENL_FAM_TAB_SIZE]; | | |
| 65 | /* | 64 | /* |
| 66 | * Bitmap of multicast groups that are currently in use. | 65 | * Bitmap of multicast groups that are currently in use. |
| 67 | * | 66 | * |
| @@ -86,45 +85,29 @@ static unsigned long mc_group_start = 0x3 | BIT(GENL_ID_CTRL) | · 18 unmodified lines |
| 86 | static unsigned long *mc_groups = &mc_group_start; | 85 | static unsigned long *mc_groups = &mc_group_start; |
| 87 | static unsigned long mc_groups_longs = 1; | 86 | static unsigned long mc_groups_longs = 1; |
| 88 | | 87 | |
| 89 | static int genl_ctrl_event(int event, struct genl_family *family, | 88 | static int genl_ctrl_event(int event, const struct genl_family *family, |
| 90 | const struct genl_multicast_group *grp, | 89 | const struct genl_multicast_group *grp, |
| 91 | int grp_id); | 90 | int grp_id); |
| 92 | | 91 | |
| 93 | static inline unsigned int genl_family_hash(unsigned int id) | 92 | static const struct genl_family *genl_family_find_byid(unsigned int id) |
| 94 | { | 93 | { |
| 95 | return id & GENL_FAM_TAB_MASK; | 94 | return idr_find(&genl_fam_idr, id); |
| 96 | } | 95 | } |
| 97 | | 96 | |
| 98 | static inline struct list_head *genl_family_chain(unsigned int id) | 97 | static const struct genl_family *genl_family_find_byname(char *name) |
| 99 | { | 98 | { |
| 100 | return &family_ht[genl_family_hash(id)]; | 99 | const struct genl_family *family; |
| 101 | } | 100 | unsigned int id; |
| 102 | | | |
| 103 | static struct genl_family *genl_family_find_byid(unsigned int id) | | |
| 104 | { | | |
| 105 | struct genl_family *f; | | |
| 106 | | 101 | |
| 107 | list_for_each_entry(f, genl_family_chain(id), family_list) | 102 | idr_for_each_entry(&genl_fam_idr, family, id) |
| 108 | if (f->id == id) | 103 | if (strcmp(family->name, name) == 0) |
| 109 | return f; | 104 | return family; |
| 110 | | 105 | |
| 111 | return NULL; | 106 | return NULL; |
| 112 | } | 107 | } |
| 113 | | 108 | |
| 114 | static struct genl_family *genl_family_find_byname(char *name) | 109 | static const struct genl_ops *genl_get_cmd(u8 cmd, |
| 115 | { | 110 | const struct genl_family *family) |
| 116 | struct genl_family *f; | | |
| 117 | int i; | | |
| 118 | | | |
| 119 | for (i = 0; i < GENL_FAM_TAB_SIZE; i++) | | |
| 120 | list_for_each_entry(f, genl_family_chain(i), family_list) | | |
| 121 | if (strcmp(f->name, name) == 0) | | |
| 122 | return f; | | |
| 123 | | | |
| 124 | return NULL; | | |
| 125 | } | | |
| 126 | | | |
| 127 | static const struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family) | | |
| 128 | { | 111 | { |
| 129 | int i; | 112 | int i; |
| 130 | | 113 | |
| @@ -135,26 +118,6 @@ static const struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family) · 4 unmodified lines |
| 135 | return NULL; | 118 | return NULL; |
| 136 | } | 119 | } |
| 137 | | 120 | |
| 138 | /* Of course we are going to have problems once we hit | | |
| 139 | * 2^16 alive types, but that can only happen by year 2K | | |
| 140 | */ | | |
| 141 | static u16 genl_generate_id(void) | | |
| 142 | { | | |
| 143 | static u16 id_gen_idx = GENL_MIN_ID; | | |
| 144 | int i; | | |
| 145 | | | |
| 146 | for (i = 0; i <= GENL_MAX_ID - GENL_MIN_ID; i++) { | | |
| 147 | if (id_gen_idx != GENL_ID_VFS_DQUOT && | | |
| 148 | id_gen_idx != GENL_ID_PMCRAID && | | |
| 149 | !genl_family_find_byid(id_gen_idx)) | | |
| 150 | return id_gen_idx; | | |
| 151 | if (++id_gen_idx > GENL_MAX_ID) | | |
| 152 | id_gen_idx = GENL_MIN_ID; | | |
| 153 | } | | |
| 154 | | | |
| 155 | return 0; | | |
| 156 | } | | |
| 157 | | | |
| 158 | static int genl_allocate_reserve_groups(int n_groups, int *first_id) | 121 | static int genl_allocate_reserve_groups(int n_groups, int *first_id) |
| 159 | { | 122 | { |
| 160 | unsigned long *new_groups; | 123 | unsigned long *new_groups; |
| @@ -295,7 +258,7 @@ static int genl_validate_assign_mc_groups(struct genl_family *family) · 134 unmodified lines |
| 295 | return err; | 258 | return err; |
| 296 | } | 259 | } |
| 297 | | 260 | |
| 298 | static void genl_unregister_mc_groups(struct genl_family *family) | 261 | static void genl_unregister_mc_groups(const struct genl_family *family) |
| 299 | { | 262 | { |
| 300 | struct net *net; | 263 | struct net *net; |
| 301 | int i; | 264 | int i; |
| @@ -358,6 +321,7 @@ static int genl_validate_ops(const struct genl_family *family) · 56 unmodified lines |
| 358 | int genl_register_family(struct genl_family *family) | 321 | int genl_register_family(struct genl_family *family) |
| 359 | { | 322 | { |
| 360 | int err, i; | 323 | int err, i; |
| | 324 | int start = GENL_START_ALLOC, end = GENL_MAX_ID; |
| 361 | | 325 | |
| 362 | err = genl_validate_ops(family); | 326 | err = genl_validate_ops(family); |
| 363 | if (err) | 327 | if (err) |
| @@ -370,34 +334,20 @@ int genl_register_family(struct genl_family *family) · 6 unmodified lines |
| 370 | goto errout_locked; | 334 | goto errout_locked; |
| 371 | } | 335 | } |
| 372 | | 336 | |
| | 337 | /* |
| | 338 | * Sadly, a few cases need to be special-cased |
| | 339 | * due to them having previously abused the API |
| | 340 | * and having used their family ID also as their |
| | 341 | * multicast group ID, so we use reserved IDs |
| | 342 | * for both to be sure we can do that mapping. |
| | 343 | */ |
| 373 | if (family == &genl_ctrl) { | 344 | if (family == &genl_ctrl) { |
| 374 | family->id = GENL_ID_CTRL; | 345 | /* and this needs to be special for initial family lookups */ |
| 375 | } else { | 346 | start = end = GENL_ID_CTRL; |
| 376 | u16 newid; | 347 | } else if (strcmp(family->name, "pmcraid") == 0) { |
| 377 | | 348 | start = end = GENL_ID_PMCRAID; |
| 378 | /* this should be left zero in the struct */ | 349 | } else if (strcmp(family->name, "VFS_DQUOT") == 0) { |
| 379 | WARN_ON(family->id); | 350 | start = end = GENL_ID_VFS_DQUOT; |
| 380 | | | |
| 381 | /* | | |
| 382 | * Sadly, a few cases need to be special-cased | | |
| 383 | * due to them having previously abused the API | | |
| 384 | * and having used their family ID also as their | | |
| 385 | * multicast group ID, so we use reserved IDs | | |
| 386 | * for both to be sure we can do that mapping. | | |
| 387 | */ | | |
| 388 | if (strcmp(family->name, "pmcraid") == 0) | | |
| 389 | newid = GENL_ID_PMCRAID; | | |
| 390 | else if (strcmp(family->name, "VFS_DQUOT") == 0) | | |
| 391 | newid = GENL_ID_VFS_DQUOT; | | |
| 392 | else | | |
| 393 | newid = genl_generate_id(); | | |
| 394 | | | |
| 395 | if (!newid) { | | |
| 396 | err = -ENOMEM; | | |
| 397 | goto errout_locked; | | |
| 398 | } | | |
| 399 | | | |
| 400 | family->id = newid; | | |
| 401 | } | 351 | } |
| 402 | | 352 | |
| 403 | if (family->maxattr && !family->parallel_ops) { | 353 | if (family->maxattr && !family->parallel_ops) { |
| @@ -410,11 +360,15 @@ int genl_register_family(struct genl_family *family) · 6 unmodified lines |
| 410 | } else | 360 | } else |
| 411 | family->attrbuf = NULL; | 361 | family->attrbuf = NULL; |
| 412 | | 362 | |
| | 363 | family->id = idr_alloc(&genl_fam_idr, family, |
| | 364 | start, end + 1, GFP_KERNEL); |
| | 365 | if (!family->id) |
| | 366 | goto errout_locked; |
| | 367 | |
| 413 | err = genl_validate_assign_mc_groups(family); | 368 | err = genl_validate_assign_mc_groups(family); |
| 414 | if (err) | 369 | if (err) |
| 415 | goto errout_locked; | 370 | goto errout_remove; |
| 416 | | 371 | |
| 417 | list_add_tail(&family->family_list, genl_family_chain(family->id)); | | |
| 418 | genl_unlock_all(); | 372 | genl_unlock_all(); |
| 419 | | 373 | |
| 420 | /* send all events */ | 374 | /* send all events */ |
| @@ -425,6 +379,8 @@ int genl_register_family(struct genl_family *family) · 4 unmodified lines |
| 425 | | 379 | |
| 426 | return 0; | 380 | return 0; |
| 427 | | 381 | |
| | 382 | errout_remove: |
| | 383 | idr_remove(&genl_fam_idr, family->id); |
| 428 | errout_locked: | 384 | errout_locked: |
| 429 | genl_unlock_all(); | 385 | genl_unlock_all(); |
| 430 | return err; | 386 | return err; |
| @@ -439,32 +395,29 @@ EXPORT_SYMBOL(genl_register_family); · 8 unmodified lines |
| 439 | * | 395 | * |
| 440 | * Returns 0 on success or a negative error code. | 396 | * Returns 0 on success or a negative error code. |
| 441 | */ | 397 | */ |
| 442 | int genl_unregister_family(struct genl_family *family) | 398 | int genl_unregister_family(const struct genl_family *family) |
| 443 | { | 399 | { |
| 444 | struct genl_family *rc; | | |
| 445 | | | |
| 446 | genl_lock_all(); | 400 | genl_lock_all(); |
| 447 | | 401 | |
| 448 | list_for_each_entry(rc, genl_family_chain(family->id), family_list) { | 402 | if (genl_family_find_byid(family->id)) { |
| 449 | if (family->id != rc->id || strcmp(rc->name, family->name)) | 403 | genl_unlock_all(); |
| 450 | continue; | 404 | return -ENOENT; |
| | 405 | } |
| 451 | | 406 | |
| 452 | genl_unregister_mc_groups(family); | 407 | genl_unregister_mc_groups(family); |
| 453 | | 408 | |
| 454 | list_del(&rc->family_list); | 409 | idr_remove(&genl_fam_idr, family->id); |
| 455 | up_write(&cb_lock); | | |
| 456 | wait_event(genl_sk_destructing_waitq, | | |
| 457 | atomic_read(&genl_sk_destructing_cnt) == 0); | | |
| 458 | genl_unlock(); | | |
| 459 | | 410 | |
| 460 | kfree(family->attrbuf); | 411 | up_write(&cb_lock); |
| 461 | genl_ctrl_event(CTRL_CMD_DELFAMILY, family, NULL, 0); | 412 | wait_event(genl_sk_destructing_waitq, |
| 462 | return 0; | 413 | atomic_read(&genl_sk_destructing_cnt) == 0); |
| 463 | } | 414 | genl_unlock(); |
| 464 | | 415 | |
| 465 | genl_unlock_all(); | 416 | kfree(family->attrbuf); |
| 466 | | 417 | |
| 467 | return -ENOENT; | 418 | genl_ctrl_event(CTRL_CMD_DELFAMILY, family, NULL, 0); |
| | 419 | |
| | 420 | return 0; |
| 468 | } | 421 | } |
| 469 | EXPORT_SYMBOL(genl_unregister_family); | 422 | EXPORT_SYMBOL(genl_unregister_family); |
| 470 | | 423 | |
| @@ -480,7 +433,7 @@ EXPORT_SYMBOL(genl_unregister_family); · 9 unmodified lines |
| 480 | * Returns pointer to user specific header | 433 | * Returns pointer to user specific header |
| 481 | */ | 434 | */ |
| 482 | void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, | 435 | void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, |
| 483 | struct genl_family *family, int flags, u8 cmd) | 436 | const struct genl_family *family, int flags, u8 cmd) |
| 484 | { | 437 | { |
| 485 | struct nlmsghdr *nlh; | 438 | struct nlmsghdr *nlh; |
| 486 | struct genlmsghdr *hdr; | 439 | struct genlmsghdr *hdr; |
| @@ -539,7 +492,7 @@ static int genl_lock_done(struct netlink_callback *cb) · 52 unmodified lines |
| 539 | return rc; | 492 | return rc; |
| 540 | } | 493 | } |
| 541 | | 494 | |
| 542 | static int genl_family_rcv_msg(struct genl_family *family, | 495 | static int genl_family_rcv_msg(const struct genl_family *family, |
| 543 | struct sk_buff *skb, | 496 | struct sk_buff *skb, |
| 544 | struct nlmsghdr *nlh) | 497 | struct nlmsghdr *nlh) |
| 545 | { | 498 | { |
| @@ -651,7 +604,7 @@ out: · 105 unmodified lines |
| 651 | | 604 | |
| 652 | static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | 605 | static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
| 653 | { | 606 | { |
| 654 | struct genl_family *family; | 607 | const struct genl_family *family; |
| 655 | int err; | 608 | int err; |
| 656 | | 609 | |
| 657 | family = genl_family_find_byid(nlh->nlmsg_type); | 610 | family = genl_family_find_byid(nlh->nlmsg_type); |
| @@ -682,7 +635,7 @@ static void genl_rcv(struct sk_buff *skb) · 24 unmodified lines |
| 682 | | 635 | |
| 683 | static struct genl_family genl_ctrl; | 636 | static struct genl_family genl_ctrl; |
| 684 | | 637 | |
| 685 | static int ctrl_fill_info(struct genl_family *family, u32 portid, u32 seq, | 638 | static int ctrl_fill_info(const struct genl_family *family, u32 portid, u32 seq, |
| 686 | u32 flags, struct sk_buff *skb, u8 cmd) | 639 | u32 flags, struct sk_buff *skb, u8 cmd) |
| 687 | { | 640 | { |
| 688 | void *hdr; | 641 | void *hdr; |
| @@ -769,7 +722,7 @@ nla_put_failure: · 80 unmodified lines |
| 769 | return -EMSGSIZE; | 722 | return -EMSGSIZE; |
| 770 | } | 723 | } |
| 771 | | 724 | |
| 772 | static int ctrl_fill_mcgrp_info(struct genl_family *family, | 725 | static int ctrl_fill_mcgrp_info(const struct genl_family *family, |
| 773 | const struct genl_multicast_group *grp, | 726 | const struct genl_multicast_group *grp, |
| 774 | int grp_id, u32 portid, u32 seq, u32 flags, | 727 | int grp_id, u32 portid, u32 seq, u32 flags, |
| 775 | struct sk_buff *skb, u8 cmd) | 728 | struct sk_buff *skb, u8 cmd) |
| @@ -812,37 +765,30 @@ nla_put_failure: · 36 unmodified lines |
| 812 | | 765 | |
| 813 | static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb) | 766 | static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb) |
| 814 | { | 767 | { |
| 815 | | 768 | int n = 0; |
| 816 | int i, n = 0; | | |
| 817 | struct genl_family *rt; | 769 | struct genl_family *rt; |
| 818 | struct net *net = sock_net(skb->sk); | 770 | struct net *net = sock_net(skb->sk); |
| 819 | int chains_to_skip = cb->args[0]; | 771 | int fams_to_skip = cb->args[0]; |
| 820 | int fams_to_skip = cb->args[1]; | 772 | unsigned int id; |
| 821 | | | |
| 822 | for (i = chains_to_skip; i < GENL_FAM_TAB_SIZE; i++) { | | |
| 823 | n = 0; | | |
| 824 | list_for_each_entry(rt, genl_family_chain(i), family_list) { | | |
| 825 | if (!rt->netnsok && !net_eq(net, &init_net)) | | |
| 826 | continue; | | |
| 827 | if (++n < fams_to_skip) | | |
| 828 | continue; | | |
| 829 | if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).portid, | | |
| 830 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | | |
| 831 | skb, CTRL_CMD_NEWFAMILY) < 0) | | |
| 832 | goto errout; | | |
| 833 | } | | |
| 834 | | 773 | |
| 835 | fams_to_skip = 0; | 774 | idr_for_each_entry(&genl_fam_idr, rt, id) { |
| 836 | } | 775 | if (!rt->netnsok && !net_eq(net, &init_net)) |
| | 776 | continue; |
| | 777 | |
| | 778 | if (n++ < fams_to_skip) |
| | 779 | continue; |
| 837 | | 780 | |
| 838 | errout: | 781 | if (ctrl_fill_info(rt, NETLINK_CB(cb->skb).portid, |
| 839 | cb->args[0] = i; | 782 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
| 840 | cb->args[1] = n; | 783 | skb, CTRL_CMD_NEWFAMILY) < 0) |
| | 784 | break; |
| | 785 | } |
| 841 | | 786 | |
| | 787 | cb->args[0] = n; |
| 842 | return skb->len; | 788 | return skb->len; |
| 843 | } | 789 | } |
| 844 | | 790 | |
| 845 | static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, | 791 | static struct sk_buff *ctrl_build_family_msg(const struct genl_family *family, |
| 846 | u32 portid, int seq, u8 cmd) | 792 | u32 portid, int seq, u8 cmd) |
| 847 | { | 793 | { |
| 848 | struct sk_buff *skb; | 794 | struct sk_buff *skb; |
| @@ -862,7 +808,7 @@ static struct sk_buff *ctrl_build_family_msg(struct genl_family *family, · 13 unmodified lines |
| 862 | } | 808 | } |
| 863 | | 809 | |
| 864 | static struct sk_buff * | 810 | static struct sk_buff * |
| 865 | ctrl_build_mcgrp_msg(struct genl_family *family, | 811 | ctrl_build_mcgrp_msg(const struct genl_family *family, |
| 866 | const struct genl_multicast_group *grp, | 812 | const struct genl_multicast_group *grp, |
| 867 | int grp_id, u32 portid, int seq, u8 cmd) | 813 | int grp_id, u32 portid, int seq, u8 cmd) |
| 868 | { | 814 | { |
| @@ -892,7 +838,7 @@ static const struct nla_policy ctrl_policy[CTRL_ATTR_MAX+1] = { · 23 unmodified lines |
| 892 | static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info) | 838 | static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info) |
| 893 | { | 839 | { |
| 894 | struct sk_buff *msg; | 840 | struct sk_buff *msg; |
| 895 | struct genl_family *res = NULL; | 841 | const struct genl_family *res = NULL; |
| 896 | int err = -EINVAL; | 842 | int err = -EINVAL; |
| 897 | | 843 | |
| 898 | if (info->attrs[CTRL_ATTR_FAMILY_ID]) { | 844 | if (info->attrs[CTRL_ATTR_FAMILY_ID]) { |
| @@ -936,7 +882,7 @@ static int ctrl_getfamily(struct sk_buff *skb, struct genl_info *info) · 37 unmodified lines |
| 936 | return genlmsg_reply(msg, info); | 882 | return genlmsg_reply(msg, info); |
| 937 | } | 883 | } |
| 938 | | 884 | |
| 939 | static int genl_ctrl_event(int event, struct genl_family *family, | 885 | static int genl_ctrl_event(int event, const struct genl_family *family, |
| 940 | const struct genl_multicast_group *grp, | 886 | const struct genl_multicast_group *grp, |
| 941 | int grp_id) | 887 | int grp_id) |
| 942 | { | 888 | { |
| @@ -1005,25 +951,24 @@ static struct genl_family genl_ctrl = { · 62 unmodified lines |
| 1005 | | 951 | |
| 1006 | static int genl_bind(struct net *net, int group) | 952 | static int genl_bind(struct net *net, int group) |
| 1007 | { | 953 | { |
| 1008 | int i, err = -ENOENT; | 954 | struct genl_family *f; |
| | 955 | int err = -ENOENT; |
| | 956 | unsigned int id; |
| 1009 | | 957 | |
| 1010 | down_read(&cb_lock); | 958 | down_read(&cb_lock); |
| 1011 | for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { | 959 | |
| 1012 | struct genl_family *f; | 960 | idr_for_each_entry(&genl_fam_idr, f, id) { |
| 1013 | | 961 | if (group >= f->mcgrp_offset && |
| 1014 | list_for_each_entry(f, genl_family_chain(i), family_list) { | 962 | group < f->mcgrp_offset + f->n_mcgrps) { |
| 1015 | if (group >= f->mcgrp_offset && | 963 | int fam_grp = group - f->mcgrp_offset; |
| 1016 | group < f->mcgrp_offset + f->n_mcgrps) { | 964 | |
| 1017 | int fam_grp = group - f->mcgrp_offset; | 965 | if (!f->netnsok && net != &init_net) |
| 1018 | | 966 | err = -ENOENT; |
| 1019 | if (!f->netnsok && net != &init_net) | 967 | else if (f->mcast_bind) |
| 1020 | err = -ENOENT; | 968 | err = f->mcast_bind(net, fam_grp); |
| 1021 | else if (f->mcast_bind) | 969 | else |
| 1022 | err = f->mcast_bind(net, fam_grp); | 970 | err = 0; |
| 1023 | else | 971 | break; |
| 1024 | err = 0; | | |
| 1025 | break; | | |
| 1026 | } | | |
| 1027 | } | 972 | } |
| 1028 | } | 973 | } |
| 1029 | up_read(&cb_lock); | 974 | up_read(&cb_lock); |
| @@ -1033,21 +978,19 @@ static int genl_bind(struct net *net, int group) · 3 unmodified lines |
| 1033 | | 978 | |
| 1034 | static void genl_unbind(struct net *net, int group) | 979 | static void genl_unbind(struct net *net, int group) |
| 1035 | { | 980 | { |
| 1036 | int i; | 981 | struct genl_family *f; |
| | 982 | unsigned int id; |
| 1037 | | 983 | |
| 1038 | down_read(&cb_lock); | 984 | down_read(&cb_lock); |
| 1039 | for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { | | |
| 1040 | struct genl_family *f; | | |
| 1041 | | 985 | |
| 1042 | list_for_each_entry(f, genl_family_chain(i), family_list) { | 986 | idr_for_each_entry(&genl_fam_idr, f, id) { |
| 1043 | if (group >= f->mcgrp_offset && | 987 | if (group >= f->mcgrp_offset && |
| 1044 | group < f->mcgrp_offset + f->n_mcgrps) { | 988 | group < f->mcgrp_offset + f->n_mcgrps) { |
| 1045 | int fam_grp = group - f->mcgrp_offset; | 989 | int fam_grp = group - f->mcgrp_offset; |
| 1046 | | 990 | |
| 1047 | if (f->mcast_unbind) | 991 | if (f->mcast_unbind) |
| 1048 | f->mcast_unbind(net, fam_grp); | 992 | f->mcast_unbind(net, fam_grp); |
| 1049 | break; | 993 | break; |
| 1050 | } | | |
| 1051 | } | 994 | } |
| 1052 | } | 995 | } |
| 1053 | up_read(&cb_lock); | 996 | up_read(&cb_lock); |
| @@ -1087,10 +1030,7 @@ static struct pernet_operations genl_pernet_ops = { · 33 unmodified lines |
| 1087 | | 1030 | |
| 1088 | static int __init genl_init(void) | 1031 | static int __init genl_init(void) |
| 1089 | { | 1032 | { |
| 1090 | int i, err; | 1033 | int err; |
| 1091 | | | |
| 1092 | for (i = 0; i < GENL_FAM_TAB_SIZE; i++) | | |
| 1093 | INIT_LIST_HEAD(&family_ht[i]); | | |
| 1094 | | 1034 | |
| 1095 | err = genl_register_family(&genl_ctrl); | 1035 | err = genl_register_family(&genl_ctrl); |
| 1096 | if (err < 0) | 1036 | if (err < 0) |
| @@ -1118,7 +1058,7 @@ subsys_initcall(genl_init); · 21 unmodified lines |
| 1118 | * You cannot use this function with a family that has parallel_ops | 1058 | * You cannot use this function with a family that has parallel_ops |
| 1119 | * and you can only use it within (pre/post) doit/dumpit callbacks. | 1059 | * and you can only use it within (pre/post) doit/dumpit callbacks. |
| 1120 | */ | 1060 | */ |
| 1121 | struct nlattr **genl_family_attrbuf(struct genl_family *family) | 1061 | struct nlattr **genl_family_attrbuf(const struct genl_family *family) |
| 1122 | { | 1062 | { |
| 1123 | if (!WARN_ON(family->parallel_ops)) | 1063 | if (!WARN_ON(family->parallel_ops)) |
| 1124 | lockdep_assert_held(&genl_mutex); | 1064 | lockdep_assert_held(&genl_mutex); |
| @@ -1156,8 +1096,9 @@ static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group, · 31 unmodified lines |
| 1156 | return err; | 1096 | return err; |
| 1157 | } | 1097 | } |
| 1158 | | 1098 | |
| 1159 | int genlmsg_multicast_allns(struct genl_family *family, struct sk_buff *skb, | 1099 | int genlmsg_multicast_allns(const struct genl_family *family, |
| 1160 | u32 portid, unsigned int group, gfp_t flags) | 1100 | struct sk_buff *skb, u32 portid, |
| | 1101 | unsigned int group, gfp_t flags) |
| 1161 | { | 1102 | { |
| 1162 | if (WARN_ON_ONCE(group >= family->n_mcgrps)) | 1103 | if (WARN_ON_ONCE(group >= family->n_mcgrps)) |
| 1163 | return -EINVAL; | 1104 | return -EINVAL; |
| @@ -1166,7 +1107,7 @@ int genlmsg_multicast_allns(struct genl_family *family, struct sk_buff *skb, · 2 unmodified lines |
| 1166 | } | 1107 | } |
| 1167 | EXPORT_SYMBOL(genlmsg_multicast_allns); | 1108 | EXPORT_SYMBOL(genlmsg_multicast_allns); |
| 1168 | | 1109 | |
| 1169 | void genl_notify(struct genl_family *family, struct sk_buff *skb, | 1110 | void genl_notify(const struct genl_family *family, struct sk_buff *skb, |
| 1170 | struct genl_info *info, u32 group, gfp_t flags) | 1111 | struct genl_info *info, u32 group, gfp_t flags) |
| 1171 | { | 1112 | { |
| 1172 | struct net *net = genl_info_net(info); | 1113 | struct net *net = genl_info_net(info); |