From: Patrick McHardy <kaber@trash.net>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: David Miller <davem@davemloft.net>,
netdev@vger.kernel.org, Zhang Rui <rui.zhang@intel.com>,
jamal <hadi@cyberus.ca>
Subject: Re: [patch 2/3] netlink: allow removing multicast groups
Date: Tue, 17 Jul 2007 17:50:25 +0200 [thread overview]
Message-ID: <469CE541.9090708@trash.net> (raw)
In-Reply-To: <20070717123643.626951000@sipsolutions.net>
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)
>
next prev parent reply other threads:[~2007-07-17 15:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-17 12:27 [patch 0/3] dynamic generic netlink multicast Johannes Berg
2007-07-17 12:27 ` [patch 1/3] netlink: allocate group bitmaps dynamically Johannes Berg
2007-07-17 15:45 ` Patrick McHardy
2007-07-18 13:34 ` Johannes Berg
2007-07-17 12:27 ` [patch 2/3] netlink: allow removing multicast groups Johannes Berg
2007-07-17 15:50 ` Patrick McHardy [this message]
2007-07-18 13:35 ` Johannes Berg
2007-07-17 12:27 ` [patch 3/3] generic netlink: dynamic " Johannes Berg
2007-07-18 13:37 ` [PATCH v2 2/3] netlink: allow removing " Johannes Berg
2007-07-18 22:30 ` David Miller
2007-07-18 14:34 ` [PATCH v2 1/3] netlink: allocate group bitmaps dynamically Johannes Berg
2007-07-18 16:30 ` Patrick McHardy
2007-07-18 22:34 ` David Miller
2007-07-19 10:08 ` Johannes Berg
2007-07-18 15:05 ` [PATCH v2 3/3] generic netlink: dynamic multicast groups Johannes Berg
2007-07-19 10:39 ` [patch 0/3] dynamic generic netlink multicast Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=469CE541.9090708@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=hadi@cyberus.ca \
--cc=johannes@sipsolutions.net \
--cc=netdev@vger.kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).