123
127
ret = ceph_entity_name_encode(ac->name, &p, end);
126
130
ceph_decode_need(&p, end, sizeof(u64), bad);
127
131
ceph_encode_64(&p, ac->global_id);
129
133
ceph_encode_32(&lenp, p - lenp - sizeof(u32));
136
mutex_unlock(&ac->mutex);
136
144
static int ceph_build_auth_request(struct ceph_auth_client *ac,
228
239
ret = ac->ops->handle_reply(ac, result, payload, payload_end);
229
240
if (ret == -EAGAIN) {
230
return ceph_build_auth_request(ac, reply_buf, reply_len);
241
ret = ceph_build_auth_request(ac, reply_buf, reply_len);
231
242
} else if (ret) {
232
243
pr_err("auth method '%s' error %d\n", ac->ops->name, ret);
247
mutex_unlock(&ac->mutex);
238
251
pr_err("failed to decode auth msg\n");
243
256
int ceph_build_auth(struct ceph_auth_client *ac,
244
257
void *msg_buf, size_t msg_len)
261
mutex_lock(&ac->mutex);
246
262
if (!ac->protocol)
247
return ceph_auth_build_hello(ac, msg_buf, msg_len);
249
if (ac->ops->should_authenticate(ac))
250
return ceph_build_auth_request(ac, msg_buf, msg_len);
263
ret = ceph_auth_build_hello(ac, msg_buf, msg_len);
264
else if (ac->ops->should_authenticate(ac))
265
ret = ceph_build_auth_request(ac, msg_buf, msg_len);
266
mutex_unlock(&ac->mutex);
254
270
int ceph_auth_is_authenticated(struct ceph_auth_client *ac)
258
return ac->ops->is_authenticated(ac);
274
mutex_lock(&ac->mutex);
276
ret = ac->ops->is_authenticated(ac);
277
mutex_unlock(&ac->mutex);
280
EXPORT_SYMBOL(ceph_auth_is_authenticated);
282
int ceph_auth_create_authorizer(struct ceph_auth_client *ac,
284
struct ceph_auth_handshake *auth)
288
mutex_lock(&ac->mutex);
289
if (ac->ops && ac->ops->create_authorizer)
290
ret = ac->ops->create_authorizer(ac, peer_type, auth);
291
mutex_unlock(&ac->mutex);
294
EXPORT_SYMBOL(ceph_auth_create_authorizer);
296
void ceph_auth_destroy_authorizer(struct ceph_auth_client *ac,
297
struct ceph_authorizer *a)
299
mutex_lock(&ac->mutex);
300
if (ac->ops && ac->ops->destroy_authorizer)
301
ac->ops->destroy_authorizer(ac, a);
302
mutex_unlock(&ac->mutex);
304
EXPORT_SYMBOL(ceph_auth_destroy_authorizer);
306
int ceph_auth_update_authorizer(struct ceph_auth_client *ac,
308
struct ceph_auth_handshake *a)
312
mutex_lock(&ac->mutex);
313
if (ac->ops && ac->ops->update_authorizer)
314
ret = ac->ops->update_authorizer(ac, peer_type, a);
315
mutex_unlock(&ac->mutex);
318
EXPORT_SYMBOL(ceph_auth_update_authorizer);
320
int ceph_auth_verify_authorizer_reply(struct ceph_auth_client *ac,
321
struct ceph_authorizer *a, size_t len)
325
mutex_lock(&ac->mutex);
326
if (ac->ops && ac->ops->verify_authorizer_reply)
327
ret = ac->ops->verify_authorizer_reply(ac, a, len);
328
mutex_unlock(&ac->mutex);
331
EXPORT_SYMBOL(ceph_auth_verify_authorizer_reply);
333
void ceph_auth_invalidate_authorizer(struct ceph_auth_client *ac, int peer_type)
335
mutex_lock(&ac->mutex);
336
if (ac->ops && ac->ops->invalidate_authorizer)
337
ac->ops->invalidate_authorizer(ac, peer_type);
338
mutex_unlock(&ac->mutex);
340
EXPORT_SYMBOL(ceph_auth_invalidate_authorizer);