net/sunrpc/sysfs.c
Source file repositories/reference/linux-study-clean/net/sunrpc/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/sysfs.c- Extension
.c- Size
- 21822 bytes
- Lines
- 833
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- 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/sunrpc/clnt.hlinux/kobject.hlinux/sunrpc/addr.hlinux/sunrpc/xprtsock.hnet/net_namespace.hsysfs.h
Detected Declarations
struct xprt_addrfunction free_xprt_addrfunction rpc_sysfs_object_releasefunction rpc_sysfs_object_child_ns_typefunction rpc_sysfs_client_kobj_get_clntfunction rpc_sysfs_xprt_kobj_get_xprtfunction rpc_sysfs_xprt_kobj_get_xprt_switchfunction rpc_sysfs_xprt_switch_kobj_get_xprtfunction rpc_sysfs_clnt_version_showfunction rpc_sysfs_clnt_program_showfunction rpc_sysfs_clnt_max_connect_showfunction rpc_sysfs_xprt_dstaddr_showfunction rpc_sysfs_xprt_srcaddr_showfunction rpc_sysfs_xprt_xprtsec_showfunction rpc_sysfs_xprt_info_showfunction rpc_sysfs_xprt_state_showfunction rpc_sysfs_xprt_del_xprt_showfunction rpc_sysfs_xprt_switch_info_showfunction rpc_sysfs_xprt_switch_add_xprt_showfunction rpc_sysfs_xprt_switch_add_xprt_storefunction rpc_sysfs_xprt_dstaddr_storefunction rpc_sysfs_xprt_state_changefunction rpc_sysfs_xprt_del_xprtfunction rpc_sysfs_initfunction rpc_sysfs_client_releasefunction rpc_sysfs_xprt_switch_releasefunction rpc_sysfs_xprt_releasefunction rpc_sysfs_exitfunction rpc_sysfs_xprt_switch_allocfunction rpc_sysfs_client_setupfunction rpc_sysfs_xprt_switch_setupfunction rpc_sysfs_xprt_setupfunction rpc_sysfs_client_destroyfunction rpc_sysfs_xprt_switch_destroyfunction rpc_sysfs_xprt_destroy
Annotated Snippet
struct xprt_addr {
const char *addr;
struct rcu_head rcu;
};
static void free_xprt_addr(struct rcu_head *head)
{
struct xprt_addr *addr = container_of(head, struct xprt_addr, rcu);
kfree(addr->addr);
kfree(addr);
}
static struct kset *rpc_sunrpc_kset;
static struct kobject *rpc_sunrpc_client_kobj, *rpc_sunrpc_xprt_switch_kobj;
static void rpc_sysfs_object_release(struct kobject *kobj)
{
kfree(kobj);
}
static const struct kobj_ns_type_operations *
rpc_sysfs_object_child_ns_type(const struct kobject *kobj)
{
return &net_ns_type_operations;
}
static const struct kobj_type rpc_sysfs_object_type = {
.release = rpc_sysfs_object_release,
.sysfs_ops = &kobj_sysfs_ops,
.child_ns_type = rpc_sysfs_object_child_ns_type,
};
static struct kobject *rpc_sysfs_object_alloc(const char *name,
struct kset *kset,
struct kobject *parent)
{
struct kobject *kobj;
kobj = kzalloc_obj(*kobj);
if (kobj) {
kobj->kset = kset;
if (kobject_init_and_add(kobj, &rpc_sysfs_object_type,
parent, "%s", name) == 0)
return kobj;
kobject_put(kobj);
}
return NULL;
}
static inline struct rpc_clnt *
rpc_sysfs_client_kobj_get_clnt(struct kobject *kobj)
{
struct rpc_sysfs_client *c = container_of(kobj,
struct rpc_sysfs_client, kobject);
struct rpc_clnt *ret = c->clnt;
return refcount_inc_not_zero(&ret->cl_count) ? ret : NULL;
}
static inline struct rpc_xprt *
rpc_sysfs_xprt_kobj_get_xprt(struct kobject *kobj)
{
struct rpc_sysfs_xprt *x = container_of(kobj,
struct rpc_sysfs_xprt, kobject);
return xprt_get(x->xprt);
}
static inline struct rpc_xprt_switch *
rpc_sysfs_xprt_kobj_get_xprt_switch(struct kobject *kobj)
{
struct rpc_sysfs_xprt *x = container_of(kobj,
struct rpc_sysfs_xprt, kobject);
return xprt_switch_get(x->xprt_switch);
}
static inline struct rpc_xprt_switch *
rpc_sysfs_xprt_switch_kobj_get_xprt(struct kobject *kobj)
{
struct rpc_sysfs_xprt_switch *x = container_of(kobj,
struct rpc_sysfs_xprt_switch, kobject);
return xprt_switch_get(x->xprt_switch);
}
static ssize_t rpc_sysfs_clnt_version_show(struct kobject *kobj,
struct kobj_attribute *attr,
char *buf)
Annotation
- Immediate include surface: `linux/sunrpc/clnt.h`, `linux/kobject.h`, `linux/sunrpc/addr.h`, `linux/sunrpc/xprtsock.h`, `net/net_namespace.h`, `sysfs.h`.
- Detected declarations: `struct xprt_addr`, `function free_xprt_addr`, `function rpc_sysfs_object_release`, `function rpc_sysfs_object_child_ns_type`, `function rpc_sysfs_client_kobj_get_clnt`, `function rpc_sysfs_xprt_kobj_get_xprt`, `function rpc_sysfs_xprt_kobj_get_xprt_switch`, `function rpc_sysfs_xprt_switch_kobj_get_xprt`, `function rpc_sysfs_clnt_version_show`, `function rpc_sysfs_clnt_program_show`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.