Johannes Berg wrote:
> +static void netlink_update_socket_mc(struct netlink_sock *nlk,
> +                                  unsigned int group,
> +                                  int is_new)
> +{
> +     int old, new = !!is_new, subscriptions;
> +
> +     netlink_table_grab();


Having the caller lock the table would save lots of atomic operation
in case of netlink_clear_multicast_users.

> +     old = test_bit(group - 1, nlk->groups);
> +     subscriptions = nlk->subscriptions - old + new;
> +     if (new)
> +             __set_bit(group - 1, nlk->groups);
> +     else
> +             __clear_bit(group - 1, nlk->groups);
> +     netlink_update_subscriptions(&nlk->sk, subscriptions);
> +     netlink_update_listeners(&nlk->sk);
> +     netlink_table_ungrab();
> +}
> +

> +void netlink_clear_multicast_users(int unit, unsigned int group)

Same as in the last patch, passing the kernel socket would be nicer IMO.

> +{
> +     struct sock *sk;
> +     struct hlist_node *node;
> +
> +     read_lock(&nl_table_lock);

Won't this deadlock? netlink_table_grab takes a write-lock.

> +
> +     sk_for_each_bound(sk, node, &nl_table[unit].mc_list)
> +             netlink_update_socket_mc(nlk_sk(sk), group, 0);
> +
> +     read_unlock(&nl_table_lock);
> +}
> +EXPORT_SYMBOL(netlink_clear_multicast_users);
> +
>  void netlink_set_nonroot(int protocol, unsigned int flags)
>  {
>       if ((unsigned int)protocol < MAX_LINKS)
> 

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to