Lines Matching +full:dout +full:- +full:default +full:- +full:2
1 // SPDX-License-Identifier: GPL-2.0
26 dout("%s proto %d\n", __func__, proto); in init_protocol()
33 default: in init_protocol()
35 return -EINVAL; in init_protocol()
41 dout("%s global_id %llu\n", __func__, global_id); in ceph_auth_set_global_id()
46 if (ac->global_id && global_id != ac->global_id) in ceph_auth_set_global_id()
47 pr_err("global_id changed from %llu to %llu\n", ac->global_id, in ceph_auth_set_global_id()
50 ac->global_id = global_id; in ceph_auth_set_global_id()
64 return ERR_PTR(-ENOMEM); in ceph_auth_init()
66 mutex_init(&ac->mutex); in ceph_auth_init()
67 ac->negotiating = true; in ceph_auth_init()
69 ac->name = name; in ceph_auth_init()
71 ac->name = CEPH_AUTH_NAME_DEFAULT; in ceph_auth_init()
72 ac->key = key; in ceph_auth_init()
73 ac->preferred_mode = con_modes[0]; in ceph_auth_init()
74 ac->fallback_mode = con_modes[1]; in ceph_auth_init()
76 dout("%s name '%s' preferred_mode %d fallback_mode %d\n", __func__, in ceph_auth_init()
77 ac->name, ac->preferred_mode, ac->fallback_mode); in ceph_auth_init()
83 dout("auth_destroy %p\n", ac); in ceph_auth_destroy()
84 if (ac->ops) in ceph_auth_destroy()
85 ac->ops->destroy(ac); in ceph_auth_destroy()
94 mutex_lock(&ac->mutex); in ceph_auth_reset()
95 dout("auth_reset %p\n", ac); in ceph_auth_reset()
96 if (ac->ops && !ac->negotiating) in ceph_auth_reset()
97 ac->ops->reset(ac); in ceph_auth_reset()
98 ac->negotiating = true; in ceph_auth_reset()
99 mutex_unlock(&ac->mutex); in ceph_auth_reset()
109 if (*p + 2*sizeof(u32) + len > end) in ceph_auth_entity_name_encode()
110 return -ERANGE; in ceph_auth_entity_name_encode()
128 mutex_lock(&ac->mutex); in ceph_auth_build_hello()
129 dout("auth_build_hello\n"); in ceph_auth_build_hello()
130 monhdr->have_version = 0; in ceph_auth_build_hello()
131 monhdr->session_mon = cpu_to_le16(-1); in ceph_auth_build_hello()
132 monhdr->session_mon_tid = 0; in ceph_auth_build_hello()
147 ret = ceph_auth_entity_name_encode(ac->name, &p, end); in ceph_auth_build_hello()
151 ceph_encode_64(&p, ac->global_id); in ceph_auth_build_hello()
153 ceph_encode_32(&lenp, p - lenp - sizeof(u32)); in ceph_auth_build_hello()
154 ret = p - buf; in ceph_auth_build_hello()
156 mutex_unlock(&ac->mutex); in ceph_auth_build_hello()
160 ret = -ERANGE; in ceph_auth_build_hello()
175 ceph_encode_16_safe(&p, end, -1, e_range); in build_request()
177 ceph_encode_32_safe(&p, end, ac->protocol, e_range); in build_request()
181 ret = ac->ops->build_request(ac, p + sizeof(u32), end); in build_request()
184 ceph_auth_proto_name(ac->protocol), ret); in build_request()
187 dout(" built request %d bytes\n", ret); in build_request()
189 return p + ret - buf; in build_request()
192 return -ERANGE; in build_request()
211 int ret = -EINVAL; in ceph_handle_auth_reply()
213 mutex_lock(&ac->mutex); in ceph_handle_auth_reply()
214 dout("handle_auth_reply %p %p\n", p, end); in ceph_handle_auth_reply()
229 dout(" result %d '%.*s' gid %llu len %d\n", result, result_msg_len, in ceph_handle_auth_reply()
234 if (ac->negotiating) { in ceph_handle_auth_reply()
241 if (ac->protocol && ac->protocol != protocol) { in ceph_handle_auth_reply()
242 ac->ops->destroy(ac); in ceph_handle_auth_reply()
243 ac->protocol = 0; in ceph_handle_auth_reply()
244 ac->ops = NULL; in ceph_handle_auth_reply()
246 if (ac->protocol != protocol) { in ceph_handle_auth_reply()
255 ac->negotiating = false; in ceph_handle_auth_reply()
260 ceph_auth_proto_name(ac->protocol), result); in ceph_handle_auth_reply()
265 ret = ac->ops->handle_reply(ac, global_id, payload, payload_end, in ceph_handle_auth_reply()
267 if (ret == -EAGAIN) { in ceph_handle_auth_reply()
275 mutex_unlock(&ac->mutex); in ceph_handle_auth_reply()
280 ret = -EINVAL; in ceph_handle_auth_reply()
289 mutex_lock(&ac->mutex); in ceph_build_auth()
290 if (ac->ops->should_authenticate(ac)) in ceph_build_auth()
292 mutex_unlock(&ac->mutex); in ceph_build_auth()
300 mutex_lock(&ac->mutex); in ceph_auth_is_authenticated()
301 if (ac->ops) in ceph_auth_is_authenticated()
302 ret = ac->ops->is_authenticated(ac); in ceph_auth_is_authenticated()
303 mutex_unlock(&ac->mutex); in ceph_auth_is_authenticated()
315 mutex_lock(&ac->mutex); in __ceph_auth_get_authorizer()
316 if (force_new && auth->authorizer) { in __ceph_auth_get_authorizer()
317 ceph_auth_destroy_authorizer(auth->authorizer); in __ceph_auth_get_authorizer()
318 auth->authorizer = NULL; in __ceph_auth_get_authorizer()
320 if (!auth->authorizer) in __ceph_auth_get_authorizer()
321 ret = ac->ops->create_authorizer(ac, peer_type, auth); in __ceph_auth_get_authorizer()
322 else if (ac->ops->update_authorizer) in __ceph_auth_get_authorizer()
323 ret = ac->ops->update_authorizer(ac, peer_type, auth); in __ceph_auth_get_authorizer()
329 *proto = ac->protocol; in __ceph_auth_get_authorizer()
331 *pref_mode = ac->preferred_mode; in __ceph_auth_get_authorizer()
332 *fallb_mode = ac->fallback_mode; in __ceph_auth_get_authorizer()
336 mutex_unlock(&ac->mutex); in __ceph_auth_get_authorizer()
343 a->destroy(a); in ceph_auth_destroy_authorizer()
354 mutex_lock(&ac->mutex); in ceph_auth_add_authorizer_challenge()
355 if (ac->ops && ac->ops->add_authorizer_challenge) in ceph_auth_add_authorizer_challenge()
356 ret = ac->ops->add_authorizer_challenge(ac, a, challenge_buf, in ceph_auth_add_authorizer_challenge()
358 mutex_unlock(&ac->mutex); in ceph_auth_add_authorizer_challenge()
371 mutex_lock(&ac->mutex); in ceph_auth_verify_authorizer_reply()
372 if (ac->ops && ac->ops->verify_authorizer_reply) in ceph_auth_verify_authorizer_reply()
373 ret = ac->ops->verify_authorizer_reply(ac, a, in ceph_auth_verify_authorizer_reply()
376 mutex_unlock(&ac->mutex); in ceph_auth_verify_authorizer_reply()
383 mutex_lock(&ac->mutex); in ceph_auth_invalidate_authorizer()
384 if (ac->ops && ac->ops->invalidate_authorizer) in ceph_auth_invalidate_authorizer()
385 ac->ops->invalidate_authorizer(ac, peer_type); in ceph_auth_invalidate_authorizer()
386 mutex_unlock(&ac->mutex); in ceph_auth_invalidate_authorizer()
410 ceph_encode_32_safe(p, end, 2, e_range); in encode_con_modes()
421 return -ERANGE; in encode_con_modes()
429 int proto = ac->key ? CEPH_AUTH_CEPHX : CEPH_AUTH_NONE; in ceph_auth_get_request()
435 mutex_lock(&ac->mutex); in ceph_auth_get_request()
436 if (ac->protocol == CEPH_AUTH_UNKNOWN) { in ceph_auth_get_request()
444 WARN_ON(ac->protocol != proto); in ceph_auth_get_request()
445 ac->ops->reset(ac); in ceph_auth_get_request()
449 ceph_encode_32_safe(&p, end, ac->protocol, e_range); in ceph_auth_get_request()
450 ret = encode_con_modes(&p, end, ac->preferred_mode, ac->fallback_mode); in ceph_auth_get_request()
458 ret = ceph_auth_entity_name_encode(ac->name, &p, end); in ceph_auth_get_request()
462 ceph_encode_64_safe(&p, end, ac->global_id, e_range); in ceph_auth_get_request()
463 ceph_encode_32(&lenp, p - lenp - 4); in ceph_auth_get_request()
464 ret = p - buf; in ceph_auth_get_request()
467 mutex_unlock(&ac->mutex); in ceph_auth_get_request()
471 ret = -ERANGE; in ceph_auth_get_request()
480 mutex_lock(&ac->mutex); in ceph_auth_handle_reply_more()
481 ret = ac->ops->handle_reply(ac, 0, reply, reply + reply_len, in ceph_auth_handle_reply_more()
483 if (ret == -EAGAIN) in ceph_auth_handle_reply_more()
487 mutex_unlock(&ac->mutex); in ceph_auth_handle_reply_more()
498 mutex_lock(&ac->mutex); in ceph_auth_handle_reply_done()
499 ret = ac->ops->handle_reply(ac, global_id, reply, reply + reply_len, in ceph_auth_handle_reply_done()
502 WARN_ON(ret == -EAGAIN || ret > 0); in ceph_auth_handle_reply_done()
503 mutex_unlock(&ac->mutex); in ceph_auth_handle_reply_done()
512 mutex_lock(&ac->mutex); in ceph_auth_handle_bad_method()
513 WARN_ON(used_proto != ac->protocol); in ceph_auth_handle_bad_method()
515 if (result == -EOPNOTSUPP) { in ceph_auth_handle_bad_method()
516 if (!contains(allowed_protos, proto_cnt, ac->protocol)) { in ceph_auth_handle_bad_method()
518 ceph_auth_proto_name(ac->protocol)); in ceph_auth_handle_bad_method()
521 if (!contains(allowed_modes, mode_cnt, ac->preferred_mode) && in ceph_auth_handle_bad_method()
522 (ac->fallback_mode == CEPH_CON_MODE_UNKNOWN || in ceph_auth_handle_bad_method()
523 !contains(allowed_modes, mode_cnt, ac->fallback_mode))) { in ceph_auth_handle_bad_method()
525 ceph_con_mode_name(ac->preferred_mode)); in ceph_auth_handle_bad_method()
526 if (ac->fallback_mode == CEPH_CON_MODE_UNKNOWN) in ceph_auth_handle_bad_method()
530 ceph_con_mode_name(ac->fallback_mode)); in ceph_auth_handle_bad_method()
535 WARN_ON(result == -EOPNOTSUPP || result >= 0); in ceph_auth_handle_bad_method()
537 ceph_auth_proto_name(ac->protocol), result); in ceph_auth_handle_bad_method()
539 mutex_unlock(&ac->mutex); in ceph_auth_handle_bad_method()
543 mutex_unlock(&ac->mutex); in ceph_auth_handle_bad_method()
568 ceph_encode_32_safe(&p, end, auth->authorizer_buf_len, e_range); in ceph_auth_get_authorizer()
569 *buf_len = p - buf; in ceph_auth_get_authorizer()
573 return -ERANGE; in ceph_auth_get_authorizer()
586 ret = ceph_auth_add_authorizer_challenge(ac, auth->authorizer, in ceph_auth_handle_svc_reply_more()
592 ceph_encode_32_safe(&p, end, auth->authorizer_buf_len, e_range); in ceph_auth_handle_svc_reply_more()
593 *buf_len = p - buf; in ceph_auth_handle_svc_reply_more()
597 return -ERANGE; in ceph_auth_handle_svc_reply_more()
607 return ceph_auth_verify_authorizer_reply(ac, auth->authorizer, in ceph_auth_handle_svc_reply_done()
618 mutex_lock(&ac->mutex); in ceph_auth_handle_bad_authorizer()
619 WARN_ON(used_proto != ac->protocol); in ceph_auth_handle_bad_authorizer()
621 if (result == -EOPNOTSUPP) { in ceph_auth_handle_bad_authorizer()
622 if (!contains(allowed_protos, proto_cnt, ac->protocol)) { in ceph_auth_handle_bad_authorizer()
624 ceph_auth_proto_name(ac->protocol), in ceph_auth_handle_bad_authorizer()
628 if (!contains(allowed_modes, mode_cnt, ac->preferred_mode) && in ceph_auth_handle_bad_authorizer()
629 (ac->fallback_mode == CEPH_CON_MODE_UNKNOWN || in ceph_auth_handle_bad_authorizer()
630 !contains(allowed_modes, mode_cnt, ac->fallback_mode))) { in ceph_auth_handle_bad_authorizer()
632 ceph_con_mode_name(ac->preferred_mode), in ceph_auth_handle_bad_authorizer()
634 if (ac->fallback_mode == CEPH_CON_MODE_UNKNOWN) in ceph_auth_handle_bad_authorizer()
638 ceph_con_mode_name(ac->fallback_mode), in ceph_auth_handle_bad_authorizer()
644 WARN_ON(result == -EOPNOTSUPP || result >= 0); in ceph_auth_handle_bad_authorizer()
646 ceph_auth_proto_name(ac->protocol), in ceph_auth_handle_bad_authorizer()
649 if (ac->ops->invalidate_authorizer) in ceph_auth_handle_bad_authorizer()
650 ac->ops->invalidate_authorizer(ac, peer_type); in ceph_auth_handle_bad_authorizer()
652 mutex_unlock(&ac->mutex); in ceph_auth_handle_bad_authorizer()
656 mutex_unlock(&ac->mutex); in ceph_auth_handle_bad_authorizer()