xref: /linux/net/sunrpc/netlink.c (revision bba2c3615bd6cfee7456d1130f2e6b01b3f4e9ba)
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/sunrpc_cache.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/sunrpc_netlink.h>
13 
14 /* Common nested types */
15 const struct nla_policy sunrpc_ip_map_nl_policy[SUNRPC_A_IP_MAP_EXPIRY + 1] = {
16 	[SUNRPC_A_IP_MAP_SEQNO] = { .type = NLA_U64, },
17 	[SUNRPC_A_IP_MAP_CLASS] = { .type = NLA_NUL_STRING, },
18 	[SUNRPC_A_IP_MAP_ADDR] = { .type = NLA_NUL_STRING, },
19 	[SUNRPC_A_IP_MAP_DOMAIN] = { .type = NLA_NUL_STRING, },
20 	[SUNRPC_A_IP_MAP_NEGATIVE] = { .type = NLA_FLAG, },
21 	[SUNRPC_A_IP_MAP_EXPIRY] = { .type = NLA_U64, },
22 };
23 
24 const struct nla_policy sunrpc_unix_gid_nl_policy[SUNRPC_A_UNIX_GID_EXPIRY + 1] = {
25 	[SUNRPC_A_UNIX_GID_SEQNO] = { .type = NLA_U64, },
26 	[SUNRPC_A_UNIX_GID_UID] = { .type = NLA_U32, },
27 	[SUNRPC_A_UNIX_GID_GIDS] = { .type = NLA_U32, },
28 	[SUNRPC_A_UNIX_GID_NEGATIVE] = { .type = NLA_FLAG, },
29 	[SUNRPC_A_UNIX_GID_EXPIRY] = { .type = NLA_U64, },
30 };
31 
32 /* SUNRPC_CMD_IP_MAP_SET_REQS - do */
33 static const struct nla_policy sunrpc_ip_map_set_reqs_nl_policy[SUNRPC_A_IP_MAP_REQS_REQUESTS + 1] = {
34 	[SUNRPC_A_IP_MAP_REQS_REQUESTS] = NLA_POLICY_NESTED(sunrpc_ip_map_nl_policy),
35 };
36 
37 /* SUNRPC_CMD_UNIX_GID_SET_REQS - do */
38 static const struct nla_policy sunrpc_unix_gid_set_reqs_nl_policy[SUNRPC_A_UNIX_GID_REQS_REQUESTS + 1] = {
39 	[SUNRPC_A_UNIX_GID_REQS_REQUESTS] = NLA_POLICY_NESTED(sunrpc_unix_gid_nl_policy),
40 };
41 
42 /* SUNRPC_CMD_CACHE_FLUSH - do */
43 static const struct nla_policy sunrpc_cache_flush_nl_policy[SUNRPC_A_CACHE_FLUSH_MASK + 1] = {
44 	[SUNRPC_A_CACHE_FLUSH_MASK] = NLA_POLICY_MASK(NLA_U32, 0x3),
45 };
46 
47 /* Ops table for sunrpc */
48 static const struct genl_split_ops sunrpc_nl_ops[] = {
49 	{
50 		.cmd	= SUNRPC_CMD_IP_MAP_GET_REQS,
51 		.dumpit	= sunrpc_nl_ip_map_get_reqs_dumpit,
52 		.flags	= GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
53 	},
54 	{
55 		.cmd		= SUNRPC_CMD_IP_MAP_SET_REQS,
56 		.doit		= sunrpc_nl_ip_map_set_reqs_doit,
57 		.policy		= sunrpc_ip_map_set_reqs_nl_policy,
58 		.maxattr	= SUNRPC_A_IP_MAP_REQS_REQUESTS,
59 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
60 	},
61 	{
62 		.cmd	= SUNRPC_CMD_UNIX_GID_GET_REQS,
63 		.dumpit	= sunrpc_nl_unix_gid_get_reqs_dumpit,
64 		.flags	= GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
65 	},
66 	{
67 		.cmd		= SUNRPC_CMD_UNIX_GID_SET_REQS,
68 		.doit		= sunrpc_nl_unix_gid_set_reqs_doit,
69 		.policy		= sunrpc_unix_gid_set_reqs_nl_policy,
70 		.maxattr	= SUNRPC_A_UNIX_GID_REQS_REQUESTS,
71 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
72 	},
73 	{
74 		.cmd		= SUNRPC_CMD_CACHE_FLUSH,
75 		.doit		= sunrpc_nl_cache_flush_doit,
76 		.policy		= sunrpc_cache_flush_nl_policy,
77 		.maxattr	= SUNRPC_A_CACHE_FLUSH_MASK,
78 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
79 	},
80 };
81 
82 static const struct genl_multicast_group sunrpc_nl_mcgrps[] = {
83 	[SUNRPC_NLGRP_NONE] = { "none", },
84 	[SUNRPC_NLGRP_EXPORTD] = { "exportd", },
85 };
86 
87 struct genl_family sunrpc_nl_family __ro_after_init = {
88 	.name		= SUNRPC_FAMILY_NAME,
89 	.version	= SUNRPC_FAMILY_VERSION,
90 	.netnsok	= true,
91 	.parallel_ops	= true,
92 	.module		= THIS_MODULE,
93 	.split_ops	= sunrpc_nl_ops,
94 	.n_split_ops	= ARRAY_SIZE(sunrpc_nl_ops),
95 	.mcgrps		= sunrpc_nl_mcgrps,
96 	.n_mcgrps	= ARRAY_SIZE(sunrpc_nl_mcgrps),
97 };
98