fs/lockd/svc.c

Source file repositories/reference/linux-study-clean/fs/lockd/svc.c

File Facts

System
Linux kernel
Corpus path
fs/lockd/svc.c
Extension
.c
Size
19216 bytes
Lines
792
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

module_init(init_nlm);
module_exit(exit_nlm);

/**
 * nlmsvc_dispatch - Process an NLM Request
 * @rqstp: incoming request
 *
 * Return values:
 *  %0: Processing complete; do not send a Reply
 *  %1: Processing complete; send Reply in rqstp->rq_res
 */
int nlmsvc_dispatch(struct svc_rqst *rqstp)
{
	const struct svc_procedure *procp = rqstp->rq_procinfo;
	__be32 *statp = rqstp->rq_accept_statp;

	if (!procp->pc_decode(rqstp, &rqstp->rq_arg_stream))
		goto out_decode_err;

	*statp = procp->pc_func(rqstp);
	if (*statp == rpc_drop_reply)
		return 0;
	if (*statp != rpc_success)
		return 1;

	if (!procp->pc_encode(rqstp, &rqstp->rq_res_stream))
		goto out_encode_err;

	return 1;

out_decode_err:
	*statp = rpc_garbage_args;
	return 1;

out_encode_err:
	*statp = rpc_system_err;
	return 1;
}

/*
 * Define NLM program and procedures
 */
static const struct svc_version *nlmsvc_version[] = {
	[1] = &nlmsvc_version1,
	[3] = &nlmsvc_version3,
#ifdef CONFIG_LOCKD_V4
	[4] = &nlmsvc_version4,
#endif
};

#define NLM_NRVERS	ARRAY_SIZE(nlmsvc_version)
static struct svc_program	nlmsvc_program = {
	.pg_prog		= NLM_PROGRAM,		/* program number */
	.pg_nvers		= NLM_NRVERS,		/* number of entries in nlmsvc_version */
	.pg_vers		= nlmsvc_version,	/* version table */
	.pg_name		= "lockd",		/* service name */
	.pg_class		= "nfsd",		/* share authentication with nfsd */
	.pg_authenticate	= &lockd_authenticate,	/* export authentication */
	.pg_init_request	= svc_generic_init_request,
	.pg_rpcbind_set		= svc_generic_rpcbind_set,
};

/**
 * lockd_nl_server_set_doit - set the lockd server parameters via netlink
 * @skb: reply buffer
 * @info: netlink metadata and command arguments
 *
 * This updates the per-net values. When updating the values in the init_net
 * namespace, also update the "legacy" global values.
 *
 * Return 0 on success or a negative errno.
 */
int lockd_nl_server_set_doit(struct sk_buff *skb, struct genl_info *info)
{
	struct net *net = genl_info_net(info);
	struct lockd_net *ln = net_generic(net, lockd_net_id);
	const struct nlattr *attr;

	if (GENL_REQ_ATTR_CHECK(info, LOCKD_A_SERVER_GRACETIME))
		return -EINVAL;

	if (info->attrs[LOCKD_A_SERVER_GRACETIME] ||
	    info->attrs[LOCKD_A_SERVER_TCP_PORT] ||
	    info->attrs[LOCKD_A_SERVER_UDP_PORT]) {
		attr = info->attrs[LOCKD_A_SERVER_GRACETIME];
		if (attr) {
			u32 gracetime = nla_get_u32(attr);

			if (gracetime > nlm_grace_period_max)
				return -EINVAL;

Annotation

Implementation Notes