aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2013-02-22 20:13:48 -0500
committerDavid S. Miller <davem@davemloft.net>2013-02-23 13:51:54 -0500
commit8e904550d0fffcda2b18d7ab12750b0c75757e89 (patch)
treebe10511f81dc57b40a3d747940082431fece50b6 /net
parent6e601a53566d84e1ffd25e7b6fe0b6894ffd79c0 (diff)
sock_diag: Simplify sock_diag_handlers[] handling in __sock_diag_rcv_msg
The sock_diag_lock_handler() and sock_diag_unlock_handler() actually make the code less readable. Get rid of them and make the lock usage and access to sock_diag_handlers[] clear on the first sight. Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/sock_diag.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index 750f44f3aa31..a29e90cf36b7 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -97,21 +97,6 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
97} 97}
98EXPORT_SYMBOL_GPL(sock_diag_unregister); 98EXPORT_SYMBOL_GPL(sock_diag_unregister);
99 99
100static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
101{
102 if (sock_diag_handlers[family] == NULL)
103 request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
104 NETLINK_SOCK_DIAG, family);
105
106 mutex_lock(&sock_diag_table_mutex);
107 return sock_diag_handlers[family];
108}
109
110static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
111{
112 mutex_unlock(&sock_diag_table_mutex);
113}
114
115static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) 100static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
116{ 101{
117 int err; 102 int err;
@@ -124,12 +109,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
124 if (req->sdiag_family >= AF_MAX) 109 if (req->sdiag_family >= AF_MAX)
125 return -EINVAL; 110 return -EINVAL;
126 111
127 hndl = sock_diag_lock_handler(req->sdiag_family); 112 if (sock_diag_handlers[req->sdiag_family] == NULL)
113 request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
114 NETLINK_SOCK_DIAG, req->sdiag_family);
115
116 mutex_lock(&sock_diag_table_mutex);
117 hndl = sock_diag_handlers[req->sdiag_family];
128 if (hndl == NULL) 118 if (hndl == NULL)
129 err = -ENOENT; 119 err = -ENOENT;
130 else 120 else
131 err = hndl->dump(skb, nlh); 121 err = hndl->dump(skb, nlh);
132 sock_diag_unlock_handler(hndl); 122 mutex_unlock(&sock_diag_table_mutex);
133 123
134 return err; 124 return err;
135} 125}