diff options
author | Patrick McHardy <kaber@trash.net> | 2007-04-16 19:59:10 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:29:04 -0400 |
commit | 1c2d670f3660e9103fdcdca702f6dbf8ea7d6afb (patch) | |
tree | 4a85b1e41f74e0c0b7445a950186b026de3ef0e0 | |
parent | af65bdfce98d7965fbe93a48b8128444a2eea024 (diff) |
[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>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | 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 648a7b6d15df..62f5c7f98d17 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) | |||
859 | int min_len; | 859 | int min_len; |
860 | int family; | 860 | int family; |
861 | int type; | 861 | int type; |
862 | int err; | ||
862 | 863 | ||
863 | type = nlh->nlmsg_type; | 864 | type = nlh->nlmsg_type; |
864 | if (type > RTM_MAX) | 865 | if (type > RTM_MAX) |
@@ -887,7 +888,10 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
887 | if (dumpit == NULL) | 888 | if (dumpit == NULL) |
888 | return -EOPNOTSUPP; | 889 | return -EOPNOTSUPP; |
889 | 890 | ||
890 | return netlink_dump_start(rtnl, skb, nlh, dumpit, NULL); | 891 | __rtnl_unlock(); |
892 | err = netlink_dump_start(rtnl, skb, nlh, dumpit, NULL); | ||
893 | rtnl_lock(); | ||
894 | return err; | ||
891 | } | 895 | } |
892 | 896 | ||
893 | memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *))); | 897 | memset(rta_buf, 0, (rtattr_max * sizeof(struct rtattr *))); |
@@ -972,7 +976,7 @@ void __init rtnetlink_init(void) | |||
972 | panic("rtnetlink_init: cannot allocate rta_buf\n"); | 976 | panic("rtnetlink_init: cannot allocate rta_buf\n"); |
973 | 977 | ||
974 | rtnl = netlink_kernel_create(NETLINK_ROUTE, RTNLGRP_MAX, rtnetlink_rcv, | 978 | rtnl = netlink_kernel_create(NETLINK_ROUTE, RTNLGRP_MAX, rtnetlink_rcv, |
975 | NULL, THIS_MODULE); | 979 | &rtnl_mutex, THIS_MODULE); |
976 | if (rtnl == NULL) | 980 | if (rtnl == NULL) |
977 | panic("rtnetlink_init: cannot initialize rtnetlink\n"); | 981 | panic("rtnetlink_init: cannot initialize rtnetlink\n"); |
978 | netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV); | 982 | netlink_set_nonroot(NETLINK_ROUTE, NL_NONROOT_RECV); |