Lines Matching refs:ac
23 static int ceph_auth_init_protocol(struct ceph_auth_client *ac, int protocol) in ceph_auth_init_protocol() argument
27 return ceph_auth_none_init(ac); in ceph_auth_init_protocol()
29 return ceph_x_init(ac); in ceph_auth_init_protocol()
40 struct ceph_auth_client *ac; in ceph_auth_init() local
46 ac = kzalloc(sizeof(*ac), GFP_NOFS); in ceph_auth_init()
47 if (!ac) in ceph_auth_init()
50 mutex_init(&ac->mutex); in ceph_auth_init()
51 ac->negotiating = true; in ceph_auth_init()
53 ac->name = name; in ceph_auth_init()
55 ac->name = CEPH_AUTH_NAME_DEFAULT; in ceph_auth_init()
56 dout("auth_init name %s\n", ac->name); in ceph_auth_init()
57 ac->key = key; in ceph_auth_init()
58 return ac; in ceph_auth_init()
64 void ceph_auth_destroy(struct ceph_auth_client *ac) in ceph_auth_destroy() argument
66 dout("auth_destroy %p\n", ac); in ceph_auth_destroy()
67 if (ac->ops) in ceph_auth_destroy()
68 ac->ops->destroy(ac); in ceph_auth_destroy()
69 kfree(ac); in ceph_auth_destroy()
75 void ceph_auth_reset(struct ceph_auth_client *ac) in ceph_auth_reset() argument
77 mutex_lock(&ac->mutex); in ceph_auth_reset()
78 dout("auth_reset %p\n", ac); in ceph_auth_reset()
79 if (ac->ops && !ac->negotiating) in ceph_auth_reset()
80 ac->ops->reset(ac); in ceph_auth_reset()
81 ac->negotiating = true; in ceph_auth_reset()
82 mutex_unlock(&ac->mutex); in ceph_auth_reset()
101 int ceph_auth_build_hello(struct ceph_auth_client *ac, void *buf, size_t len) in ceph_auth_build_hello() argument
108 mutex_lock(&ac->mutex); in ceph_auth_build_hello()
127 ret = ceph_entity_name_encode(ac->name, &p, end); in ceph_auth_build_hello()
131 ceph_encode_64(&p, ac->global_id); in ceph_auth_build_hello()
136 mutex_unlock(&ac->mutex); in ceph_auth_build_hello()
144 static int ceph_build_auth_request(struct ceph_auth_client *ac, in ceph_build_auth_request() argument
156 ceph_encode_32(&p, ac->protocol); in ceph_build_auth_request()
158 ret = ac->ops->build_request(ac, p + sizeof(u32), end); in ceph_build_auth_request()
161 ac->ops->name); in ceph_build_auth_request()
174 int ceph_handle_auth_reply(struct ceph_auth_client *ac, in ceph_handle_auth_reply() argument
189 mutex_lock(&ac->mutex); in ceph_handle_auth_reply()
210 if (global_id && ac->global_id != global_id) { in ceph_handle_auth_reply()
211 dout(" set global_id %lld -> %lld\n", ac->global_id, global_id); in ceph_handle_auth_reply()
212 ac->global_id = global_id; in ceph_handle_auth_reply()
215 if (ac->negotiating) { in ceph_handle_auth_reply()
222 if (ac->protocol && ac->protocol != protocol) { in ceph_handle_auth_reply()
223 ac->ops->destroy(ac); in ceph_handle_auth_reply()
224 ac->protocol = 0; in ceph_handle_auth_reply()
225 ac->ops = NULL; in ceph_handle_auth_reply()
227 if (ac->protocol != protocol) { in ceph_handle_auth_reply()
228 ret = ceph_auth_init_protocol(ac, protocol); in ceph_handle_auth_reply()
236 ac->negotiating = false; in ceph_handle_auth_reply()
239 ret = ac->ops->handle_reply(ac, result, payload, payload_end); in ceph_handle_auth_reply()
241 ret = ceph_build_auth_request(ac, reply_buf, reply_len); in ceph_handle_auth_reply()
243 pr_err("auth method '%s' error %d\n", ac->ops->name, ret); in ceph_handle_auth_reply()
247 mutex_unlock(&ac->mutex); in ceph_handle_auth_reply()
256 int ceph_build_auth(struct ceph_auth_client *ac, in ceph_build_auth() argument
261 mutex_lock(&ac->mutex); in ceph_build_auth()
262 if (!ac->protocol) in ceph_build_auth()
263 ret = ceph_auth_build_hello(ac, msg_buf, msg_len); in ceph_build_auth()
264 else if (ac->ops->should_authenticate(ac)) in ceph_build_auth()
265 ret = ceph_build_auth_request(ac, msg_buf, msg_len); in ceph_build_auth()
266 mutex_unlock(&ac->mutex); in ceph_build_auth()
270 int ceph_auth_is_authenticated(struct ceph_auth_client *ac) in ceph_auth_is_authenticated() argument
274 mutex_lock(&ac->mutex); in ceph_auth_is_authenticated()
275 if (ac->ops) in ceph_auth_is_authenticated()
276 ret = ac->ops->is_authenticated(ac); in ceph_auth_is_authenticated()
277 mutex_unlock(&ac->mutex); in ceph_auth_is_authenticated()
282 int ceph_auth_create_authorizer(struct ceph_auth_client *ac, in ceph_auth_create_authorizer() argument
288 mutex_lock(&ac->mutex); in ceph_auth_create_authorizer()
289 if (ac->ops && ac->ops->create_authorizer) in ceph_auth_create_authorizer()
290 ret = ac->ops->create_authorizer(ac, peer_type, auth); in ceph_auth_create_authorizer()
291 mutex_unlock(&ac->mutex); in ceph_auth_create_authorizer()
296 void ceph_auth_destroy_authorizer(struct ceph_auth_client *ac, in ceph_auth_destroy_authorizer() argument
299 mutex_lock(&ac->mutex); in ceph_auth_destroy_authorizer()
300 if (ac->ops && ac->ops->destroy_authorizer) in ceph_auth_destroy_authorizer()
301 ac->ops->destroy_authorizer(ac, a); in ceph_auth_destroy_authorizer()
302 mutex_unlock(&ac->mutex); in ceph_auth_destroy_authorizer()
306 int ceph_auth_update_authorizer(struct ceph_auth_client *ac, in ceph_auth_update_authorizer() argument
312 mutex_lock(&ac->mutex); in ceph_auth_update_authorizer()
313 if (ac->ops && ac->ops->update_authorizer) in ceph_auth_update_authorizer()
314 ret = ac->ops->update_authorizer(ac, peer_type, a); in ceph_auth_update_authorizer()
315 mutex_unlock(&ac->mutex); in ceph_auth_update_authorizer()
320 int ceph_auth_verify_authorizer_reply(struct ceph_auth_client *ac, in ceph_auth_verify_authorizer_reply() argument
325 mutex_lock(&ac->mutex); in ceph_auth_verify_authorizer_reply()
326 if (ac->ops && ac->ops->verify_authorizer_reply) in ceph_auth_verify_authorizer_reply()
327 ret = ac->ops->verify_authorizer_reply(ac, a, len); in ceph_auth_verify_authorizer_reply()
328 mutex_unlock(&ac->mutex); in ceph_auth_verify_authorizer_reply()
333 void ceph_auth_invalidate_authorizer(struct ceph_auth_client *ac, int peer_type) in ceph_auth_invalidate_authorizer() argument
335 mutex_lock(&ac->mutex); in ceph_auth_invalidate_authorizer()
336 if (ac->ops && ac->ops->invalidate_authorizer) in ceph_auth_invalidate_authorizer()
337 ac->ops->invalidate_authorizer(ac, peer_type); in ceph_auth_invalidate_authorizer()
338 mutex_unlock(&ac->mutex); in ceph_auth_invalidate_authorizer()