net/rxrpc/key.c
Source file repositories/reference/linux-study-clean/net/rxrpc/key.c
File Facts
- System
- Linux kernel
- Corpus path
net/rxrpc/key.c- Extension
.c- Size
- 21965 bytes
- Lines
- 896
- 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.
- 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/module.hlinux/net.hlinux/overflow.hlinux/skbuff.hlinux/key-type.hlinux/ctype.hlinux/slab.hnet/sock.hnet/af_rxrpc.hkeys/rxrpc-type.hkeys/user-type.har-internal.h
Detected Declarations
function rxrpc_preparse_xdr_rxkadfunction xdr_dec64function rxrpc_s64_to_time64function rxrpc_preparse_xdr_yfs_rxgkfunction rxrpc_preparse_xdrfunction indexfunction rxrpc_free_token_listfunction rxrpc_free_preparsefunction rxrpc_destroyfunction rxrpc_describefunction rxrpc_request_keyfunction rxrpc_get_server_data_keyfunction rxrpc_readexport key_type_rxrpcexport rxrpc_get_server_data_keyexport rxrpc_get_null_key
Annotated Snippet
switch (sec_ix) {
case RXRPC_SECURITY_RXKAD:
ret2 = rxrpc_preparse_xdr_rxkad(prep, datalen, token, toklen);
break;
case RXRPC_SECURITY_YFS_RXGK:
ret2 = rxrpc_preparse_xdr_yfs_rxgk(prep, datalen, token, toklen);
break;
default:
ret2 = -EPROTONOSUPPORT;
break;
}
switch (ret2) {
case 0:
ret = 0;
break;
case -EPROTONOSUPPORT:
break;
case -ENOPKG:
if (ret != 0)
ret = -ENOPKG;
break;
default:
ret = ret2;
goto error;
}
} while (--ntoken > 0);
error:
_leave(" = %d", ret);
return ret;
not_xdr:
_leave(" = -EPROTO");
return -EPROTO;
}
/*
* Preparse an rxrpc defined key.
*
* Data should be of the form:
* OFFSET LEN CONTENT
* 0 4 key interface version number
* 4 2 security index (type)
* 6 2 ticket length
* 8 4 key expiry time (time_t)
* 12 4 kvno
* 16 8 session key
* 24 [len] ticket
*
* if no data is provided, then a no-security key is made
*/
static int rxrpc_preparse(struct key_preparsed_payload *prep)
{
const struct rxrpc_key_data_v1 *v1;
struct rxrpc_key_token *token, **pp;
time64_t expiry;
size_t plen;
u32 kver;
int ret;
_enter("%zu", prep->datalen);
/* handle a no-security key */
if (!prep->data && prep->datalen == 0)
return 0;
/* determine if the XDR payload format is being used */
if (prep->datalen > 7 * 4) {
ret = rxrpc_preparse_xdr(prep);
if (ret != -EPROTO)
return ret;
}
/* get the key interface version number */
ret = -EINVAL;
if (prep->datalen <= 4 || !prep->data)
goto error;
memcpy(&kver, prep->data, sizeof(kver));
prep->data += sizeof(kver);
prep->datalen -= sizeof(kver);
prep->quotalen = 0;
_debug("KEY I/F VERSION: %u", kver);
ret = -EKEYREJECTED;
if (kver != 1)
goto error;
Annotation
- Immediate include surface: `linux/module.h`, `linux/net.h`, `linux/overflow.h`, `linux/skbuff.h`, `linux/key-type.h`, `linux/ctype.h`, `linux/slab.h`, `net/sock.h`.
- Detected declarations: `function rxrpc_preparse_xdr_rxkad`, `function xdr_dec64`, `function rxrpc_s64_to_time64`, `function rxrpc_preparse_xdr_yfs_rxgk`, `function rxrpc_preparse_xdr`, `function index`, `function rxrpc_free_token_list`, `function rxrpc_free_preparse`, `function rxrpc_destroy`, `function rxrpc_describe`.
- 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.