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()
104 int ceph_auth_build_hello(struct ceph_auth_client *ac, void *buf, size_t len) in ceph_auth_build_hello() argument
111 mutex_lock(&ac->mutex); in ceph_auth_build_hello()
130 ret = ceph_auth_entity_name_encode(ac->name, &p, end); in ceph_auth_build_hello()
134 ceph_encode_64(&p, ac->global_id); in ceph_auth_build_hello()
139 mutex_unlock(&ac->mutex); in ceph_auth_build_hello()
147 static int ceph_build_auth_request(struct ceph_auth_client *ac, in ceph_build_auth_request() argument
159 ceph_encode_32(&p, ac->protocol); in ceph_build_auth_request()
161 ret = ac->ops->build_request(ac, p + sizeof(u32), end); in ceph_build_auth_request()
164 ac->ops->name); in ceph_build_auth_request()
177 int ceph_handle_auth_reply(struct ceph_auth_client *ac, in ceph_handle_auth_reply() argument
192 mutex_lock(&ac->mutex); in ceph_handle_auth_reply()
213 if (global_id && ac->global_id != global_id) { in ceph_handle_auth_reply()
214 dout(" set global_id %lld -> %lld\n", ac->global_id, global_id); in ceph_handle_auth_reply()
215 ac->global_id = global_id; in ceph_handle_auth_reply()
218 if (ac->negotiating) { in ceph_handle_auth_reply()
225 if (ac->protocol && ac->protocol != protocol) { in ceph_handle_auth_reply()
226 ac->ops->destroy(ac); in ceph_handle_auth_reply()
227 ac->protocol = 0; in ceph_handle_auth_reply()
228 ac->ops = NULL; in ceph_handle_auth_reply()
230 if (ac->protocol != protocol) { in ceph_handle_auth_reply()
231 ret = ceph_auth_init_protocol(ac, protocol); in ceph_handle_auth_reply()
239 ac->negotiating = false; in ceph_handle_auth_reply()
242 ret = ac->ops->handle_reply(ac, result, payload, payload_end); in ceph_handle_auth_reply()
244 ret = ceph_build_auth_request(ac, reply_buf, reply_len); in ceph_handle_auth_reply()
246 pr_err("auth method '%s' error %d\n", ac->ops->name, ret); in ceph_handle_auth_reply()
250 mutex_unlock(&ac->mutex); in ceph_handle_auth_reply()
259 int ceph_build_auth(struct ceph_auth_client *ac, in ceph_build_auth() argument
264 mutex_lock(&ac->mutex); in ceph_build_auth()
265 if (ac->ops->should_authenticate(ac)) in ceph_build_auth()
266 ret = ceph_build_auth_request(ac, msg_buf, msg_len); in ceph_build_auth()
267 mutex_unlock(&ac->mutex); in ceph_build_auth()
271 int ceph_auth_is_authenticated(struct ceph_auth_client *ac) in ceph_auth_is_authenticated() argument
275 mutex_lock(&ac->mutex); in ceph_auth_is_authenticated()
276 if (ac->ops) in ceph_auth_is_authenticated()
277 ret = ac->ops->is_authenticated(ac); in ceph_auth_is_authenticated()
278 mutex_unlock(&ac->mutex); in ceph_auth_is_authenticated()
283 int ceph_auth_create_authorizer(struct ceph_auth_client *ac, in ceph_auth_create_authorizer() argument
289 mutex_lock(&ac->mutex); in ceph_auth_create_authorizer()
290 if (ac->ops && ac->ops->create_authorizer) in ceph_auth_create_authorizer()
291 ret = ac->ops->create_authorizer(ac, peer_type, auth); in ceph_auth_create_authorizer()
292 mutex_unlock(&ac->mutex); in ceph_auth_create_authorizer()
303 int ceph_auth_update_authorizer(struct ceph_auth_client *ac, in ceph_auth_update_authorizer() argument
309 mutex_lock(&ac->mutex); in ceph_auth_update_authorizer()
310 if (ac->ops && ac->ops->update_authorizer) in ceph_auth_update_authorizer()
311 ret = ac->ops->update_authorizer(ac, peer_type, a); in ceph_auth_update_authorizer()
312 mutex_unlock(&ac->mutex); in ceph_auth_update_authorizer()
317 int ceph_auth_verify_authorizer_reply(struct ceph_auth_client *ac, in ceph_auth_verify_authorizer_reply() argument
322 mutex_lock(&ac->mutex); in ceph_auth_verify_authorizer_reply()
323 if (ac->ops && ac->ops->verify_authorizer_reply) in ceph_auth_verify_authorizer_reply()
324 ret = ac->ops->verify_authorizer_reply(ac, a, len); in ceph_auth_verify_authorizer_reply()
325 mutex_unlock(&ac->mutex); in ceph_auth_verify_authorizer_reply()
330 void ceph_auth_invalidate_authorizer(struct ceph_auth_client *ac, int peer_type) in ceph_auth_invalidate_authorizer() argument
332 mutex_lock(&ac->mutex); in ceph_auth_invalidate_authorizer()
333 if (ac->ops && ac->ops->invalidate_authorizer) in ceph_auth_invalidate_authorizer()
334 ac->ops->invalidate_authorizer(ac, peer_type); in ceph_auth_invalidate_authorizer()
335 mutex_unlock(&ac->mutex); in ceph_auth_invalidate_authorizer()