net/rxrpc/server_key.c
Source file repositories/reference/linux-study-clean/net/rxrpc/server_key.c
File Facts
- System
- Linux kernel
- Corpus path
net/rxrpc/server_key.c- Extension
.c- Size
- 5870 bytes
- Lines
- 216
- 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/module.hlinux/net.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_vet_description_sfunction rxrpc_preparse_sfunction rxrpc_free_preparse_sfunction rxrpc_destroy_sfunction rxrpc_describe_sfunction rxrpc_server_keyringfunction rxrpc_sock_set_security_keyringfunction recvmsgexport rxrpc_sock_set_security_keyringexport rxrpc_sock_set_manage_response
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/* RxRPC key management
*
* Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
* Written by David Howells (dhowells@redhat.com)
*
* RxRPC keys should have a description of describing their purpose:
* "afs@CAMBRIDGE.REDHAT.COM>
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/net.h>
#include <linux/skbuff.h>
#include <linux/key-type.h>
#include <linux/ctype.h>
#include <linux/slab.h>
#include <net/sock.h>
#include <net/af_rxrpc.h>
#include <keys/rxrpc-type.h>
#include <keys/user-type.h>
#include "ar-internal.h"
static int rxrpc_vet_description_s(const char *);
static int rxrpc_preparse_s(struct key_preparsed_payload *);
static void rxrpc_free_preparse_s(struct key_preparsed_payload *);
static void rxrpc_destroy_s(struct key *);
static void rxrpc_describe_s(const struct key *, struct seq_file *);
/*
* rxrpc server keys take "<serviceId>:<securityIndex>[:<sec-specific>]" as the
* description and the key material as the payload.
*/
struct key_type key_type_rxrpc_s = {
.name = "rxrpc_s",
.flags = KEY_TYPE_NET_DOMAIN,
.vet_description = rxrpc_vet_description_s,
.preparse = rxrpc_preparse_s,
.free_preparse = rxrpc_free_preparse_s,
.instantiate = generic_key_instantiate,
.destroy = rxrpc_destroy_s,
.describe = rxrpc_describe_s,
};
/*
* Vet the description for an RxRPC server key.
*/
static int rxrpc_vet_description_s(const char *desc)
{
unsigned long service, sec_class;
char *p;
service = simple_strtoul(desc, &p, 10);
if (*p != ':' || service > 65535)
return -EINVAL;
sec_class = simple_strtoul(p + 1, &p, 10);
if ((*p && *p != ':') || sec_class < 1 || sec_class > 255)
return -EINVAL;
return 0;
}
/*
* Preparse a server secret key.
*/
static int rxrpc_preparse_s(struct key_preparsed_payload *prep)
{
const struct rxrpc_security *sec;
unsigned int service, sec_class;
int n;
_enter("%zu", prep->datalen);
if (!prep->orig_description)
return -EINVAL;
if (sscanf(prep->orig_description, "%u:%u%n", &service, &sec_class, &n) != 2)
return -EINVAL;
sec = rxrpc_security_lookup(sec_class);
if (!sec)
return -ENOPKG;
prep->payload.data[1] = (struct rxrpc_security *)sec;
if (!sec->preparse_server_key)
return -EINVAL;
return sec->preparse_server_key(prep);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/net.h`, `linux/skbuff.h`, `linux/key-type.h`, `linux/ctype.h`, `linux/slab.h`, `net/sock.h`, `net/af_rxrpc.h`.
- Detected declarations: `function rxrpc_vet_description_s`, `function rxrpc_preparse_s`, `function rxrpc_free_preparse_s`, `function rxrpc_destroy_s`, `function rxrpc_describe_s`, `function rxrpc_server_keyring`, `function rxrpc_sock_set_security_keyring`, `function recvmsg`, `export rxrpc_sock_set_security_keyring`, `export rxrpc_sock_set_manage_response`.
- 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.