xref: /linux/fs/nfsd/netlink.c (revision ca220141fa8ebae09765a242076b2b77338106b0)
1 // SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2 /* Do not edit directly, auto-generated from: */
3 /*	Documentation/netlink/specs/nfsd.yaml */
4 /* YNL-GEN kernel source */
5 /* To regenerate run: tools/net/ynl/ynl-regen.sh */
6 
7 #include <net/netlink.h>
8 #include <net/genetlink.h>
9 
10 #include "netlink.h"
11 
12 #include <uapi/linux/nfsd_netlink.h>
13 
14 /* Common nested types */
15 const struct nla_policy nfsd_sock_nl_policy[NFSD_A_SOCK_TRANSPORT_NAME + 1] = {
16 	[NFSD_A_SOCK_ADDR] = { .type = NLA_BINARY, },
17 	[NFSD_A_SOCK_TRANSPORT_NAME] = { .type = NLA_NUL_STRING, },
18 };
19 
20 const struct nla_policy nfsd_version_nl_policy[NFSD_A_VERSION_ENABLED + 1] = {
21 	[NFSD_A_VERSION_MAJOR] = { .type = NLA_U32, },
22 	[NFSD_A_VERSION_MINOR] = { .type = NLA_U32, },
23 	[NFSD_A_VERSION_ENABLED] = { .type = NLA_FLAG, },
24 };
25 
26 /* NFSD_CMD_THREADS_SET - do */
27 static const struct nla_policy nfsd_threads_set_nl_policy[NFSD_A_SERVER_MIN_THREADS + 1] = {
28 	[NFSD_A_SERVER_THREADS] = { .type = NLA_U32, },
29 	[NFSD_A_SERVER_GRACETIME] = { .type = NLA_U32, },
30 	[NFSD_A_SERVER_LEASETIME] = { .type = NLA_U32, },
31 	[NFSD_A_SERVER_SCOPE] = { .type = NLA_NUL_STRING, },
32 	[NFSD_A_SERVER_MIN_THREADS] = { .type = NLA_U32, },
33 };
34 
35 /* NFSD_CMD_VERSION_SET - do */
36 static const struct nla_policy nfsd_version_set_nl_policy[NFSD_A_SERVER_PROTO_VERSION + 1] = {
37 	[NFSD_A_SERVER_PROTO_VERSION] = NLA_POLICY_NESTED(nfsd_version_nl_policy),
38 };
39 
40 /* NFSD_CMD_LISTENER_SET - do */
41 static const struct nla_policy nfsd_listener_set_nl_policy[NFSD_A_SERVER_SOCK_ADDR + 1] = {
42 	[NFSD_A_SERVER_SOCK_ADDR] = NLA_POLICY_NESTED(nfsd_sock_nl_policy),
43 };
44 
45 /* NFSD_CMD_POOL_MODE_SET - do */
46 static const struct nla_policy nfsd_pool_mode_set_nl_policy[NFSD_A_POOL_MODE_MODE + 1] = {
47 	[NFSD_A_POOL_MODE_MODE] = { .type = NLA_NUL_STRING, },
48 };
49 
50 /* Ops table for nfsd */
51 static const struct genl_split_ops nfsd_nl_ops[] = {
52 	{
53 		.cmd	= NFSD_CMD_RPC_STATUS_GET,
54 		.dumpit	= nfsd_nl_rpc_status_get_dumpit,
55 		.flags	= GENL_CMD_CAP_DUMP,
56 	},
57 	{
58 		.cmd		= NFSD_CMD_THREADS_SET,
59 		.doit		= nfsd_nl_threads_set_doit,
60 		.policy		= nfsd_threads_set_nl_policy,
61 		.maxattr	= NFSD_A_SERVER_MIN_THREADS,
62 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
63 	},
64 	{
65 		.cmd	= NFSD_CMD_THREADS_GET,
66 		.doit	= nfsd_nl_threads_get_doit,
67 		.flags	= GENL_CMD_CAP_DO,
68 	},
69 	{
70 		.cmd		= NFSD_CMD_VERSION_SET,
71 		.doit		= nfsd_nl_version_set_doit,
72 		.policy		= nfsd_version_set_nl_policy,
73 		.maxattr	= NFSD_A_SERVER_PROTO_VERSION,
74 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
75 	},
76 	{
77 		.cmd	= NFSD_CMD_VERSION_GET,
78 		.doit	= nfsd_nl_version_get_doit,
79 		.flags	= GENL_CMD_CAP_DO,
80 	},
81 	{
82 		.cmd		= NFSD_CMD_LISTENER_SET,
83 		.doit		= nfsd_nl_listener_set_doit,
84 		.policy		= nfsd_listener_set_nl_policy,
85 		.maxattr	= NFSD_A_SERVER_SOCK_ADDR,
86 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
87 	},
88 	{
89 		.cmd	= NFSD_CMD_LISTENER_GET,
90 		.doit	= nfsd_nl_listener_get_doit,
91 		.flags	= GENL_CMD_CAP_DO,
92 	},
93 	{
94 		.cmd		= NFSD_CMD_POOL_MODE_SET,
95 		.doit		= nfsd_nl_pool_mode_set_doit,
96 		.policy		= nfsd_pool_mode_set_nl_policy,
97 		.maxattr	= NFSD_A_POOL_MODE_MODE,
98 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
99 	},
100 	{
101 		.cmd	= NFSD_CMD_POOL_MODE_GET,
102 		.doit	= nfsd_nl_pool_mode_get_doit,
103 		.flags	= GENL_CMD_CAP_DO,
104 	},
105 };
106 
107 struct genl_family nfsd_nl_family __ro_after_init = {
108 	.name		= NFSD_FAMILY_NAME,
109 	.version	= NFSD_FAMILY_VERSION,
110 	.netnsok	= true,
111 	.parallel_ops	= true,
112 	.module		= THIS_MODULE,
113 	.split_ops	= nfsd_nl_ops,
114 	.n_split_ops	= ARRAY_SIZE(nfsd_nl_ops),
115 };
116