net/ceph/decode.c
Source file repositories/reference/linux-study-clean/net/ceph/decode.c
File Facts
- System
- Linux kernel
- Corpus path
net/ceph/decode.c- Extension
.c- Size
- 4744 bytes
- Lines
- 194
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ceph/ceph_debug.hlinux/inet.hlinux/ceph/decode.hlinux/ceph/messenger.h
Detected Declarations
function ceph_decode_entity_addr_versionedfunction ceph_decode_entity_addr_legacyfunction ceph_decode_entity_addrfunction typefunction get_sockaddr_encoding_lenfunction ceph_entity_addr_encoding_lenfunction ceph_encode_entity_addrexport ceph_decode_entity_addrexport ceph_decode_entity_addrvec
Annotated Snippet
if (tmp_addr.type == my_type) {
if (found) {
pr_err("another match of type %d in addrvec\n",
le32_to_cpu(my_type));
return -EINVAL;
}
memcpy(addr, &tmp_addr, sizeof(*addr));
found = true;
}
}
if (found)
return 0;
if (!addr_cnt)
return 0; /* normal -- e.g. unused OSD id/slot */
if (addr_cnt == 1 && !memchr_inv(&tmp_addr, 0, sizeof(tmp_addr)))
return 0; /* weird but effectively the same as !addr_cnt */
pr_err("no match of type %d in addrvec\n", le32_to_cpu(my_type));
return -ENOENT;
e_inval:
return -EINVAL;
}
EXPORT_SYMBOL(ceph_decode_entity_addrvec);
static int get_sockaddr_encoding_len(sa_family_t family)
{
union {
struct sockaddr sa;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
} u;
switch (family) {
case AF_INET:
return sizeof(u.sin);
case AF_INET6:
return sizeof(u.sin6);
default:
return sizeof(u);
}
}
int ceph_entity_addr_encoding_len(const struct ceph_entity_addr *addr)
{
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
int addr_len = get_sockaddr_encoding_len(family);
return 1 + CEPH_ENCODING_START_BLK_LEN + 4 + 4 + 4 + addr_len;
}
void ceph_encode_entity_addr(void **p, const struct ceph_entity_addr *addr)
{
sa_family_t family = get_unaligned(&addr->in_addr.ss_family);
int addr_len = get_sockaddr_encoding_len(family);
ceph_encode_8(p, 1); /* marker */
ceph_start_encoding(p, 1, 1, sizeof(addr->type) +
sizeof(addr->nonce) +
sizeof(u32) + addr_len);
ceph_encode_copy(p, &addr->type, sizeof(addr->type));
ceph_encode_copy(p, &addr->nonce, sizeof(addr->nonce));
ceph_encode_32(p, addr_len);
ceph_encode_16(p, family);
ceph_encode_copy(p, addr->in_addr.__data, addr_len - sizeof(family));
}
Annotation
- Immediate include surface: `linux/ceph/ceph_debug.h`, `linux/inet.h`, `linux/ceph/decode.h`, `linux/ceph/messenger.h`.
- Detected declarations: `function ceph_decode_entity_addr_versioned`, `function ceph_decode_entity_addr_legacy`, `function ceph_decode_entity_addr`, `function type`, `function get_sockaddr_encoding_len`, `function ceph_entity_addr_encoding_len`, `function ceph_encode_entity_addr`, `export ceph_decode_entity_addr`, `export ceph_decode_entity_addrvec`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
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.