net/sunrpc/svcauth_unix.c
Source file repositories/reference/linux-study-clean/net/sunrpc/svcauth_unix.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/svcauth_unix.c- Extension
.c- Size
- 37508 bytes
- Lines
- 1575
- 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/types.hlinux/sched.hlinux/module.hlinux/sunrpc/types.hlinux/sunrpc/xdr.hlinux/sunrpc/svcsock.hlinux/sunrpc/svcauth.hlinux/sunrpc/gss_api.hlinux/sunrpc/addr.hlinux/err.hlinux/seq_file.hlinux/hash.hlinux/string.hlinux/slab.hnet/sock.hnet/ipv6.hlinux/kernel.hlinux/user_namespace.hnet/genetlink.huapi/linux/sunrpc_netlink.htrace/events/sunrpc.hnetns.hnetlink.h
Detected Declarations
struct unix_domainstruct ip_mapstruct unix_gidfunction svcauth_unix_domain_release_rcufunction svcauth_unix_domain_releasefunction ip_map_putfunction hash_ip6function ip_map_matchfunction ip_map_initfunction updatefunction ip_map_upcallfunction ip_map_requestfunction ip_map_parsefunction ip_map_showfunction __ip_map_updatefunction svcauth_unix_purgefunction ip_map_cached_getfunction ip_map_cached_putfunction svcauth_unix_info_releasefunction unix_gid_hashfunction unix_gid_freefunction unix_gid_putfunction unix_gid_matchfunction unix_gid_initfunction unix_gid_updatefunction unix_gid_upcallfunction unix_gid_requestfunction unix_gid_parsefunction unix_gid_showfunction unix_gid_notifyfunction sunrpc_nl_unix_gid_get_reqs_dumpitfunction sunrpc_nl_parse_one_unix_gidfunction nla_for_each_nested_typefunction sunrpc_nl_unix_gid_set_reqs_doitfunction nlmsg_for_each_attr_typefunction sunrpc_nl_cache_flush_doitfunction unix_gid_cache_createfunction unix_gid_cache_destroyfunction svcauth_unix_set_clientfunction svcauth_null_acceptfunction svcauth_null_releasefunction svcauth_tls_acceptfunction svcauth_unix_acceptfunction svcauth_unix_releasefunction ip_map_notifyfunction sunrpc_nl_ip_map_get_reqs_dumpitfunction sunrpc_nl_parse_one_ip_mapfunction sunrpc_nl_ip_map_set_reqs_doit
Annotated Snippet
struct unix_domain {
struct auth_domain h;
/* other stuff later */
};
extern struct auth_ops svcauth_null;
extern struct auth_ops svcauth_unix;
extern struct auth_ops svcauth_tls;
static void svcauth_unix_domain_release_rcu(struct rcu_head *head)
{
struct auth_domain *dom = container_of(head, struct auth_domain, rcu_head);
struct unix_domain *ud = container_of(dom, struct unix_domain, h);
kfree(dom->name);
kfree(ud);
}
static void svcauth_unix_domain_release(struct auth_domain *dom)
{
call_rcu(&dom->rcu_head, svcauth_unix_domain_release_rcu);
}
struct auth_domain *unix_domain_find(char *name)
{
struct auth_domain *rv;
struct unix_domain *new = NULL;
rv = auth_domain_find(name);
while(1) {
if (rv) {
if (new && rv != &new->h)
svcauth_unix_domain_release(&new->h);
if (rv->flavour != &svcauth_unix) {
auth_domain_put(rv);
return NULL;
}
return rv;
}
new = kmalloc_obj(*new);
if (new == NULL)
return NULL;
kref_init(&new->h.ref);
new->h.name = kstrdup(name, GFP_KERNEL);
if (new->h.name == NULL) {
kfree(new);
return NULL;
}
new->h.flavour = &svcauth_unix;
rv = auth_domain_lookup(name, &new->h);
}
}
EXPORT_SYMBOL_GPL(unix_domain_find);
/**************************************************
* cache for IP address to unix_domain
* as needed by AUTH_UNIX
*/
#define IP_HASHBITS 8
#define IP_HASHMAX (1<<IP_HASHBITS)
struct ip_map {
struct cache_head h;
char m_class[8]; /* e.g. "nfsd" */
struct in6_addr m_addr;
struct unix_domain *m_client;
struct rcu_head m_rcu;
};
static void ip_map_put(struct kref *kref)
{
struct cache_head *item = container_of(kref, struct cache_head, ref);
struct ip_map *im = container_of(item, struct ip_map,h);
if (test_bit(CACHE_VALID, &item->flags) &&
!test_bit(CACHE_NEGATIVE, &item->flags))
auth_domain_put(&im->m_client->h);
kfree_rcu(im, m_rcu);
}
static inline int hash_ip6(const struct in6_addr *ip)
{
return hash_32(ipv6_addr_hash(ip), IP_HASHBITS);
}
static int ip_map_match(struct cache_head *corig, struct cache_head *cnew)
{
struct ip_map *orig = container_of(corig, struct ip_map, h);
Annotation
- Immediate include surface: `linux/types.h`, `linux/sched.h`, `linux/module.h`, `linux/sunrpc/types.h`, `linux/sunrpc/xdr.h`, `linux/sunrpc/svcsock.h`, `linux/sunrpc/svcauth.h`, `linux/sunrpc/gss_api.h`.
- Detected declarations: `struct unix_domain`, `struct ip_map`, `struct unix_gid`, `function svcauth_unix_domain_release_rcu`, `function svcauth_unix_domain_release`, `function ip_map_put`, `function hash_ip6`, `function ip_map_match`, `function ip_map_init`, `function update`.
- 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.