diff options
author | Sage Weil <sage@inktank.com> | 2013-03-25 13:26:14 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:17:14 -0400 |
commit | 27859f9773e4a0b2042435b13400ee2c891a61f4 (patch) | |
tree | 28b8e7133959c88f4de89cc98eee2016874b1ca6 /net | |
parent | 0bed9b5c523d577378b6f83eab5835fe30c27208 (diff) |
libceph: wrap auth ops in wrapper functions
Use wrapper functions that check whether the auth op exists so that callers
do not need a bunch of conditional checks. Simplifies the external
interface.
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/auth.c | 47 | ||||
-rw-r--r-- | net/ceph/auth_x.c | 1 | ||||
-rw-r--r-- | net/ceph/mon_client.c | 7 | ||||
-rw-r--r-- | net/ceph/osd_client.c | 26 |
4 files changed, 59 insertions, 22 deletions
diff --git a/net/ceph/auth.c b/net/ceph/auth.c index b4bf4ac090f1..a22de543cedb 100644 --- a/net/ceph/auth.c +++ b/net/ceph/auth.c | |||
@@ -257,3 +257,50 @@ int ceph_auth_is_authenticated(struct ceph_auth_client *ac) | |||
257 | return 0; | 257 | return 0; |
258 | return ac->ops->is_authenticated(ac); | 258 | return ac->ops->is_authenticated(ac); |
259 | } | 259 | } |
260 | EXPORT_SYMBOL(ceph_auth_is_authenticated); | ||
261 | |||
262 | int ceph_auth_create_authorizer(struct ceph_auth_client *ac, | ||
263 | int peer_type, | ||
264 | struct ceph_auth_handshake *auth) | ||
265 | { | ||
266 | if (ac->ops && ac->ops->create_authorizer) | ||
267 | return ac->ops->create_authorizer(ac, peer_type, auth); | ||
268 | return 0; | ||
269 | } | ||
270 | EXPORT_SYMBOL(ceph_auth_create_authorizer); | ||
271 | |||
272 | void ceph_auth_destroy_authorizer(struct ceph_auth_client *ac, | ||
273 | struct ceph_authorizer *a) | ||
274 | { | ||
275 | if (ac->ops && ac->ops->destroy_authorizer) | ||
276 | ac->ops->destroy_authorizer(ac, a); | ||
277 | } | ||
278 | EXPORT_SYMBOL(ceph_auth_destroy_authorizer); | ||
279 | |||
280 | int ceph_auth_update_authorizer(struct ceph_auth_client *ac, | ||
281 | int peer_type, | ||
282 | struct ceph_auth_handshake *a) | ||
283 | { | ||
284 | int ret = 0; | ||
285 | |||
286 | if (ac->ops && ac->ops->update_authorizer) | ||
287 | ret = ac->ops->update_authorizer(ac, peer_type, a); | ||
288 | return ret; | ||
289 | } | ||
290 | EXPORT_SYMBOL(ceph_auth_update_authorizer); | ||
291 | |||
292 | int ceph_auth_verify_authorizer_reply(struct ceph_auth_client *ac, | ||
293 | struct ceph_authorizer *a, size_t len) | ||
294 | { | ||
295 | if (ac->ops && ac->ops->verify_authorizer_reply) | ||
296 | return ac->ops->verify_authorizer_reply(ac, a, len); | ||
297 | return 0; | ||
298 | } | ||
299 | EXPORT_SYMBOL(ceph_auth_verify_authorizer_reply); | ||
300 | |||
301 | void ceph_auth_invalidate_authorizer(struct ceph_auth_client *ac, int peer_type) | ||
302 | { | ||
303 | if (ac->ops && ac->ops->invalidate_authorizer) | ||
304 | ac->ops->invalidate_authorizer(ac, peer_type); | ||
305 | } | ||
306 | EXPORT_SYMBOL(ceph_auth_invalidate_authorizer); | ||
diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c index 2d5981555cd6..96238ba95f2b 100644 --- a/net/ceph/auth_x.c +++ b/net/ceph/auth_x.c | |||
@@ -562,7 +562,6 @@ static int ceph_x_update_authorizer( | |||
562 | { | 562 | { |
563 | struct ceph_x_authorizer *au; | 563 | struct ceph_x_authorizer *au; |
564 | struct ceph_x_ticket_handler *th; | 564 | struct ceph_x_ticket_handler *th; |
565 | int ret; | ||
566 | 565 | ||
567 | th = get_ticket_handler(ac, peer_type); | 566 | th = get_ticket_handler(ac, peer_type); |
568 | if (IS_ERR(th)) | 567 | if (IS_ERR(th)) |
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c index aef5b1062bee..1fe25cd29d0e 100644 --- a/net/ceph/mon_client.c +++ b/net/ceph/mon_client.c | |||
@@ -737,7 +737,7 @@ static void delayed_work(struct work_struct *work) | |||
737 | 737 | ||
738 | __validate_auth(monc); | 738 | __validate_auth(monc); |
739 | 739 | ||
740 | if (monc->auth->ops->is_authenticated(monc->auth)) | 740 | if (ceph_auth_is_authenticated(monc->auth)) |
741 | __send_subscribe(monc); | 741 | __send_subscribe(monc); |
742 | } | 742 | } |
743 | __schedule_delayed(monc); | 743 | __schedule_delayed(monc); |
@@ -892,8 +892,7 @@ static void handle_auth_reply(struct ceph_mon_client *monc, | |||
892 | 892 | ||
893 | mutex_lock(&monc->mutex); | 893 | mutex_lock(&monc->mutex); |
894 | had_debugfs_info = have_debugfs_info(monc); | 894 | had_debugfs_info = have_debugfs_info(monc); |
895 | if (monc->auth->ops) | 895 | was_auth = ceph_auth_is_authenticated(monc->auth); |
896 | was_auth = monc->auth->ops->is_authenticated(monc->auth); | ||
897 | monc->pending_auth = 0; | 896 | monc->pending_auth = 0; |
898 | ret = ceph_handle_auth_reply(monc->auth, msg->front.iov_base, | 897 | ret = ceph_handle_auth_reply(monc->auth, msg->front.iov_base, |
899 | msg->front.iov_len, | 898 | msg->front.iov_len, |
@@ -904,7 +903,7 @@ static void handle_auth_reply(struct ceph_mon_client *monc, | |||
904 | wake_up_all(&monc->client->auth_wq); | 903 | wake_up_all(&monc->client->auth_wq); |
905 | } else if (ret > 0) { | 904 | } else if (ret > 0) { |
906 | __send_prepared_auth_request(monc, ret); | 905 | __send_prepared_auth_request(monc, ret); |
907 | } else if (!was_auth && monc->auth->ops->is_authenticated(monc->auth)) { | 906 | } else if (!was_auth && ceph_auth_is_authenticated(monc->auth)) { |
908 | dout("authenticated, starting session\n"); | 907 | dout("authenticated, starting session\n"); |
909 | 908 | ||
910 | monc->client->msgr.inst.name.type = CEPH_ENTITY_TYPE_CLIENT; | 909 | monc->client->msgr.inst.name.type = CEPH_ENTITY_TYPE_CLIENT; |
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 5ef24e3e1627..7041906a55a6 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -666,8 +666,7 @@ static void put_osd(struct ceph_osd *osd) | |||
666 | if (atomic_dec_and_test(&osd->o_ref) && osd->o_auth.authorizer) { | 666 | if (atomic_dec_and_test(&osd->o_ref) && osd->o_auth.authorizer) { |
667 | struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth; | 667 | struct ceph_auth_client *ac = osd->o_osdc->client->monc.auth; |
668 | 668 | ||
669 | if (ac->ops && ac->ops->destroy_authorizer) | 669 | ceph_auth_destroy_authorizer(ac, osd->o_auth.authorizer); |
670 | ac->ops->destroy_authorizer(ac, osd->o_auth.authorizer); | ||
671 | kfree(osd); | 670 | kfree(osd); |
672 | } | 671 | } |
673 | } | 672 | } |
@@ -2211,17 +2210,16 @@ static struct ceph_auth_handshake *get_authorizer(struct ceph_connection *con, | |||
2211 | struct ceph_auth_handshake *auth = &o->o_auth; | 2210 | struct ceph_auth_handshake *auth = &o->o_auth; |
2212 | 2211 | ||
2213 | if (force_new && auth->authorizer) { | 2212 | if (force_new && auth->authorizer) { |
2214 | if (ac->ops && ac->ops->destroy_authorizer) | 2213 | ceph_auth_destroy_authorizer(ac, auth->authorizer); |
2215 | ac->ops->destroy_authorizer(ac, auth->authorizer); | ||
2216 | auth->authorizer = NULL; | 2214 | auth->authorizer = NULL; |
2217 | } | 2215 | } |
2218 | if (!auth->authorizer && ac->ops && ac->ops->create_authorizer) { | 2216 | if (!auth->authorizer) { |
2219 | int ret = ac->ops->create_authorizer(ac, CEPH_ENTITY_TYPE_OSD, | 2217 | int ret = ceph_auth_create_authorizer(ac, CEPH_ENTITY_TYPE_OSD, |
2220 | auth); | 2218 | auth); |
2221 | if (ret) | 2219 | if (ret) |
2222 | return ERR_PTR(ret); | 2220 | return ERR_PTR(ret); |
2223 | } else if (ac->ops && ac->ops->update_authorizer) { | 2221 | } else { |
2224 | int ret = ac->ops->update_authorizer(ac, CEPH_ENTITY_TYPE_OSD, | 2222 | int ret = ceph_auth_update_authorizer(ac, CEPH_ENTITY_TYPE_OSD, |
2225 | auth); | 2223 | auth); |
2226 | if (ret) | 2224 | if (ret) |
2227 | return ERR_PTR(ret); | 2225 | return ERR_PTR(ret); |
@@ -2238,11 +2236,7 @@ static int verify_authorizer_reply(struct ceph_connection *con, int len) | |||
2238 | struct ceph_osd_client *osdc = o->o_osdc; | 2236 | struct ceph_osd_client *osdc = o->o_osdc; |
2239 | struct ceph_auth_client *ac = osdc->client->monc.auth; | 2237 | struct ceph_auth_client *ac = osdc->client->monc.auth; |
2240 | 2238 | ||
2241 | /* | 2239 | return ceph_auth_verify_authorizer_reply(ac, o->o_auth.authorizer, len); |
2242 | * XXX If ac->ops or ac->ops->verify_authorizer_reply is null, | ||
2243 | * XXX which do we do: succeed or fail? | ||
2244 | */ | ||
2245 | return ac->ops->verify_authorizer_reply(ac, o->o_auth.authorizer, len); | ||
2246 | } | 2240 | } |
2247 | 2241 | ||
2248 | static int invalidate_authorizer(struct ceph_connection *con) | 2242 | static int invalidate_authorizer(struct ceph_connection *con) |
@@ -2251,9 +2245,7 @@ static int invalidate_authorizer(struct ceph_connection *con) | |||
2251 | struct ceph_osd_client *osdc = o->o_osdc; | 2245 | struct ceph_osd_client *osdc = o->o_osdc; |
2252 | struct ceph_auth_client *ac = osdc->client->monc.auth; | 2246 | struct ceph_auth_client *ac = osdc->client->monc.auth; |
2253 | 2247 | ||
2254 | if (ac->ops && ac->ops->invalidate_authorizer) | 2248 | ceph_auth_invalidate_authorizer(ac, CEPH_ENTITY_TYPE_OSD); |
2255 | ac->ops->invalidate_authorizer(ac, CEPH_ENTITY_TYPE_OSD); | ||
2256 | |||
2257 | return ceph_monc_validate_auth(&osdc->client->monc); | 2249 | return ceph_monc_validate_auth(&osdc->client->monc); |
2258 | } | 2250 | } |
2259 | 2251 | ||