From: Patrick McHardy <kaber@trash.net>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Patrick McHardy <kaber@trash.net>
Subject: [RTNETLINK 02/04]: Hold rtnl_mutex during netlink dump callbacks
Date: Mon, 16 Apr 2007 09:51:54 +0200 (MEST) [thread overview]
Message-ID: <20070416074951.19262.57226.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20070416074949.19262.73702.sendpatchset@localhost.localdomain>
[RTNETLINK]: Hold rtnl_mutex during netlink dump callbacks
Hold rtnl_mutex during the entire netlink dump operation. This allows
to simplify locking in the dump callbacks, since they can now rely on
that no concurrent changes happen.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 8d28b6a3d70b6c98bba6d1e60e2ecf8eb9fbbb2b
tree e363ea54f7b22a3cbd47e032c5fed1b1edb7d53c
parent 8373a426e9d692f74d10867c2dc3ea332e09154c
author Patrick McHardy <kaber@trash.net> Mon, 16 Apr 2007 09:05:24 +0200
committer Patrick McHardy <kaber@trash.net> Mon, 16 Apr 2007 09:05:24 +0200
net/core/rtnetlink.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 648a7b6..62f5c7f 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -859,6 +859,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
int min_len;
int family;
int type;
+ int err;
type = nlh->nlmsg_type;
if (type > RTM_MAX)
@@ -887,7 +888,10 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
if (dumpit == NULL)
return -EOPNOTSUPP;
- return netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
+ __rtnl_unlock();
+ err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL);
+ rtnl_lock();
+ return err;
}
memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *)));
@@ -972,7 +976,7 @@ void __init rtnetlink_init(void)
panic("rtnetlink_init: cannot allocate rta_buf\n");
rtnl = netlink_kernel_create(NETLINK_ROUTE, RTNLGRP_MAX, rtnetlink_rcv,
- NULL, THIS_MODULE);
+ &rtnl_mutex, THIS_MODULE);
if (rtnl == NULL)
panic("rtnetlink_init: cannot initialize rtnetlink\n");
netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV);
next prev parent reply other threads:[~2007-04-16 7:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-16 7:51 [NETLINK 00/04]: Consistent dump callback locking Patrick McHardy
2007-04-16 7:51 ` [NETLINK 01/04]: Switch cb_lock spinlock to mutex and allow to override it Patrick McHardy
2007-04-16 23:55 ` David Miller
2007-04-17 10:40 ` Patrick McHardy
2007-04-16 7:51 ` Patrick McHardy [this message]
2007-04-16 23:59 ` [RTNETLINK 02/04]: Hold rtnl_mutex during netlink dump callbacks David Miller
2007-04-16 7:51 ` [RTNETLINK 03/04]: Remove unnecessary locking in " Patrick McHardy
2007-04-17 0:01 ` David Miller
2007-04-16 7:51 ` [NET_SCHED 04/04]: Eliminate qdisc_tree_lock Patrick McHardy
2007-04-17 0:06 ` David Miller
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=20070416074951.19262.57226.sendpatchset@localhost.localdomain \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.