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