net/sunrpc/svc_xprt.c
Source file repositories/reference/linux-study-clean/net/sunrpc/svc_xprt.c
File Facts
- System
- Linux kernel
- Corpus path
net/sunrpc/svc_xprt.c- Extension
.c- Size
- 43717 bytes
- Lines
- 1595
- 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/sched.hlinux/sched/mm.hlinux/errno.hlinux/freezer.hlinux/slab.hnet/sock.hlinux/sunrpc/addr.hlinux/sunrpc/stats.hlinux/sunrpc/svc_xprt.hlinux/sunrpc/svcsock.hlinux/sunrpc/xprt.hlinux/sunrpc/bc_xprt.hlinux/module.hlinux/netdevice.htrace/events/sunrpc.h
Detected Declarations
function svc_reg_xprt_classfunction svc_unreg_xprt_classfunction svc_print_xprtsfunction svc_xprt_deferred_closefunction svc_xprt_freefunction svc_xprt_putfunction svc_xprt_initfunction svc_xprt_receivedfunction svc_add_new_perm_xprtfunction _svc_xprt_createfunction svc_xprt_create_from_safunction svc_xprt_createfunction svc_xprt_copy_addrsfunction svc_xprt_slots_in_rangefunction svc_xprt_reserve_slotfunction smp_rmbfunction svc_xprt_release_slotfunction svc_xprt_readyfunction svc_xprt_enqueuefunction svc_reservefunction free_deferredfunction svc_xprt_releasefunction svc_wake_upfunction svc_port_is_privilegedfunction svc_check_conn_limitsfunction svc_fill_pagesfunction svc_alloc_argfunction svc_thread_should_sleepfunction svc_schedule_timeoutfunction svc_thread_wait_for_workfunction svc_add_new_temp_xprtfunction svc_handle_xprtfunction svc_thread_wake_nextfunction svc_recvfunction svc_sendfunction svc_age_temp_xprtsfunction list_for_each_safefunction svc_age_temp_xprts_nowfunction call_xpt_usersfunction svc_delete_xprtfunction svc_xprt_closefunction svc_close_listfunction svc_clean_up_xprtsfunction lwq_for_each_safefunction runningfunction svc_revisitfunction svc_deferred_recvfunction svc_one_xprt_name
Annotated Snippet
if (IS_ERR(newxprt)) {
trace_svc_xprt_create_err(serv->sv_programs->pg_name,
xcl->xcl_name, sap, len,
newxprt);
module_put(xcl->xcl_owner);
return PTR_ERR(newxprt);
}
newxprt->xpt_cred = get_cred(cred);
svc_add_new_perm_xprt(serv, newxprt);
newport = svc_xprt_local_port(newxprt);
return newport;
}
err:
spin_unlock(&svc_xprt_class_lock);
/* This errno is exposed to user space. Provide a reasonable
* perror msg for a bad transport. */
return -EPROTONOSUPPORT;
}
/**
* svc_xprt_create_from_sa - Add a new listener to @serv from socket address
* @serv: target RPC service
* @xprt_name: transport class name
* @net: network namespace
* @sap: socket address pointer
* @flags: SVC_SOCK flags
* @cred: credential to bind to this transport
*
* Return local xprt port on success or %-EPROTONOSUPPORT on failure
*/
int svc_xprt_create_from_sa(struct svc_serv *serv, const char *xprt_name,
struct net *net, struct sockaddr *sap,
int flags, const struct cred *cred)
{
size_t len;
int err;
switch (sap->sa_family) {
case AF_INET:
len = sizeof(struct sockaddr_in);
break;
#if IS_ENABLED(CONFIG_IPV6)
case AF_INET6:
len = sizeof(struct sockaddr_in6);
break;
#endif
default:
return -EAFNOSUPPORT;
}
err = _svc_xprt_create(serv, xprt_name, net, sap, len, flags, cred);
if (err == -EPROTONOSUPPORT) {
request_module("svc%s", xprt_name);
err = _svc_xprt_create(serv, xprt_name, net, sap, len, flags,
cred);
}
return err;
}
EXPORT_SYMBOL_GPL(svc_xprt_create_from_sa);
/**
* svc_xprt_create - Add a new listener to @serv
* @serv: target RPC service
* @xprt_name: transport class name
* @net: network namespace
* @family: network address family
* @port: listener port
* @flags: SVC_SOCK flags
* @cred: credential to bind to this transport
*
* Return local xprt port on success or %-EPROTONOSUPPORT on failure
*/
int svc_xprt_create(struct svc_serv *serv, const char *xprt_name,
struct net *net, const int family,
const unsigned short port, int flags,
const struct cred *cred)
{
struct sockaddr_in sin = {
.sin_family = AF_INET,
.sin_addr.s_addr = htonl(INADDR_ANY),
.sin_port = htons(port),
};
#if IS_ENABLED(CONFIG_IPV6)
struct sockaddr_in6 sin6 = {
.sin6_family = AF_INET6,
.sin6_addr = IN6ADDR_ANY_INIT,
.sin6_port = htons(port),
};
#endif
Annotation
- Immediate include surface: `linux/sched.h`, `linux/sched/mm.h`, `linux/errno.h`, `linux/freezer.h`, `linux/slab.h`, `net/sock.h`, `linux/sunrpc/addr.h`, `linux/sunrpc/stats.h`.
- Detected declarations: `function svc_reg_xprt_class`, `function svc_unreg_xprt_class`, `function svc_print_xprts`, `function svc_xprt_deferred_close`, `function svc_xprt_free`, `function svc_xprt_put`, `function svc_xprt_init`, `function svc_xprt_received`, `function svc_add_new_perm_xprt`, `function _svc_xprt_create`.
- 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.