rhashtable: Per bucket locks & deferred expansion/shrinking
[cascardo/linux.git] / net / netlink / genetlink.c
index 05bf40b..2e11061 100644 (file)
@@ -983,10 +983,9 @@ static struct genl_multicast_group genl_ctrl_groups[] = {
        { .name = "notify", },
 };
 
-static int genl_bind(int group)
+static int genl_bind(struct net *net, int group)
 {
-       int i, err;
-       bool found = false;
+       int i, err = 0;
 
        down_read(&cb_lock);
        for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
@@ -997,24 +996,22 @@ static int genl_bind(int group)
                            group < f->mcgrp_offset + f->n_mcgrps) {
                                int fam_grp = group - f->mcgrp_offset;
 
-                               if (f->mcast_bind)
-                                       err = f->mcast_bind(fam_grp);
+                               if (!f->netnsok && net != &init_net)
+                                       err = -ENOENT;
+                               else if (f->mcast_bind)
+                                       err = f->mcast_bind(net, fam_grp);
                                else
                                        err = 0;
-                               found = true;
                                break;
                        }
                }
        }
        up_read(&cb_lock);
 
-       if (WARN_ON(!found))
-               err = 0;
-
        return err;
 }
 
-static void genl_unbind(int group)
+static void genl_unbind(struct net *net, int group)
 {
        int i;
        bool found = false;
@@ -1029,7 +1026,7 @@ static void genl_unbind(int group)
                                int fam_grp = group - f->mcgrp_offset;
 
                                if (f->mcast_unbind)
-                                       f->mcast_unbind(fam_grp);
+                                       f->mcast_unbind(net, fam_grp);
                                found = true;
                                break;
                        }