Skip to content

Commit f14122b

Browse files
committed
tools: ynl: Add source files for nfsd netlink protocol
Signed-off-by: Chuck Lever <[email protected]>
1 parent bd9d6a3 commit f14122b

File tree

4 files changed

+130
-1
lines changed

4 files changed

+130
-1
lines changed

tools/net/ynl/Makefile.deps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ CFLAGS_devlink:=$(call get_hdr_inc,_LINUX_DEVLINK_H_,devlink.h)
1818
CFLAGS_ethtool:=$(call get_hdr_inc,_LINUX_ETHTOOL_NETLINK_H_,ethtool_netlink.h)
1919
CFLAGS_handshake:=$(call get_hdr_inc,_LINUX_HANDSHAKE_H,handshake.h)
2020
CFLAGS_netdev:=$(call get_hdr_inc,_LINUX_NETDEV_H,netdev.h)
21+
CFLAGS_nfsd:=$(call get_hdr_inc,_LINUX_NFSD_H,nfsd.h)

tools/net/ynl/generated/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ YNL_GEN_ARG_ethtool:=--user-header linux/ethtool_netlink.h \
1414

1515
TOOL:=../ynl-gen-c.py
1616

17-
GENS:=ethtool devlink handshake fou netdev
17+
GENS:=ethtool devlink handshake fou netdev nfsd
1818
SRCS=$(patsubst %,%-user.c,${GENS})
1919
HDRS=$(patsubst %,%-user.h,${GENS})
2020
OBJS=$(patsubst %,%-user.o,${GENS})

tools/net/ynl/generated/nfsd-user.c

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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 user source */
5+
6+
#include <stdlib.h>
7+
#include <string.h>
8+
#include "nfsd-user.h"
9+
#include "ynl.h"
10+
#include <linux/nfsd_netlink.h>
11+
12+
#include <libmnl/libmnl.h>
13+
#include <linux/genetlink.h>
14+
15+
/* Enums */
16+
static const char * const nfsd_op_strmap[] = {
17+
[NFSD_CMD_RPC_STATUS_GET] = "rpc-status-get",
18+
};
19+
20+
const char *nfsd_op_str(int op)
21+
{
22+
if (op < 0 || op >= (int)MNL_ARRAY_SIZE(nfsd_op_strmap))
23+
return NULL;
24+
return nfsd_op_strmap[op];
25+
}
26+
27+
/* Policies */
28+
struct ynl_policy_attr nfsd_rpc_status_policy[NFSD_A_RPC_STATUS_MAX + 1] = {
29+
[NFSD_A_RPC_STATUS_XID] = { .name = "xid", .type = YNL_PT_U32, },
30+
[NFSD_A_RPC_STATUS_FLAGS] = { .name = "flags", .type = YNL_PT_U32, },
31+
[NFSD_A_RPC_STATUS_PROG] = { .name = "prog", .type = YNL_PT_U32, },
32+
[NFSD_A_RPC_STATUS_VERSION] = { .name = "version", .type = YNL_PT_U8, },
33+
[NFSD_A_RPC_STATUS_PROC] = { .name = "proc", .type = YNL_PT_U32, },
34+
[NFSD_A_RPC_STATUS_SERVICE_TIME] = { .name = "service_time", .type = YNL_PT_U64, },
35+
[NFSD_A_RPC_STATUS_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, },
36+
[NFSD_A_RPC_STATUS_SADDR4] = { .name = "saddr4", .type = YNL_PT_U32, },
37+
[NFSD_A_RPC_STATUS_DADDR4] = { .name = "daddr4", .type = YNL_PT_U32, },
38+
[NFSD_A_RPC_STATUS_SADDR6] = { .name = "saddr6", .type = YNL_PT_BINARY,},
39+
[NFSD_A_RPC_STATUS_DADDR6] = { .name = "daddr6", .type = YNL_PT_BINARY,},
40+
[NFSD_A_RPC_STATUS_SPORT] = { .name = "sport", .type = YNL_PT_U16, },
41+
[NFSD_A_RPC_STATUS_DPORT] = { .name = "dport", .type = YNL_PT_U16, },
42+
[NFSD_A_RPC_STATUS_COMPOUND_OPS] = { .name = "compound-ops", .type = YNL_PT_U32, },
43+
};
44+
45+
struct ynl_policy_nest nfsd_rpc_status_nest = {
46+
.max_attr = NFSD_A_RPC_STATUS_MAX,
47+
.table = nfsd_rpc_status_policy,
48+
};
49+
50+
/* Common nested types */
51+
/* ============== NFSD_CMD_RPC_STATUS_GET ============== */
52+
/* NFSD_CMD_RPC_STATUS_GET - dump */
53+
void nfsd_rpc_status_get_list_free(struct nfsd_rpc_status_get_list *rsp)
54+
{
55+
struct nfsd_rpc_status_get_list *next = rsp;
56+
57+
while ((void *)next != YNL_LIST_END) {
58+
rsp = next;
59+
next = rsp->next;
60+
61+
free(rsp->obj.saddr6);
62+
free(rsp->obj.daddr6);
63+
free(rsp->obj.compound_ops);
64+
free(rsp);
65+
}
66+
}
67+
68+
struct nfsd_rpc_status_get_list *nfsd_rpc_status_get_dump(struct ynl_sock *ys)
69+
{
70+
struct ynl_dump_state yds = {};
71+
struct nlmsghdr *nlh;
72+
int err;
73+
74+
yds.ys = ys;
75+
yds.alloc_sz = sizeof(struct nfsd_rpc_status_get_list);
76+
yds.cb = nfsd_rpc_status_get_rsp_parse;
77+
yds.rsp_cmd = NFSD_CMD_RPC_STATUS_GET;
78+
yds.rsp_policy = &nfsd_rpc_status_nest;
79+
80+
nlh = ynl_gemsg_start_dump(ys, ys->family_id, NFSD_CMD_RPC_STATUS_GET, 1);
81+
82+
err = ynl_exec_dump(ys, nlh, &yds);
83+
if (err < 0)
84+
goto free_list;
85+
86+
return yds.first;
87+
88+
free_list:
89+
nfsd_rpc_status_get_list_free(yds.first);
90+
return NULL;
91+
}
92+
93+
const struct ynl_family ynl_nfsd_family = {
94+
.name = "nfsd",
95+
};

tools/net/ynl/generated/nfsd-user.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 user header */
5+
6+
#ifndef _LINUX_NFSD_GEN_H
7+
#define _LINUX_NFSD_GEN_H
8+
9+
#include <stdlib.h>
10+
#include <string.h>
11+
#include <linux/types.h>
12+
#include <linux/nfsd_netlink.h>
13+
14+
struct ynl_sock;
15+
16+
extern const struct ynl_family ynl_nfsd_family;
17+
18+
/* Enums */
19+
const char *nfsd_op_str(int op);
20+
21+
/* Common nested types */
22+
/* ============== NFSD_CMD_RPC_STATUS_GET ============== */
23+
/* NFSD_CMD_RPC_STATUS_GET - dump */
24+
struct nfsd_rpc_status_get_list {
25+
struct nfsd_rpc_status_get_list *next;
26+
struct nfsd_rpc_status_get_rsp obj __attribute__ ((aligned (8)));
27+
};
28+
29+
void nfsd_rpc_status_get_list_free(struct nfsd_rpc_status_get_list *rsp);
30+
31+
struct nfsd_rpc_status_get_list *nfsd_rpc_status_get_dump(struct ynl_sock *ys);
32+
33+
#endif /* _LINUX_NFSD_GEN_H */

0 commit comments

Comments
 (0)