net/ceph/auth.c
Source file repositories/reference/linux-study-clean/net/ceph/auth.c
File Facts
- System
- Linux kernel
- Corpus path
net/ceph/auth.c- Extension
.c- Size
- 16186 bytes
- Lines
- 662
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ceph/ceph_debug.hlinux/module.hlinux/err.hlinux/slab.hlinux/ceph/types.hlinux/ceph/decode.hlinux/ceph/libceph.hlinux/ceph/messenger.hauth_none.hauth_x.h
Detected Declarations
function init_protocolfunction ceph_auth_set_global_idfunction ceph_auth_destroyfunction ceph_auth_resetfunction ceph_auth_entity_name_encodefunction ceph_auth_build_hellofunction build_requestfunction ceph_handle_auth_replyfunction ceph_build_authfunction ceph_auth_is_authenticatedfunction __ceph_auth_get_authorizerfunction ceph_auth_destroy_authorizerfunction ceph_auth_add_authorizer_challengefunction ceph_auth_verify_authorizer_replyfunction ceph_auth_invalidate_authorizerfunction containsfunction encode_con_modesfunction ceph_auth_build_hellofunction ceph_auth_handle_reply_morefunction ceph_auth_handle_reply_donefunction ceph_auth_handle_bad_methodfunction ceph_auth_get_authorizerfunction ceph_auth_handle_svc_reply_morefunction ceph_auth_handle_svc_reply_donefunction ceph_auth_handle_bad_authorizerexport ceph_auth_is_authenticatedexport __ceph_auth_get_authorizerexport ceph_auth_destroy_authorizerexport ceph_auth_add_authorizer_challengeexport ceph_auth_verify_authorizer_replyexport ceph_auth_invalidate_authorizerexport ceph_auth_get_authorizerexport ceph_auth_handle_svc_reply_moreexport ceph_auth_handle_svc_reply_doneexport ceph_auth_handle_bad_authorizer
Annotated Snippet
if (!protocol && result < 0) {
ret = result;
goto out;
}
/* set up (new) protocol handler? */
if (ac->protocol && ac->protocol != protocol) {
ac->ops->destroy(ac);
ac->protocol = 0;
ac->ops = NULL;
}
if (!ac->protocol) {
ret = init_protocol(ac, protocol);
if (ret) {
pr_err("auth protocol '%s' init failed: %d\n",
ceph_auth_proto_name(protocol), ret);
goto out;
}
}
ac->negotiating = false;
}
if (result < 0) {
pr_err("auth protocol '%s' mauth authentication failed: %d\n",
ceph_auth_proto_name(ac->protocol), result);
ret = result;
goto out;
}
ret = ac->ops->handle_reply(ac, global_id, payload, payload_end,
NULL, NULL, NULL, NULL);
if (ret == -EAGAIN) {
ret = build_request(ac, true, reply_buf, reply_len);
goto out;
} else if (ret) {
goto out;
}
out:
mutex_unlock(&ac->mutex);
return ret;
bad:
pr_err("failed to decode auth msg\n");
ret = -EINVAL;
goto out;
}
int ceph_build_auth(struct ceph_auth_client *ac,
void *msg_buf, size_t msg_len)
{
int ret = 0;
mutex_lock(&ac->mutex);
if (ac->ops->should_authenticate(ac))
ret = build_request(ac, true, msg_buf, msg_len);
mutex_unlock(&ac->mutex);
return ret;
}
int ceph_auth_is_authenticated(struct ceph_auth_client *ac)
{
int ret = 0;
mutex_lock(&ac->mutex);
if (ac->ops)
ret = ac->ops->is_authenticated(ac);
mutex_unlock(&ac->mutex);
return ret;
}
EXPORT_SYMBOL(ceph_auth_is_authenticated);
int __ceph_auth_get_authorizer(struct ceph_auth_client *ac,
struct ceph_auth_handshake *auth,
int peer_type, bool force_new,
int *proto, int *pref_mode, int *fallb_mode)
{
int ret;
mutex_lock(&ac->mutex);
if (force_new && auth->authorizer) {
ceph_auth_destroy_authorizer(auth->authorizer);
auth->authorizer = NULL;
}
if (!auth->authorizer)
ret = ac->ops->create_authorizer(ac, peer_type, auth);
else if (ac->ops->update_authorizer)
ret = ac->ops->update_authorizer(ac, peer_type, auth);
else
ret = 0;
Annotation
- Immediate include surface: `linux/ceph/ceph_debug.h`, `linux/module.h`, `linux/err.h`, `linux/slab.h`, `linux/ceph/types.h`, `linux/ceph/decode.h`, `linux/ceph/libceph.h`, `linux/ceph/messenger.h`.
- Detected declarations: `function init_protocol`, `function ceph_auth_set_global_id`, `function ceph_auth_destroy`, `function ceph_auth_reset`, `function ceph_auth_entity_name_encode`, `function ceph_auth_build_hello`, `function build_request`, `function ceph_handle_auth_reply`, `function ceph_build_auth`, `function ceph_auth_is_authenticated`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.