Commit f7c0e362 authored by Jakub Kicinski's avatar Jakub Kicinski

tools: ynl: remove generated user space code from git

The ynl-generated user space C code is already above 25kLoC
and is growing.

The initial reason to commit these files was to make reviewing changes
to the generator easier. Unfortunately, it has the opposite effect on
reviewing changes to specs, and we get far more changes to specs
than to the generator.

Uncommit those fails, as they are generated on the fly as needed.
netdev patchwork now runs a script on each series to create a diff
of generated code on the fly, for the rare cases when looking at
it is helpful:
https://github.com/kuba-moo/nipa/blob/master/tests/series/ynl/ynl.shSuggested-by: default avatarPaolo Abeni <pabeni@redhat.com>
Acked-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 5ab500d6
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
/* Do not edit directly, auto-generated from: */
/* Documentation/netlink/specs/fou.yaml */
/* YNL-GEN user source */
#include <stdlib.h>
#include <string.h>
#include "fou-user.h"
#include "ynl.h"
#include <linux/fou.h>
#include <libmnl/libmnl.h>
#include <linux/genetlink.h>
/* Enums */
static const char * const fou_op_strmap[] = {
[FOU_CMD_ADD] = "add",
[FOU_CMD_DEL] = "del",
[FOU_CMD_GET] = "get",
};
const char *fou_op_str(int op)
{
if (op < 0 || op >= (int)MNL_ARRAY_SIZE(fou_op_strmap))
return NULL;
return fou_op_strmap[op];
}
static const char * const fou_encap_type_strmap[] = {
[0] = "unspec",
[1] = "direct",
[2] = "gue",
};
const char *fou_encap_type_str(int value)
{
if (value < 0 || value >= (int)MNL_ARRAY_SIZE(fou_encap_type_strmap))
return NULL;
return fou_encap_type_strmap[value];
}
/* Policies */
struct ynl_policy_attr fou_policy[FOU_ATTR_MAX + 1] = {
[FOU_ATTR_UNSPEC] = { .name = "unspec", .type = YNL_PT_REJECT, },
[FOU_ATTR_PORT] = { .name = "port", .type = YNL_PT_U16, },
[FOU_ATTR_AF] = { .name = "af", .type = YNL_PT_U8, },
[FOU_ATTR_IPPROTO] = { .name = "ipproto", .type = YNL_PT_U8, },
[FOU_ATTR_TYPE] = { .name = "type", .type = YNL_PT_U8, },
[FOU_ATTR_REMCSUM_NOPARTIAL] = { .name = "remcsum_nopartial", .type = YNL_PT_FLAG, },
[FOU_ATTR_LOCAL_V4] = { .name = "local_v4", .type = YNL_PT_U32, },
[FOU_ATTR_LOCAL_V6] = { .name = "local_v6", .type = YNL_PT_BINARY,},
[FOU_ATTR_PEER_V4] = { .name = "peer_v4", .type = YNL_PT_U32, },
[FOU_ATTR_PEER_V6] = { .name = "peer_v6", .type = YNL_PT_BINARY,},
[FOU_ATTR_PEER_PORT] = { .name = "peer_port", .type = YNL_PT_U16, },
[FOU_ATTR_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, },
};
struct ynl_policy_nest fou_nest = {
.max_attr = FOU_ATTR_MAX,
.table = fou_policy,
};
/* Common nested types */
/* ============== FOU_CMD_ADD ============== */
/* FOU_CMD_ADD - do */
void fou_add_req_free(struct fou_add_req *req)
{
free(req->local_v6);
free(req->peer_v6);
free(req);
}
int fou_add(struct ynl_sock *ys, struct fou_add_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, FOU_CMD_ADD, 1);
ys->req_policy = &fou_nest;
if (req->_present.port)
mnl_attr_put_u16(nlh, FOU_ATTR_PORT, req->port);
if (req->_present.ipproto)
mnl_attr_put_u8(nlh, FOU_ATTR_IPPROTO, req->ipproto);
if (req->_present.type)
mnl_attr_put_u8(nlh, FOU_ATTR_TYPE, req->type);
if (req->_present.remcsum_nopartial)
mnl_attr_put(nlh, FOU_ATTR_REMCSUM_NOPARTIAL, 0, NULL);
if (req->_present.local_v4)
mnl_attr_put_u32(nlh, FOU_ATTR_LOCAL_V4, req->local_v4);
if (req->_present.peer_v4)
mnl_attr_put_u32(nlh, FOU_ATTR_PEER_V4, req->peer_v4);
if (req->_present.local_v6_len)
mnl_attr_put(nlh, FOU_ATTR_LOCAL_V6, req->_present.local_v6_len, req->local_v6);
if (req->_present.peer_v6_len)
mnl_attr_put(nlh, FOU_ATTR_PEER_V6, req->_present.peer_v6_len, req->peer_v6);
if (req->_present.peer_port)
mnl_attr_put_u16(nlh, FOU_ATTR_PEER_PORT, req->peer_port);
if (req->_present.ifindex)
mnl_attr_put_u32(nlh, FOU_ATTR_IFINDEX, req->ifindex);
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
return -1;
return 0;
}
/* ============== FOU_CMD_DEL ============== */
/* FOU_CMD_DEL - do */
void fou_del_req_free(struct fou_del_req *req)
{
free(req->local_v6);
free(req->peer_v6);
free(req);
}
int fou_del(struct ynl_sock *ys, struct fou_del_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, FOU_CMD_DEL, 1);
ys->req_policy = &fou_nest;
if (req->_present.af)
mnl_attr_put_u8(nlh, FOU_ATTR_AF, req->af);
if (req->_present.ifindex)
mnl_attr_put_u32(nlh, FOU_ATTR_IFINDEX, req->ifindex);
if (req->_present.port)
mnl_attr_put_u16(nlh, FOU_ATTR_PORT, req->port);
if (req->_present.peer_port)
mnl_attr_put_u16(nlh, FOU_ATTR_PEER_PORT, req->peer_port);
if (req->_present.local_v4)
mnl_attr_put_u32(nlh, FOU_ATTR_LOCAL_V4, req->local_v4);
if (req->_present.peer_v4)
mnl_attr_put_u32(nlh, FOU_ATTR_PEER_V4, req->peer_v4);
if (req->_present.local_v6_len)
mnl_attr_put(nlh, FOU_ATTR_LOCAL_V6, req->_present.local_v6_len, req->local_v6);
if (req->_present.peer_v6_len)
mnl_attr_put(nlh, FOU_ATTR_PEER_V6, req->_present.peer_v6_len, req->peer_v6);
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
return -1;
return 0;
}
/* ============== FOU_CMD_GET ============== */
/* FOU_CMD_GET - do */
void fou_get_req_free(struct fou_get_req *req)
{
free(req->local_v6);
free(req->peer_v6);
free(req);
}
void fou_get_rsp_free(struct fou_get_rsp *rsp)
{
free(rsp->local_v6);
free(rsp->peer_v6);
free(rsp);
}
int fou_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
struct fou_get_rsp *dst;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == FOU_ATTR_PORT) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.port = 1;
dst->port = mnl_attr_get_u16(attr);
} else if (type == FOU_ATTR_IPPROTO) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.ipproto = 1;
dst->ipproto = mnl_attr_get_u8(attr);
} else if (type == FOU_ATTR_TYPE) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.type = 1;
dst->type = mnl_attr_get_u8(attr);
} else if (type == FOU_ATTR_REMCSUM_NOPARTIAL) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.remcsum_nopartial = 1;
} else if (type == FOU_ATTR_LOCAL_V4) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.local_v4 = 1;
dst->local_v4 = mnl_attr_get_u32(attr);
} else if (type == FOU_ATTR_PEER_V4) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.peer_v4 = 1;
dst->peer_v4 = mnl_attr_get_u32(attr);
} else if (type == FOU_ATTR_LOCAL_V6) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = mnl_attr_get_payload_len(attr);
dst->_present.local_v6_len = len;
dst->local_v6 = malloc(len);
memcpy(dst->local_v6, mnl_attr_get_payload(attr), len);
} else if (type == FOU_ATTR_PEER_V6) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = mnl_attr_get_payload_len(attr);
dst->_present.peer_v6_len = len;
dst->peer_v6 = malloc(len);
memcpy(dst->peer_v6, mnl_attr_get_payload(attr), len);
} else if (type == FOU_ATTR_PEER_PORT) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.peer_port = 1;
dst->peer_port = mnl_attr_get_u16(attr);
} else if (type == FOU_ATTR_IFINDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.ifindex = 1;
dst->ifindex = mnl_attr_get_u32(attr);
}
}
return MNL_CB_OK;
}
struct fou_get_rsp *fou_get(struct ynl_sock *ys, struct fou_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct fou_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, FOU_CMD_GET, 1);
ys->req_policy = &fou_nest;
yrs.yarg.rsp_policy = &fou_nest;
if (req->_present.af)
mnl_attr_put_u8(nlh, FOU_ATTR_AF, req->af);
if (req->_present.ifindex)
mnl_attr_put_u32(nlh, FOU_ATTR_IFINDEX, req->ifindex);
if (req->_present.port)
mnl_attr_put_u16(nlh, FOU_ATTR_PORT, req->port);
if (req->_present.peer_port)
mnl_attr_put_u16(nlh, FOU_ATTR_PEER_PORT, req->peer_port);
if (req->_present.local_v4)
mnl_attr_put_u32(nlh, FOU_ATTR_LOCAL_V4, req->local_v4);
if (req->_present.peer_v4)
mnl_attr_put_u32(nlh, FOU_ATTR_PEER_V4, req->peer_v4);
if (req->_present.local_v6_len)
mnl_attr_put(nlh, FOU_ATTR_LOCAL_V6, req->_present.local_v6_len, req->local_v6);
if (req->_present.peer_v6_len)
mnl_attr_put(nlh, FOU_ATTR_PEER_V6, req->_present.peer_v6_len, req->peer_v6);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = fou_get_rsp_parse;
yrs.rsp_cmd = FOU_CMD_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
fou_get_rsp_free(rsp);
return NULL;
}
/* FOU_CMD_GET - dump */
void fou_get_list_free(struct fou_get_list *rsp)
{
struct fou_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.local_v6);
free(rsp->obj.peer_v6);
free(rsp);
}
}
struct fou_get_list *fou_get_dump(struct ynl_sock *ys)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct fou_get_list);
yds.cb = fou_get_rsp_parse;
yds.rsp_cmd = FOU_CMD_GET;
yds.rsp_policy = &fou_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, FOU_CMD_GET, 1);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
fou_get_list_free(yds.first);
return NULL;
}
const struct ynl_family ynl_fou_family = {
.name = "fou",
};
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
/* Do not edit directly, auto-generated from: */
/* Documentation/netlink/specs/fou.yaml */
/* YNL-GEN user header */
#ifndef _LINUX_FOU_GEN_H
#define _LINUX_FOU_GEN_H
#include <stdlib.h>
#include <string.h>
#include <linux/types.h>
#include <linux/fou.h>
struct ynl_sock;
extern const struct ynl_family ynl_fou_family;
/* Enums */
const char *fou_op_str(int op);
const char *fou_encap_type_str(int value);
/* Common nested types */
/* ============== FOU_CMD_ADD ============== */
/* FOU_CMD_ADD - do */
struct fou_add_req {
struct {
__u32 port:1;
__u32 ipproto:1;
__u32 type:1;
__u32 remcsum_nopartial:1;
__u32 local_v4:1;
__u32 peer_v4:1;
__u32 local_v6_len;
__u32 peer_v6_len;
__u32 peer_port:1;
__u32 ifindex:1;
} _present;
__u16 port /* big-endian */;
__u8 ipproto;
__u8 type;
__u32 local_v4;
__u32 peer_v4;
void *local_v6;
void *peer_v6;
__u16 peer_port /* big-endian */;
__s32 ifindex;
};
static inline struct fou_add_req *fou_add_req_alloc(void)
{
return calloc(1, sizeof(struct fou_add_req));
}
void fou_add_req_free(struct fou_add_req *req);
static inline void
fou_add_req_set_port(struct fou_add_req *req, __u16 port /* big-endian */)
{
req->_present.port = 1;
req->port = port;
}
static inline void
fou_add_req_set_ipproto(struct fou_add_req *req, __u8 ipproto)
{
req->_present.ipproto = 1;
req->ipproto = ipproto;
}
static inline void fou_add_req_set_type(struct fou_add_req *req, __u8 type)
{
req->_present.type = 1;
req->type = type;
}
static inline void fou_add_req_set_remcsum_nopartial(struct fou_add_req *req)
{
req->_present.remcsum_nopartial = 1;
}
static inline void
fou_add_req_set_local_v4(struct fou_add_req *req, __u32 local_v4)
{
req->_present.local_v4 = 1;
req->local_v4 = local_v4;
}
static inline void
fou_add_req_set_peer_v4(struct fou_add_req *req, __u32 peer_v4)
{
req->_present.peer_v4 = 1;
req->peer_v4 = peer_v4;
}
static inline void
fou_add_req_set_local_v6(struct fou_add_req *req, const void *local_v6,
size_t len)
{
free(req->local_v6);
req->_present.local_v6_len = len;
req->local_v6 = malloc(req->_present.local_v6_len);
memcpy(req->local_v6, local_v6, req->_present.local_v6_len);
}
static inline void
fou_add_req_set_peer_v6(struct fou_add_req *req, const void *peer_v6,
size_t len)
{
free(req->peer_v6);
req->_present.peer_v6_len = len;
req->peer_v6 = malloc(req->_present.peer_v6_len);
memcpy(req->peer_v6, peer_v6, req->_present.peer_v6_len);
}
static inline void
fou_add_req_set_peer_port(struct fou_add_req *req,
__u16 peer_port /* big-endian */)
{
req->_present.peer_port = 1;
req->peer_port = peer_port;
}
static inline void
fou_add_req_set_ifindex(struct fou_add_req *req, __s32 ifindex)
{
req->_present.ifindex = 1;
req->ifindex = ifindex;
}
/*
* Add port.
*/
int fou_add(struct ynl_sock *ys, struct fou_add_req *req);
/* ============== FOU_CMD_DEL ============== */
/* FOU_CMD_DEL - do */
struct fou_del_req {
struct {
__u32 af:1;
__u32 ifindex:1;
__u32 port:1;
__u32 peer_port:1;
__u32 local_v4:1;
__u32 peer_v4:1;
__u32 local_v6_len;
__u32 peer_v6_len;
} _present;
__u8 af;
__s32 ifindex;
__u16 port /* big-endian */;
__u16 peer_port /* big-endian */;
__u32 local_v4;
__u32 peer_v4;
void *local_v6;
void *peer_v6;
};
static inline struct fou_del_req *fou_del_req_alloc(void)
{
return calloc(1, sizeof(struct fou_del_req));
}
void fou_del_req_free(struct fou_del_req *req);
static inline void fou_del_req_set_af(struct fou_del_req *req, __u8 af)
{
req->_present.af = 1;
req->af = af;
}
static inline void
fou_del_req_set_ifindex(struct fou_del_req *req, __s32 ifindex)
{
req->_present.ifindex = 1;
req->ifindex = ifindex;
}
static inline void
fou_del_req_set_port(struct fou_del_req *req, __u16 port /* big-endian */)
{
req->_present.port = 1;
req->port = port;
}
static inline void
fou_del_req_set_peer_port(struct fou_del_req *req,
__u16 peer_port /* big-endian */)
{
req->_present.peer_port = 1;
req->peer_port = peer_port;
}
static inline void
fou_del_req_set_local_v4(struct fou_del_req *req, __u32 local_v4)
{
req->_present.local_v4 = 1;
req->local_v4 = local_v4;
}
static inline void
fou_del_req_set_peer_v4(struct fou_del_req *req, __u32 peer_v4)
{
req->_present.peer_v4 = 1;
req->peer_v4 = peer_v4;
}
static inline void
fou_del_req_set_local_v6(struct fou_del_req *req, const void *local_v6,
size_t len)
{
free(req->local_v6);
req->_present.local_v6_len = len;
req->local_v6 = malloc(req->_present.local_v6_len);
memcpy(req->local_v6, local_v6, req->_present.local_v6_len);
}
static inline void
fou_del_req_set_peer_v6(struct fou_del_req *req, const void *peer_v6,
size_t len)
{
free(req->peer_v6);
req->_present.peer_v6_len = len;
req->peer_v6 = malloc(req->_present.peer_v6_len);
memcpy(req->peer_v6, peer_v6, req->_present.peer_v6_len);
}
/*
* Delete port.
*/
int fou_del(struct ynl_sock *ys, struct fou_del_req *req);
/* ============== FOU_CMD_GET ============== */
/* FOU_CMD_GET - do */
struct fou_get_req {
struct {
__u32 af:1;
__u32 ifindex:1;
__u32 port:1;
__u32 peer_port:1;
__u32 local_v4:1;
__u32 peer_v4:1;
__u32 local_v6_len;
__u32 peer_v6_len;
} _present;
__u8 af;
__s32 ifindex;
__u16 port /* big-endian */;
__u16 peer_port /* big-endian */;
__u32 local_v4;
__u32 peer_v4;
void *local_v6;
void *peer_v6;
};
static inline struct fou_get_req *fou_get_req_alloc(void)
{
return calloc(1, sizeof(struct fou_get_req));
}
void fou_get_req_free(struct fou_get_req *req);
static inline void fou_get_req_set_af(struct fou_get_req *req, __u8 af)
{
req->_present.af = 1;
req->af = af;
}
static inline void
fou_get_req_set_ifindex(struct fou_get_req *req, __s32 ifindex)
{
req->_present.ifindex = 1;
req->ifindex = ifindex;
}
static inline void
fou_get_req_set_port(struct fou_get_req *req, __u16 port /* big-endian */)
{
req->_present.port = 1;
req->port = port;
}
static inline void
fou_get_req_set_peer_port(struct fou_get_req *req,
__u16 peer_port /* big-endian */)
{
req->_present.peer_port = 1;
req->peer_port = peer_port;
}
static inline void
fou_get_req_set_local_v4(struct fou_get_req *req, __u32 local_v4)
{
req->_present.local_v4 = 1;
req->local_v4 = local_v4;
}
static inline void
fou_get_req_set_peer_v4(struct fou_get_req *req, __u32 peer_v4)
{
req->_present.peer_v4 = 1;
req->peer_v4 = peer_v4;
}
static inline void
fou_get_req_set_local_v6(struct fou_get_req *req, const void *local_v6,
size_t len)
{
free(req->local_v6);
req->_present.local_v6_len = len;
req->local_v6 = malloc(req->_present.local_v6_len);
memcpy(req->local_v6, local_v6, req->_present.local_v6_len);
}
static inline void
fou_get_req_set_peer_v6(struct fou_get_req *req, const void *peer_v6,
size_t len)
{
free(req->peer_v6);
req->_present.peer_v6_len = len;
req->peer_v6 = malloc(req->_present.peer_v6_len);
memcpy(req->peer_v6, peer_v6, req->_present.peer_v6_len);
}
struct fou_get_rsp {
struct {
__u32 port:1;
__u32 ipproto:1;
__u32 type:1;
__u32 remcsum_nopartial:1;
__u32 local_v4:1;
__u32 peer_v4:1;
__u32 local_v6_len;
__u32 peer_v6_len;
__u32 peer_port:1;
__u32 ifindex:1;
} _present;
__u16 port /* big-endian */;
__u8 ipproto;
__u8 type;
__u32 local_v4;
__u32 peer_v4;
void *local_v6;
void *peer_v6;
__u16 peer_port /* big-endian */;
__s32 ifindex;
};
void fou_get_rsp_free(struct fou_get_rsp *rsp);
/*
* Get tunnel info.
*/
struct fou_get_rsp *fou_get(struct ynl_sock *ys, struct fou_get_req *req);
/* FOU_CMD_GET - dump */
struct fou_get_list {
struct fou_get_list *next;
struct fou_get_rsp obj __attribute__((aligned(8)));
};
void fou_get_list_free(struct fou_get_list *rsp);
struct fou_get_list *fou_get_dump(struct ynl_sock *ys);
#endif /* _LINUX_FOU_GEN_H */
// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
/* Do not edit directly, auto-generated from: */
/* Documentation/netlink/specs/handshake.yaml */
/* YNL-GEN user source */
#include <stdlib.h>
#include <string.h>
#include "handshake-user.h"
#include "ynl.h"
#include <linux/handshake.h>
#include <libmnl/libmnl.h>
#include <linux/genetlink.h>
/* Enums */
static const char * const handshake_op_strmap[] = {
[HANDSHAKE_CMD_READY] = "ready",
[HANDSHAKE_CMD_ACCEPT] = "accept",
[HANDSHAKE_CMD_DONE] = "done",
};
const char *handshake_op_str(int op)
{
if (op < 0 || op >= (int)MNL_ARRAY_SIZE(handshake_op_strmap))
return NULL;
return handshake_op_strmap[op];
}
static const char * const handshake_handler_class_strmap[] = {
[0] = "none",
[1] = "tlshd",
[2] = "max",
};
const char *handshake_handler_class_str(enum handshake_handler_class value)
{
if (value < 0 || value >= (int)MNL_ARRAY_SIZE(handshake_handler_class_strmap))
return NULL;
return handshake_handler_class_strmap[value];
}
static const char * const handshake_msg_type_strmap[] = {
[0] = "unspec",
[1] = "clienthello",
[2] = "serverhello",
};
const char *handshake_msg_type_str(enum handshake_msg_type value)
{
if (value < 0 || value >= (int)MNL_ARRAY_SIZE(handshake_msg_type_strmap))
return NULL;
return handshake_msg_type_strmap[value];
}
static const char * const handshake_auth_strmap[] = {
[0] = "unspec",
[1] = "unauth",
[2] = "psk",
[3] = "x509",
};
const char *handshake_auth_str(enum handshake_auth value)
{
if (value < 0 || value >= (int)MNL_ARRAY_SIZE(handshake_auth_strmap))
return NULL;
return handshake_auth_strmap[value];
}
/* Policies */
struct ynl_policy_attr handshake_x509_policy[HANDSHAKE_A_X509_MAX + 1] = {
[HANDSHAKE_A_X509_CERT] = { .name = "cert", .type = YNL_PT_U32, },
[HANDSHAKE_A_X509_PRIVKEY] = { .name = "privkey", .type = YNL_PT_U32, },
};
struct ynl_policy_nest handshake_x509_nest = {
.max_attr = HANDSHAKE_A_X509_MAX,
.table = handshake_x509_policy,
};
struct ynl_policy_attr handshake_accept_policy[HANDSHAKE_A_ACCEPT_MAX + 1] = {
[HANDSHAKE_A_ACCEPT_SOCKFD] = { .name = "sockfd", .type = YNL_PT_U32, },
[HANDSHAKE_A_ACCEPT_HANDLER_CLASS] = { .name = "handler-class", .type = YNL_PT_U32, },
[HANDSHAKE_A_ACCEPT_MESSAGE_TYPE] = { .name = "message-type", .type = YNL_PT_U32, },
[HANDSHAKE_A_ACCEPT_TIMEOUT] = { .name = "timeout", .type = YNL_PT_U32, },
[HANDSHAKE_A_ACCEPT_AUTH_MODE] = { .name = "auth-mode", .type = YNL_PT_U32, },
[HANDSHAKE_A_ACCEPT_PEER_IDENTITY] = { .name = "peer-identity", .type = YNL_PT_U32, },
[HANDSHAKE_A_ACCEPT_CERTIFICATE] = { .name = "certificate", .type = YNL_PT_NEST, .nest = &handshake_x509_nest, },
[HANDSHAKE_A_ACCEPT_PEERNAME] = { .name = "peername", .type = YNL_PT_NUL_STR, },
};
struct ynl_policy_nest handshake_accept_nest = {
.max_attr = HANDSHAKE_A_ACCEPT_MAX,
.table = handshake_accept_policy,
};
struct ynl_policy_attr handshake_done_policy[HANDSHAKE_A_DONE_MAX + 1] = {
[HANDSHAKE_A_DONE_STATUS] = { .name = "status", .type = YNL_PT_U32, },
[HANDSHAKE_A_DONE_SOCKFD] = { .name = "sockfd", .type = YNL_PT_U32, },
[HANDSHAKE_A_DONE_REMOTE_AUTH] = { .name = "remote-auth", .type = YNL_PT_U32, },
};
struct ynl_policy_nest handshake_done_nest = {
.max_attr = HANDSHAKE_A_DONE_MAX,
.table = handshake_done_policy,
};
/* Common nested types */
void handshake_x509_free(struct handshake_x509 *obj)
{
}
int handshake_x509_parse(struct ynl_parse_arg *yarg,
const struct nlattr *nested)
{
struct handshake_x509 *dst = yarg->data;
const struct nlattr *attr;
mnl_attr_for_each_nested(attr, nested) {
unsigned int type = mnl_attr_get_type(attr);
if (type == HANDSHAKE_A_X509_CERT) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.cert = 1;
dst->cert = mnl_attr_get_u32(attr);
} else if (type == HANDSHAKE_A_X509_PRIVKEY) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.privkey = 1;
dst->privkey = mnl_attr_get_u32(attr);
}
}
return 0;
}
/* ============== HANDSHAKE_CMD_ACCEPT ============== */
/* HANDSHAKE_CMD_ACCEPT - do */
void handshake_accept_req_free(struct handshake_accept_req *req)
{
free(req);
}
void handshake_accept_rsp_free(struct handshake_accept_rsp *rsp)
{
unsigned int i;
free(rsp->peer_identity);
for (i = 0; i < rsp->n_certificate; i++)
handshake_x509_free(&rsp->certificate[i]);
free(rsp->certificate);
free(rsp->peername);
free(rsp);
}
int handshake_accept_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct ynl_parse_arg *yarg = data;
struct handshake_accept_rsp *dst;
unsigned int n_peer_identity = 0;
unsigned int n_certificate = 0;
const struct nlattr *attr;
struct ynl_parse_arg parg;
int i;
dst = yarg->data;
parg.ys = yarg->ys;
if (dst->certificate)
return ynl_error_parse(yarg, "attribute already present (accept.certificate)");
if (dst->peer_identity)
return ynl_error_parse(yarg, "attribute already present (accept.peer-identity)");
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == HANDSHAKE_A_ACCEPT_SOCKFD) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.sockfd = 1;
dst->sockfd = mnl_attr_get_u32(attr);
} else if (type == HANDSHAKE_A_ACCEPT_MESSAGE_TYPE) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.message_type = 1;
dst->message_type = mnl_attr_get_u32(attr);
} else if (type == HANDSHAKE_A_ACCEPT_TIMEOUT) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.timeout = 1;
dst->timeout = mnl_attr_get_u32(attr);
} else if (type == HANDSHAKE_A_ACCEPT_AUTH_MODE) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.auth_mode = 1;
dst->auth_mode = mnl_attr_get_u32(attr);
} else if (type == HANDSHAKE_A_ACCEPT_PEER_IDENTITY) {
n_peer_identity++;
} else if (type == HANDSHAKE_A_ACCEPT_CERTIFICATE) {
n_certificate++;
} else if (type == HANDSHAKE_A_ACCEPT_PEERNAME) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = strnlen(mnl_attr_get_str(attr), mnl_attr_get_payload_len(attr));
dst->_present.peername_len = len;
dst->peername = malloc(len + 1);
memcpy(dst->peername, mnl_attr_get_str(attr), len);
dst->peername[len] = 0;
}
}
if (n_certificate) {
dst->certificate = calloc(n_certificate, sizeof(*dst->certificate));
dst->n_certificate = n_certificate;
i = 0;
parg.rsp_policy = &handshake_x509_nest;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
if (mnl_attr_get_type(attr) == HANDSHAKE_A_ACCEPT_CERTIFICATE) {
parg.data = &dst->certificate[i];
if (handshake_x509_parse(&parg, attr))
return MNL_CB_ERROR;
i++;
}
}
}
if (n_peer_identity) {
dst->peer_identity = calloc(n_peer_identity, sizeof(*dst->peer_identity));
dst->n_peer_identity = n_peer_identity;
i = 0;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
if (mnl_attr_get_type(attr) == HANDSHAKE_A_ACCEPT_PEER_IDENTITY) {
dst->peer_identity[i] = mnl_attr_get_u32(attr);
i++;
}
}
}
return MNL_CB_OK;
}
struct handshake_accept_rsp *
handshake_accept(struct ynl_sock *ys, struct handshake_accept_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct handshake_accept_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, HANDSHAKE_CMD_ACCEPT, 1);
ys->req_policy = &handshake_accept_nest;
yrs.yarg.rsp_policy = &handshake_accept_nest;
if (req->_present.handler_class)
mnl_attr_put_u32(nlh, HANDSHAKE_A_ACCEPT_HANDLER_CLASS, req->handler_class);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = handshake_accept_rsp_parse;
yrs.rsp_cmd = HANDSHAKE_CMD_ACCEPT;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
handshake_accept_rsp_free(rsp);
return NULL;
}
/* HANDSHAKE_CMD_ACCEPT - notify */
void handshake_accept_ntf_free(struct handshake_accept_ntf *rsp)
{
unsigned int i;
free(rsp->obj.peer_identity);
for (i = 0; i < rsp->obj.n_certificate; i++)
handshake_x509_free(&rsp->obj.certificate[i]);
free(rsp->obj.certificate);
free(rsp->obj.peername);
free(rsp);
}
/* ============== HANDSHAKE_CMD_DONE ============== */
/* HANDSHAKE_CMD_DONE - do */
void handshake_done_req_free(struct handshake_done_req *req)
{
free(req->remote_auth);
free(req);
}
int handshake_done(struct ynl_sock *ys, struct handshake_done_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, HANDSHAKE_CMD_DONE, 1);
ys->req_policy = &handshake_done_nest;
if (req->_present.status)
mnl_attr_put_u32(nlh, HANDSHAKE_A_DONE_STATUS, req->status);
if (req->_present.sockfd)
mnl_attr_put_u32(nlh, HANDSHAKE_A_DONE_SOCKFD, req->sockfd);
for (unsigned int i = 0; i < req->n_remote_auth; i++)
mnl_attr_put_u32(nlh, HANDSHAKE_A_DONE_REMOTE_AUTH, req->remote_auth[i]);
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
return -1;
return 0;
}
static const struct ynl_ntf_info handshake_ntf_info[] = {
[HANDSHAKE_CMD_READY] = {
.alloc_sz = sizeof(struct handshake_accept_ntf),
.cb = handshake_accept_rsp_parse,
.policy = &handshake_accept_nest,
.free = (void *)handshake_accept_ntf_free,
},
};
const struct ynl_family ynl_handshake_family = {
.name = "handshake",
.ntf_info = handshake_ntf_info,
.ntf_info_size = MNL_ARRAY_SIZE(handshake_ntf_info),
};
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
/* Do not edit directly, auto-generated from: */
/* Documentation/netlink/specs/handshake.yaml */
/* YNL-GEN user header */
#ifndef _LINUX_HANDSHAKE_GEN_H
#define _LINUX_HANDSHAKE_GEN_H
#include <stdlib.h>
#include <string.h>
#include <linux/types.h>
#include <linux/handshake.h>
struct ynl_sock;
extern const struct ynl_family ynl_handshake_family;
/* Enums */
const char *handshake_op_str(int op);
const char *handshake_handler_class_str(enum handshake_handler_class value);
const char *handshake_msg_type_str(enum handshake_msg_type value);
const char *handshake_auth_str(enum handshake_auth value);
/* Common nested types */
struct handshake_x509 {
struct {
__u32 cert:1;
__u32 privkey:1;
} _present;
__s32 cert;
__s32 privkey;
};
/* ============== HANDSHAKE_CMD_ACCEPT ============== */
/* HANDSHAKE_CMD_ACCEPT - do */
struct handshake_accept_req {
struct {
__u32 handler_class:1;
} _present;
enum handshake_handler_class handler_class;
};
static inline struct handshake_accept_req *handshake_accept_req_alloc(void)
{
return calloc(1, sizeof(struct handshake_accept_req));
}
void handshake_accept_req_free(struct handshake_accept_req *req);
static inline void
handshake_accept_req_set_handler_class(struct handshake_accept_req *req,
enum handshake_handler_class handler_class)
{
req->_present.handler_class = 1;
req->handler_class = handler_class;
}
struct handshake_accept_rsp {
struct {
__u32 sockfd:1;
__u32 message_type:1;
__u32 timeout:1;
__u32 auth_mode:1;
__u32 peername_len;
} _present;
__s32 sockfd;
enum handshake_msg_type message_type;
__u32 timeout;
enum handshake_auth auth_mode;
unsigned int n_peer_identity;
__u32 *peer_identity;
unsigned int n_certificate;
struct handshake_x509 *certificate;
char *peername;
};
void handshake_accept_rsp_free(struct handshake_accept_rsp *rsp);
/*
* Handler retrieves next queued handshake request
*/
struct handshake_accept_rsp *
handshake_accept(struct ynl_sock *ys, struct handshake_accept_req *req);
/* HANDSHAKE_CMD_ACCEPT - notify */
struct handshake_accept_ntf {
__u16 family;
__u8 cmd;
struct ynl_ntf_base_type *next;
void (*free)(struct handshake_accept_ntf *ntf);
struct handshake_accept_rsp obj __attribute__((aligned(8)));
};
void handshake_accept_ntf_free(struct handshake_accept_ntf *rsp);
/* ============== HANDSHAKE_CMD_DONE ============== */
/* HANDSHAKE_CMD_DONE - do */
struct handshake_done_req {
struct {
__u32 status:1;
__u32 sockfd:1;
} _present;
__u32 status;
__s32 sockfd;
unsigned int n_remote_auth;
__u32 *remote_auth;
};
static inline struct handshake_done_req *handshake_done_req_alloc(void)
{
return calloc(1, sizeof(struct handshake_done_req));
}
void handshake_done_req_free(struct handshake_done_req *req);
static inline void
handshake_done_req_set_status(struct handshake_done_req *req, __u32 status)
{
req->_present.status = 1;
req->status = status;
}
static inline void
handshake_done_req_set_sockfd(struct handshake_done_req *req, __s32 sockfd)
{
req->_present.sockfd = 1;
req->sockfd = sockfd;
}
static inline void
__handshake_done_req_set_remote_auth(struct handshake_done_req *req,
__u32 *remote_auth,
unsigned int n_remote_auth)
{
free(req->remote_auth);
req->remote_auth = remote_auth;
req->n_remote_auth = n_remote_auth;
}
/*
* Handler reports handshake completion
*/
int handshake_done(struct ynl_sock *ys, struct handshake_done_req *req);
#endif /* _LINUX_HANDSHAKE_GEN_H */
// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
/* Do not edit directly, auto-generated from: */
/* Documentation/netlink/specs/netdev.yaml */
/* YNL-GEN user source */
#include <stdlib.h>
#include <string.h>
#include "netdev-user.h"
#include "ynl.h"
#include <linux/netdev.h>
#include <libmnl/libmnl.h>
#include <linux/genetlink.h>
/* Enums */
static const char * const netdev_op_strmap[] = {
[NETDEV_CMD_DEV_GET] = "dev-get",
[NETDEV_CMD_DEV_ADD_NTF] = "dev-add-ntf",
[NETDEV_CMD_DEV_DEL_NTF] = "dev-del-ntf",
[NETDEV_CMD_DEV_CHANGE_NTF] = "dev-change-ntf",
[NETDEV_CMD_PAGE_POOL_GET] = "page-pool-get",
[NETDEV_CMD_PAGE_POOL_ADD_NTF] = "page-pool-add-ntf",
[NETDEV_CMD_PAGE_POOL_DEL_NTF] = "page-pool-del-ntf",
[NETDEV_CMD_PAGE_POOL_CHANGE_NTF] = "page-pool-change-ntf",
[NETDEV_CMD_PAGE_POOL_STATS_GET] = "page-pool-stats-get",
[NETDEV_CMD_QUEUE_GET] = "queue-get",
[NETDEV_CMD_NAPI_GET] = "napi-get",
};
const char *netdev_op_str(int op)
{
if (op < 0 || op >= (int)MNL_ARRAY_SIZE(netdev_op_strmap))
return NULL;
return netdev_op_strmap[op];
}
static const char * const netdev_xdp_act_strmap[] = {
[0] = "basic",
[1] = "redirect",
[2] = "ndo-xmit",
[3] = "xsk-zerocopy",
[4] = "hw-offload",
[5] = "rx-sg",
[6] = "ndo-xmit-sg",
};
const char *netdev_xdp_act_str(enum netdev_xdp_act value)
{
value = ffs(value) - 1;
if (value < 0 || value >= (int)MNL_ARRAY_SIZE(netdev_xdp_act_strmap))
return NULL;
return netdev_xdp_act_strmap[value];
}
static const char * const netdev_xdp_rx_metadata_strmap[] = {
[0] = "timestamp",
[1] = "hash",
};
const char *netdev_xdp_rx_metadata_str(enum netdev_xdp_rx_metadata value)
{
value = ffs(value) - 1;
if (value < 0 || value >= (int)MNL_ARRAY_SIZE(netdev_xdp_rx_metadata_strmap))
return NULL;
return netdev_xdp_rx_metadata_strmap[value];
}
static const char * const netdev_xsk_flags_strmap[] = {
[0] = "tx-timestamp",
[1] = "tx-checksum",
};
const char *netdev_xsk_flags_str(enum netdev_xsk_flags value)
{
value = ffs(value) - 1;
if (value < 0 || value >= (int)MNL_ARRAY_SIZE(netdev_xsk_flags_strmap))
return NULL;
return netdev_xsk_flags_strmap[value];
}
static const char * const netdev_queue_type_strmap[] = {
[0] = "rx",
[1] = "tx",
};
const char *netdev_queue_type_str(enum netdev_queue_type value)
{
if (value < 0 || value >= (int)MNL_ARRAY_SIZE(netdev_queue_type_strmap))
return NULL;
return netdev_queue_type_strmap[value];
}
/* Policies */
struct ynl_policy_attr netdev_page_pool_info_policy[NETDEV_A_PAGE_POOL_MAX + 1] = {
[NETDEV_A_PAGE_POOL_ID] = { .name = "id", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, },
};
struct ynl_policy_nest netdev_page_pool_info_nest = {
.max_attr = NETDEV_A_PAGE_POOL_MAX,
.table = netdev_page_pool_info_policy,
};
struct ynl_policy_attr netdev_dev_policy[NETDEV_A_DEV_MAX + 1] = {
[NETDEV_A_DEV_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, },
[NETDEV_A_DEV_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, },
[NETDEV_A_DEV_XDP_FEATURES] = { .name = "xdp-features", .type = YNL_PT_U64, },
[NETDEV_A_DEV_XDP_ZC_MAX_SEGS] = { .name = "xdp-zc-max-segs", .type = YNL_PT_U32, },
[NETDEV_A_DEV_XDP_RX_METADATA_FEATURES] = { .name = "xdp-rx-metadata-features", .type = YNL_PT_U64, },
[NETDEV_A_DEV_XSK_FEATURES] = { .name = "xsk-features", .type = YNL_PT_U64, },
};
struct ynl_policy_nest netdev_dev_nest = {
.max_attr = NETDEV_A_DEV_MAX,
.table = netdev_dev_policy,
};
struct ynl_policy_attr netdev_page_pool_policy[NETDEV_A_PAGE_POOL_MAX + 1] = {
[NETDEV_A_PAGE_POOL_ID] = { .name = "id", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, },
[NETDEV_A_PAGE_POOL_NAPI_ID] = { .name = "napi-id", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_INFLIGHT] = { .name = "inflight", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_INFLIGHT_MEM] = { .name = "inflight-mem", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_DETACH_TIME] = { .name = "detach-time", .type = YNL_PT_UINT, },
};
struct ynl_policy_nest netdev_page_pool_nest = {
.max_attr = NETDEV_A_PAGE_POOL_MAX,
.table = netdev_page_pool_policy,
};
struct ynl_policy_attr netdev_page_pool_stats_policy[NETDEV_A_PAGE_POOL_STATS_MAX + 1] = {
[NETDEV_A_PAGE_POOL_STATS_INFO] = { .name = "info", .type = YNL_PT_NEST, .nest = &netdev_page_pool_info_nest, },
[NETDEV_A_PAGE_POOL_STATS_ALLOC_FAST] = { .name = "alloc-fast", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_STATS_ALLOC_SLOW] = { .name = "alloc-slow", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_STATS_ALLOC_SLOW_HIGH_ORDER] = { .name = "alloc-slow-high-order", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_STATS_ALLOC_EMPTY] = { .name = "alloc-empty", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_STATS_ALLOC_REFILL] = { .name = "alloc-refill", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_STATS_ALLOC_WAIVE] = { .name = "alloc-waive", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_STATS_RECYCLE_CACHED] = { .name = "recycle-cached", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_STATS_RECYCLE_CACHE_FULL] = { .name = "recycle-cache-full", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_STATS_RECYCLE_RING] = { .name = "recycle-ring", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_STATS_RECYCLE_RING_FULL] = { .name = "recycle-ring-full", .type = YNL_PT_UINT, },
[NETDEV_A_PAGE_POOL_STATS_RECYCLE_RELEASED_REFCNT] = { .name = "recycle-released-refcnt", .type = YNL_PT_UINT, },
};
struct ynl_policy_nest netdev_page_pool_stats_nest = {
.max_attr = NETDEV_A_PAGE_POOL_STATS_MAX,
.table = netdev_page_pool_stats_policy,
};
struct ynl_policy_attr netdev_queue_policy[NETDEV_A_QUEUE_MAX + 1] = {
[NETDEV_A_QUEUE_ID] = { .name = "id", .type = YNL_PT_U32, },
[NETDEV_A_QUEUE_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, },
[NETDEV_A_QUEUE_TYPE] = { .name = "type", .type = YNL_PT_U32, },
[NETDEV_A_QUEUE_NAPI_ID] = { .name = "napi-id", .type = YNL_PT_U32, },
};
struct ynl_policy_nest netdev_queue_nest = {
.max_attr = NETDEV_A_QUEUE_MAX,
.table = netdev_queue_policy,
};
struct ynl_policy_attr netdev_napi_policy[NETDEV_A_NAPI_MAX + 1] = {
[NETDEV_A_NAPI_IFINDEX] = { .name = "ifindex", .type = YNL_PT_U32, },
[NETDEV_A_NAPI_ID] = { .name = "id", .type = YNL_PT_U32, },
[NETDEV_A_NAPI_IRQ] = { .name = "irq", .type = YNL_PT_U32, },
[NETDEV_A_NAPI_PID] = { .name = "pid", .type = YNL_PT_U32, },
};
struct ynl_policy_nest netdev_napi_nest = {
.max_attr = NETDEV_A_NAPI_MAX,
.table = netdev_napi_policy,
};
/* Common nested types */
void netdev_page_pool_info_free(struct netdev_page_pool_info *obj)
{
}
int netdev_page_pool_info_put(struct nlmsghdr *nlh, unsigned int attr_type,
struct netdev_page_pool_info *obj)
{
struct nlattr *nest;
nest = mnl_attr_nest_start(nlh, attr_type);
if (obj->_present.id)
mnl_attr_put_uint(nlh, NETDEV_A_PAGE_POOL_ID, obj->id);
if (obj->_present.ifindex)
mnl_attr_put_u32(nlh, NETDEV_A_PAGE_POOL_IFINDEX, obj->ifindex);
mnl_attr_nest_end(nlh, nest);
return 0;
}
int netdev_page_pool_info_parse(struct ynl_parse_arg *yarg,
const struct nlattr *nested)
{
struct netdev_page_pool_info *dst = yarg->data;
const struct nlattr *attr;
mnl_attr_for_each_nested(attr, nested) {
unsigned int type = mnl_attr_get_type(attr);
if (type == NETDEV_A_PAGE_POOL_ID) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.id = 1;
dst->id = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_IFINDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.ifindex = 1;
dst->ifindex = mnl_attr_get_u32(attr);
} else if (type == NETDEV_A_NAPI_IRQ) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.irq = 1;
dst->irq = mnl_attr_get_u32(attr);
} else if (type == NETDEV_A_NAPI_PID) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.pid = 1;
dst->pid = mnl_attr_get_u32(attr);
}
}
return 0;
}
/* ============== NETDEV_CMD_DEV_GET ============== */
/* NETDEV_CMD_DEV_GET - do */
void netdev_dev_get_req_free(struct netdev_dev_get_req *req)
{
free(req);
}
void netdev_dev_get_rsp_free(struct netdev_dev_get_rsp *rsp)
{
free(rsp);
}
int netdev_dev_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct ynl_parse_arg *yarg = data;
struct netdev_dev_get_rsp *dst;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == NETDEV_A_DEV_IFINDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.ifindex = 1;
dst->ifindex = mnl_attr_get_u32(attr);
} else if (type == NETDEV_A_DEV_XDP_FEATURES) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.xdp_features = 1;
dst->xdp_features = mnl_attr_get_u64(attr);
} else if (type == NETDEV_A_DEV_XDP_ZC_MAX_SEGS) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.xdp_zc_max_segs = 1;
dst->xdp_zc_max_segs = mnl_attr_get_u32(attr);
} else if (type == NETDEV_A_DEV_XDP_RX_METADATA_FEATURES) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.xdp_rx_metadata_features = 1;
dst->xdp_rx_metadata_features = mnl_attr_get_u64(attr);
} else if (type == NETDEV_A_DEV_XSK_FEATURES) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.xsk_features = 1;
dst->xsk_features = mnl_attr_get_u64(attr);
}
}
return MNL_CB_OK;
}
struct netdev_dev_get_rsp *
netdev_dev_get(struct ynl_sock *ys, struct netdev_dev_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct netdev_dev_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, NETDEV_CMD_DEV_GET, 1);
ys->req_policy = &netdev_dev_nest;
yrs.yarg.rsp_policy = &netdev_dev_nest;
if (req->_present.ifindex)
mnl_attr_put_u32(nlh, NETDEV_A_DEV_IFINDEX, req->ifindex);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = netdev_dev_get_rsp_parse;
yrs.rsp_cmd = NETDEV_CMD_DEV_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
netdev_dev_get_rsp_free(rsp);
return NULL;
}
/* NETDEV_CMD_DEV_GET - dump */
void netdev_dev_get_list_free(struct netdev_dev_get_list *rsp)
{
struct netdev_dev_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp);
}
}
struct netdev_dev_get_list *netdev_dev_get_dump(struct ynl_sock *ys)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct netdev_dev_get_list);
yds.cb = netdev_dev_get_rsp_parse;
yds.rsp_cmd = NETDEV_CMD_DEV_GET;
yds.rsp_policy = &netdev_dev_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, NETDEV_CMD_DEV_GET, 1);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
netdev_dev_get_list_free(yds.first);
return NULL;
}
/* NETDEV_CMD_DEV_GET - notify */
void netdev_dev_get_ntf_free(struct netdev_dev_get_ntf *rsp)
{
free(rsp);
}
/* ============== NETDEV_CMD_PAGE_POOL_GET ============== */
/* NETDEV_CMD_PAGE_POOL_GET - do */
void netdev_page_pool_get_req_free(struct netdev_page_pool_get_req *req)
{
free(req);
}
void netdev_page_pool_get_rsp_free(struct netdev_page_pool_get_rsp *rsp)
{
free(rsp);
}
int netdev_page_pool_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct netdev_page_pool_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == NETDEV_A_PAGE_POOL_ID) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.id = 1;
dst->id = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_IFINDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.ifindex = 1;
dst->ifindex = mnl_attr_get_u32(attr);
} else if (type == NETDEV_A_PAGE_POOL_NAPI_ID) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.napi_id = 1;
dst->napi_id = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_INFLIGHT) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.inflight = 1;
dst->inflight = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_INFLIGHT_MEM) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.inflight_mem = 1;
dst->inflight_mem = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_DETACH_TIME) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.detach_time = 1;
dst->detach_time = mnl_attr_get_uint(attr);
}
}
return MNL_CB_OK;
}
struct netdev_page_pool_get_rsp *
netdev_page_pool_get(struct ynl_sock *ys, struct netdev_page_pool_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct netdev_page_pool_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, NETDEV_CMD_PAGE_POOL_GET, 1);
ys->req_policy = &netdev_page_pool_nest;
yrs.yarg.rsp_policy = &netdev_page_pool_nest;
if (req->_present.id)
mnl_attr_put_uint(nlh, NETDEV_A_PAGE_POOL_ID, req->id);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = netdev_page_pool_get_rsp_parse;
yrs.rsp_cmd = NETDEV_CMD_PAGE_POOL_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
netdev_page_pool_get_rsp_free(rsp);
return NULL;
}
/* NETDEV_CMD_PAGE_POOL_GET - dump */
void netdev_page_pool_get_list_free(struct netdev_page_pool_get_list *rsp)
{
struct netdev_page_pool_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp);
}
}
struct netdev_page_pool_get_list *
netdev_page_pool_get_dump(struct ynl_sock *ys)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct netdev_page_pool_get_list);
yds.cb = netdev_page_pool_get_rsp_parse;
yds.rsp_cmd = NETDEV_CMD_PAGE_POOL_GET;
yds.rsp_policy = &netdev_page_pool_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, NETDEV_CMD_PAGE_POOL_GET, 1);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
netdev_page_pool_get_list_free(yds.first);
return NULL;
}
/* NETDEV_CMD_PAGE_POOL_GET - notify */
void netdev_page_pool_get_ntf_free(struct netdev_page_pool_get_ntf *rsp)
{
free(rsp);
}
/* ============== NETDEV_CMD_PAGE_POOL_STATS_GET ============== */
/* NETDEV_CMD_PAGE_POOL_STATS_GET - do */
void
netdev_page_pool_stats_get_req_free(struct netdev_page_pool_stats_get_req *req)
{
netdev_page_pool_info_free(&req->info);
free(req);
}
void
netdev_page_pool_stats_get_rsp_free(struct netdev_page_pool_stats_get_rsp *rsp)
{
netdev_page_pool_info_free(&rsp->info);
free(rsp);
}
int netdev_page_pool_stats_get_rsp_parse(const struct nlmsghdr *nlh,
void *data)
{
struct netdev_page_pool_stats_get_rsp *dst;
struct ynl_parse_arg *yarg = data;
const struct nlattr *attr;
struct ynl_parse_arg parg;
dst = yarg->data;
parg.ys = yarg->ys;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == NETDEV_A_PAGE_POOL_STATS_INFO) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.info = 1;
parg.rsp_policy = &netdev_page_pool_info_nest;
parg.data = &dst->info;
if (netdev_page_pool_info_parse(&parg, attr))
return MNL_CB_ERROR;
} else if (type == NETDEV_A_PAGE_POOL_STATS_ALLOC_FAST) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.alloc_fast = 1;
dst->alloc_fast = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_STATS_ALLOC_SLOW) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.alloc_slow = 1;
dst->alloc_slow = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_STATS_ALLOC_SLOW_HIGH_ORDER) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.alloc_slow_high_order = 1;
dst->alloc_slow_high_order = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_STATS_ALLOC_EMPTY) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.alloc_empty = 1;
dst->alloc_empty = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_STATS_ALLOC_REFILL) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.alloc_refill = 1;
dst->alloc_refill = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_STATS_ALLOC_WAIVE) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.alloc_waive = 1;
dst->alloc_waive = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_STATS_RECYCLE_CACHED) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.recycle_cached = 1;
dst->recycle_cached = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_STATS_RECYCLE_CACHE_FULL) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.recycle_cache_full = 1;
dst->recycle_cache_full = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_STATS_RECYCLE_RING) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.recycle_ring = 1;
dst->recycle_ring = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_STATS_RECYCLE_RING_FULL) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.recycle_ring_full = 1;
dst->recycle_ring_full = mnl_attr_get_uint(attr);
} else if (type == NETDEV_A_PAGE_POOL_STATS_RECYCLE_RELEASED_REFCNT) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.recycle_released_refcnt = 1;
dst->recycle_released_refcnt = mnl_attr_get_uint(attr);
}
}
return MNL_CB_OK;
}
struct netdev_page_pool_stats_get_rsp *
netdev_page_pool_stats_get(struct ynl_sock *ys,
struct netdev_page_pool_stats_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct netdev_page_pool_stats_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, NETDEV_CMD_PAGE_POOL_STATS_GET, 1);
ys->req_policy = &netdev_page_pool_stats_nest;
yrs.yarg.rsp_policy = &netdev_page_pool_stats_nest;
if (req->_present.info)
netdev_page_pool_info_put(nlh, NETDEV_A_PAGE_POOL_STATS_INFO, &req->info);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = netdev_page_pool_stats_get_rsp_parse;
yrs.rsp_cmd = NETDEV_CMD_PAGE_POOL_STATS_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
netdev_page_pool_stats_get_rsp_free(rsp);
return NULL;
}
/* NETDEV_CMD_PAGE_POOL_STATS_GET - dump */
void
netdev_page_pool_stats_get_list_free(struct netdev_page_pool_stats_get_list *rsp)
{
struct netdev_page_pool_stats_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
netdev_page_pool_info_free(&rsp->obj.info);
free(rsp);
}
}
struct netdev_page_pool_stats_get_list *
netdev_page_pool_stats_get_dump(struct ynl_sock *ys)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct netdev_page_pool_stats_get_list);
yds.cb = netdev_page_pool_stats_get_rsp_parse;
yds.rsp_cmd = NETDEV_CMD_PAGE_POOL_STATS_GET;
yds.rsp_policy = &netdev_page_pool_stats_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, NETDEV_CMD_PAGE_POOL_STATS_GET, 1);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
netdev_page_pool_stats_get_list_free(yds.first);
return NULL;
}
/* ============== NETDEV_CMD_QUEUE_GET ============== */
/* NETDEV_CMD_QUEUE_GET - do */
void netdev_queue_get_req_free(struct netdev_queue_get_req *req)
{
free(req);
}
void netdev_queue_get_rsp_free(struct netdev_queue_get_rsp *rsp)
{
free(rsp);
}
int netdev_queue_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct ynl_parse_arg *yarg = data;
struct netdev_queue_get_rsp *dst;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == NETDEV_A_QUEUE_ID) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.id = 1;
dst->id = mnl_attr_get_u32(attr);
} else if (type == NETDEV_A_QUEUE_TYPE) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.type = 1;
dst->type = mnl_attr_get_u32(attr);
} else if (type == NETDEV_A_QUEUE_NAPI_ID) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.napi_id = 1;
dst->napi_id = mnl_attr_get_u32(attr);
} else if (type == NETDEV_A_QUEUE_IFINDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.ifindex = 1;
dst->ifindex = mnl_attr_get_u32(attr);
}
}
return MNL_CB_OK;
}
struct netdev_queue_get_rsp *
netdev_queue_get(struct ynl_sock *ys, struct netdev_queue_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct netdev_queue_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, NETDEV_CMD_QUEUE_GET, 1);
ys->req_policy = &netdev_queue_nest;
yrs.yarg.rsp_policy = &netdev_queue_nest;
if (req->_present.ifindex)
mnl_attr_put_u32(nlh, NETDEV_A_QUEUE_IFINDEX, req->ifindex);
if (req->_present.type)
mnl_attr_put_u32(nlh, NETDEV_A_QUEUE_TYPE, req->type);
if (req->_present.id)
mnl_attr_put_u32(nlh, NETDEV_A_QUEUE_ID, req->id);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = netdev_queue_get_rsp_parse;
yrs.rsp_cmd = NETDEV_CMD_QUEUE_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
netdev_queue_get_rsp_free(rsp);
return NULL;
}
/* NETDEV_CMD_QUEUE_GET - dump */
void netdev_queue_get_list_free(struct netdev_queue_get_list *rsp)
{
struct netdev_queue_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp);
}
}
struct netdev_queue_get_list *
netdev_queue_get_dump(struct ynl_sock *ys,
struct netdev_queue_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct netdev_queue_get_list);
yds.cb = netdev_queue_get_rsp_parse;
yds.rsp_cmd = NETDEV_CMD_QUEUE_GET;
yds.rsp_policy = &netdev_queue_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, NETDEV_CMD_QUEUE_GET, 1);
ys->req_policy = &netdev_queue_nest;
if (req->_present.ifindex)
mnl_attr_put_u32(nlh, NETDEV_A_QUEUE_IFINDEX, req->ifindex);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
netdev_queue_get_list_free(yds.first);
return NULL;
}
/* ============== NETDEV_CMD_NAPI_GET ============== */
/* NETDEV_CMD_NAPI_GET - do */
void netdev_napi_get_req_free(struct netdev_napi_get_req *req)
{
free(req);
}
void netdev_napi_get_rsp_free(struct netdev_napi_get_rsp *rsp)
{
free(rsp);
}
int netdev_napi_get_rsp_parse(const struct nlmsghdr *nlh, void *data)
{
struct ynl_parse_arg *yarg = data;
struct netdev_napi_get_rsp *dst;
const struct nlattr *attr;
dst = yarg->data;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == NETDEV_A_NAPI_ID) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.id = 1;
dst->id = mnl_attr_get_u32(attr);
} else if (type == NETDEV_A_NAPI_IFINDEX) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.ifindex = 1;
dst->ifindex = mnl_attr_get_u32(attr);
}
}
return MNL_CB_OK;
}
struct netdev_napi_get_rsp *
netdev_napi_get(struct ynl_sock *ys, struct netdev_napi_get_req *req)
{
struct ynl_req_state yrs = { .yarg = { .ys = ys, }, };
struct netdev_napi_get_rsp *rsp;
struct nlmsghdr *nlh;
int err;
nlh = ynl_gemsg_start_req(ys, ys->family_id, NETDEV_CMD_NAPI_GET, 1);
ys->req_policy = &netdev_napi_nest;
yrs.yarg.rsp_policy = &netdev_napi_nest;
if (req->_present.id)
mnl_attr_put_u32(nlh, NETDEV_A_NAPI_ID, req->id);
rsp = calloc(1, sizeof(*rsp));
yrs.yarg.data = rsp;
yrs.cb = netdev_napi_get_rsp_parse;
yrs.rsp_cmd = NETDEV_CMD_NAPI_GET;
err = ynl_exec(ys, nlh, &yrs);
if (err < 0)
goto err_free;
return rsp;
err_free:
netdev_napi_get_rsp_free(rsp);
return NULL;
}
/* NETDEV_CMD_NAPI_GET - dump */
void netdev_napi_get_list_free(struct netdev_napi_get_list *rsp)
{
struct netdev_napi_get_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp);
}
}
struct netdev_napi_get_list *
netdev_napi_get_dump(struct ynl_sock *ys, struct netdev_napi_get_req_dump *req)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct netdev_napi_get_list);
yds.cb = netdev_napi_get_rsp_parse;
yds.rsp_cmd = NETDEV_CMD_NAPI_GET;
yds.rsp_policy = &netdev_napi_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, NETDEV_CMD_NAPI_GET, 1);
ys->req_policy = &netdev_napi_nest;
if (req->_present.ifindex)
mnl_attr_put_u32(nlh, NETDEV_A_NAPI_IFINDEX, req->ifindex);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
netdev_napi_get_list_free(yds.first);
return NULL;
}
static const struct ynl_ntf_info netdev_ntf_info[] = {
[NETDEV_CMD_DEV_ADD_NTF] = {
.alloc_sz = sizeof(struct netdev_dev_get_ntf),
.cb = netdev_dev_get_rsp_parse,
.policy = &netdev_dev_nest,
.free = (void *)netdev_dev_get_ntf_free,
},
[NETDEV_CMD_DEV_DEL_NTF] = {
.alloc_sz = sizeof(struct netdev_dev_get_ntf),
.cb = netdev_dev_get_rsp_parse,
.policy = &netdev_dev_nest,
.free = (void *)netdev_dev_get_ntf_free,
},
[NETDEV_CMD_DEV_CHANGE_NTF] = {
.alloc_sz = sizeof(struct netdev_dev_get_ntf),
.cb = netdev_dev_get_rsp_parse,
.policy = &netdev_dev_nest,
.free = (void *)netdev_dev_get_ntf_free,
},
[NETDEV_CMD_PAGE_POOL_ADD_NTF] = {
.alloc_sz = sizeof(struct netdev_page_pool_get_ntf),
.cb = netdev_page_pool_get_rsp_parse,
.policy = &netdev_page_pool_nest,
.free = (void *)netdev_page_pool_get_ntf_free,
},
[NETDEV_CMD_PAGE_POOL_DEL_NTF] = {
.alloc_sz = sizeof(struct netdev_page_pool_get_ntf),
.cb = netdev_page_pool_get_rsp_parse,
.policy = &netdev_page_pool_nest,
.free = (void *)netdev_page_pool_get_ntf_free,
},
[NETDEV_CMD_PAGE_POOL_CHANGE_NTF] = {
.alloc_sz = sizeof(struct netdev_page_pool_get_ntf),
.cb = netdev_page_pool_get_rsp_parse,
.policy = &netdev_page_pool_nest,
.free = (void *)netdev_page_pool_get_ntf_free,
},
};
const struct ynl_family ynl_netdev_family = {
.name = "netdev",
.ntf_info = netdev_ntf_info,
.ntf_info_size = MNL_ARRAY_SIZE(netdev_ntf_info),
};
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
/* Do not edit directly, auto-generated from: */
/* Documentation/netlink/specs/netdev.yaml */
/* YNL-GEN user header */
#ifndef _LINUX_NETDEV_GEN_H
#define _LINUX_NETDEV_GEN_H
#include <stdlib.h>
#include <string.h>
#include <linux/types.h>
#include <linux/netdev.h>
struct ynl_sock;
extern const struct ynl_family ynl_netdev_family;
/* Enums */
const char *netdev_op_str(int op);
const char *netdev_xdp_act_str(enum netdev_xdp_act value);
const char *netdev_xdp_rx_metadata_str(enum netdev_xdp_rx_metadata value);
const char *netdev_xsk_flags_str(enum netdev_xsk_flags value);
const char *netdev_queue_type_str(enum netdev_queue_type value);
/* Common nested types */
struct netdev_page_pool_info {
struct {
__u32 id:1;
__u32 ifindex:1;
} _present;
__u64 id;
__u32 ifindex;
};
/* ============== NETDEV_CMD_DEV_GET ============== */
/* NETDEV_CMD_DEV_GET - do */
struct netdev_dev_get_req {
struct {
__u32 ifindex:1;
} _present;
__u32 ifindex;
};
static inline struct netdev_dev_get_req *netdev_dev_get_req_alloc(void)
{
return calloc(1, sizeof(struct netdev_dev_get_req));
}
void netdev_dev_get_req_free(struct netdev_dev_get_req *req);
static inline void
netdev_dev_get_req_set_ifindex(struct netdev_dev_get_req *req, __u32 ifindex)
{
req->_present.ifindex = 1;
req->ifindex = ifindex;
}
struct netdev_dev_get_rsp {
struct {
__u32 ifindex:1;
__u32 xdp_features:1;
__u32 xdp_zc_max_segs:1;
__u32 xdp_rx_metadata_features:1;
__u32 xsk_features:1;
} _present;
__u32 ifindex;
__u64 xdp_features;
__u32 xdp_zc_max_segs;
__u64 xdp_rx_metadata_features;
__u64 xsk_features;
};
void netdev_dev_get_rsp_free(struct netdev_dev_get_rsp *rsp);
/*
* Get / dump information about a netdev.
*/
struct netdev_dev_get_rsp *
netdev_dev_get(struct ynl_sock *ys, struct netdev_dev_get_req *req);
/* NETDEV_CMD_DEV_GET - dump */
struct netdev_dev_get_list {
struct netdev_dev_get_list *next;
struct netdev_dev_get_rsp obj __attribute__((aligned(8)));
};
void netdev_dev_get_list_free(struct netdev_dev_get_list *rsp);
struct netdev_dev_get_list *netdev_dev_get_dump(struct ynl_sock *ys);
/* NETDEV_CMD_DEV_GET - notify */
struct netdev_dev_get_ntf {
__u16 family;
__u8 cmd;
struct ynl_ntf_base_type *next;
void (*free)(struct netdev_dev_get_ntf *ntf);
struct netdev_dev_get_rsp obj __attribute__((aligned(8)));
};
void netdev_dev_get_ntf_free(struct netdev_dev_get_ntf *rsp);
/* ============== NETDEV_CMD_PAGE_POOL_GET ============== */
/* NETDEV_CMD_PAGE_POOL_GET - do */
struct netdev_page_pool_get_req {
struct {
__u32 id:1;
} _present;
__u64 id;
};
static inline struct netdev_page_pool_get_req *
netdev_page_pool_get_req_alloc(void)
{
return calloc(1, sizeof(struct netdev_page_pool_get_req));
}
void netdev_page_pool_get_req_free(struct netdev_page_pool_get_req *req);
static inline void
netdev_page_pool_get_req_set_id(struct netdev_page_pool_get_req *req, __u64 id)
{
req->_present.id = 1;
req->id = id;
}
struct netdev_page_pool_get_rsp {
struct {
__u32 id:1;
__u32 ifindex:1;
__u32 napi_id:1;
__u32 inflight:1;
__u32 inflight_mem:1;
__u32 detach_time:1;
} _present;
__u64 id;
__u32 ifindex;
__u64 napi_id;
__u64 inflight;
__u64 inflight_mem;
__u64 detach_time;
};
void netdev_page_pool_get_rsp_free(struct netdev_page_pool_get_rsp *rsp);
/*
* Get / dump information about Page Pools.
(Only Page Pools associated with a net_device can be listed.)
*/
struct netdev_page_pool_get_rsp *
netdev_page_pool_get(struct ynl_sock *ys, struct netdev_page_pool_get_req *req);
/* NETDEV_CMD_PAGE_POOL_GET - dump */
struct netdev_page_pool_get_list {
struct netdev_page_pool_get_list *next;
struct netdev_page_pool_get_rsp obj __attribute__((aligned(8)));
};
void netdev_page_pool_get_list_free(struct netdev_page_pool_get_list *rsp);
struct netdev_page_pool_get_list *
netdev_page_pool_get_dump(struct ynl_sock *ys);
/* NETDEV_CMD_PAGE_POOL_GET - notify */
struct netdev_page_pool_get_ntf {
__u16 family;
__u8 cmd;
struct ynl_ntf_base_type *next;
void (*free)(struct netdev_page_pool_get_ntf *ntf);
struct netdev_page_pool_get_rsp obj __attribute__((aligned(8)));
};
void netdev_page_pool_get_ntf_free(struct netdev_page_pool_get_ntf *rsp);
/* ============== NETDEV_CMD_PAGE_POOL_STATS_GET ============== */
/* NETDEV_CMD_PAGE_POOL_STATS_GET - do */
struct netdev_page_pool_stats_get_req {
struct {
__u32 info:1;
} _present;
struct netdev_page_pool_info info;
};
static inline struct netdev_page_pool_stats_get_req *
netdev_page_pool_stats_get_req_alloc(void)
{
return calloc(1, sizeof(struct netdev_page_pool_stats_get_req));
}
void
netdev_page_pool_stats_get_req_free(struct netdev_page_pool_stats_get_req *req);
static inline void
netdev_page_pool_stats_get_req_set_info_id(struct netdev_page_pool_stats_get_req *req,
__u64 id)
{
req->_present.info = 1;
req->info._present.id = 1;
req->info.id = id;
}
static inline void
netdev_page_pool_stats_get_req_set_info_ifindex(struct netdev_page_pool_stats_get_req *req,
__u32 ifindex)
{
req->_present.info = 1;
req->info._present.ifindex = 1;
req->info.ifindex = ifindex;
}
struct netdev_page_pool_stats_get_rsp {
struct {
__u32 info:1;
__u32 alloc_fast:1;
__u32 alloc_slow:1;
__u32 alloc_slow_high_order:1;
__u32 alloc_empty:1;
__u32 alloc_refill:1;
__u32 alloc_waive:1;
__u32 recycle_cached:1;
__u32 recycle_cache_full:1;
__u32 recycle_ring:1;
__u32 recycle_ring_full:1;
__u32 recycle_released_refcnt:1;
} _present;
struct netdev_page_pool_info info;
__u64 alloc_fast;
__u64 alloc_slow;
__u64 alloc_slow_high_order;
__u64 alloc_empty;
__u64 alloc_refill;
__u64 alloc_waive;
__u64 recycle_cached;
__u64 recycle_cache_full;
__u64 recycle_ring;
__u64 recycle_ring_full;
__u64 recycle_released_refcnt;
};
void
netdev_page_pool_stats_get_rsp_free(struct netdev_page_pool_stats_get_rsp *rsp);
/*
* Get page pool statistics.
*/
struct netdev_page_pool_stats_get_rsp *
netdev_page_pool_stats_get(struct ynl_sock *ys,
struct netdev_page_pool_stats_get_req *req);
/* NETDEV_CMD_PAGE_POOL_STATS_GET - dump */
struct netdev_page_pool_stats_get_list {
struct netdev_page_pool_stats_get_list *next;
struct netdev_page_pool_stats_get_rsp obj __attribute__((aligned(8)));
};
void
netdev_page_pool_stats_get_list_free(struct netdev_page_pool_stats_get_list *rsp);
struct netdev_page_pool_stats_get_list *
netdev_page_pool_stats_get_dump(struct ynl_sock *ys);
/* ============== NETDEV_CMD_QUEUE_GET ============== */
/* NETDEV_CMD_QUEUE_GET - do */
struct netdev_queue_get_req {
struct {
__u32 ifindex:1;
__u32 type:1;
__u32 id:1;
} _present;
__u32 ifindex;
enum netdev_queue_type type;
__u32 id;
};
static inline struct netdev_queue_get_req *netdev_queue_get_req_alloc(void)
{
return calloc(1, sizeof(struct netdev_queue_get_req));
}
void netdev_queue_get_req_free(struct netdev_queue_get_req *req);
static inline void
netdev_queue_get_req_set_ifindex(struct netdev_queue_get_req *req,
__u32 ifindex)
{
req->_present.ifindex = 1;
req->ifindex = ifindex;
}
static inline void
netdev_queue_get_req_set_type(struct netdev_queue_get_req *req,
enum netdev_queue_type type)
{
req->_present.type = 1;
req->type = type;
}
static inline void
netdev_queue_get_req_set_id(struct netdev_queue_get_req *req, __u32 id)
{
req->_present.id = 1;
req->id = id;
}
struct netdev_queue_get_rsp {
struct {
__u32 id:1;
__u32 type:1;
__u32 napi_id:1;
__u32 ifindex:1;
} _present;
__u32 id;
enum netdev_queue_type type;
__u32 napi_id;
__u32 ifindex;
};
void netdev_queue_get_rsp_free(struct netdev_queue_get_rsp *rsp);
/*
* Get queue information from the kernel. Only configured queues will be reported (as opposed to all available hardware queues).
*/
struct netdev_queue_get_rsp *
netdev_queue_get(struct ynl_sock *ys, struct netdev_queue_get_req *req);
/* NETDEV_CMD_QUEUE_GET - dump */
struct netdev_queue_get_req_dump {
struct {
__u32 ifindex:1;
} _present;
__u32 ifindex;
};
static inline struct netdev_queue_get_req_dump *
netdev_queue_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct netdev_queue_get_req_dump));
}
void netdev_queue_get_req_dump_free(struct netdev_queue_get_req_dump *req);
static inline void
netdev_queue_get_req_dump_set_ifindex(struct netdev_queue_get_req_dump *req,
__u32 ifindex)
{
req->_present.ifindex = 1;
req->ifindex = ifindex;
}
struct netdev_queue_get_list {
struct netdev_queue_get_list *next;
struct netdev_queue_get_rsp obj __attribute__((aligned(8)));
};
void netdev_queue_get_list_free(struct netdev_queue_get_list *rsp);
struct netdev_queue_get_list *
netdev_queue_get_dump(struct ynl_sock *ys,
struct netdev_queue_get_req_dump *req);
/* ============== NETDEV_CMD_NAPI_GET ============== */
/* NETDEV_CMD_NAPI_GET - do */
struct netdev_napi_get_req {
struct {
__u32 id:1;
} _present;
__u32 id;
};
static inline struct netdev_napi_get_req *netdev_napi_get_req_alloc(void)
{
return calloc(1, sizeof(struct netdev_napi_get_req));
}
void netdev_napi_get_req_free(struct netdev_napi_get_req *req);
static inline void
netdev_napi_get_req_set_id(struct netdev_napi_get_req *req, __u32 id)
{
req->_present.id = 1;
req->id = id;
}
struct netdev_napi_get_rsp {
struct {
__u32 id:1;
__u32 ifindex:1;
__u32 irq:1;
__u32 pid:1;
} _present;
__u32 id;
__u32 ifindex;
__u32 irq;
__u32 pid;
};
void netdev_napi_get_rsp_free(struct netdev_napi_get_rsp *rsp);
/*
* Get information about NAPI instances configured on the system.
*/
struct netdev_napi_get_rsp *
netdev_napi_get(struct ynl_sock *ys, struct netdev_napi_get_req *req);
/* NETDEV_CMD_NAPI_GET - dump */
struct netdev_napi_get_req_dump {
struct {
__u32 ifindex:1;
} _present;
__u32 ifindex;
};
static inline struct netdev_napi_get_req_dump *
netdev_napi_get_req_dump_alloc(void)
{
return calloc(1, sizeof(struct netdev_napi_get_req_dump));
}
void netdev_napi_get_req_dump_free(struct netdev_napi_get_req_dump *req);
static inline void
netdev_napi_get_req_dump_set_ifindex(struct netdev_napi_get_req_dump *req,
__u32 ifindex)
{
req->_present.ifindex = 1;
req->ifindex = ifindex;
}
struct netdev_napi_get_list {
struct netdev_napi_get_list *next;
struct netdev_napi_get_rsp obj __attribute__((aligned(8)));
};
void netdev_napi_get_list_free(struct netdev_napi_get_list *rsp);
struct netdev_napi_get_list *
netdev_napi_get_dump(struct ynl_sock *ys, struct netdev_napi_get_req_dump *req);
#endif /* _LINUX_NETDEV_GEN_H */
// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
/* Do not edit directly, auto-generated from: */
/* Documentation/netlink/specs/nfsd.yaml */
/* YNL-GEN user source */
#include <stdlib.h>
#include <string.h>
#include "nfsd-user.h"
#include "ynl.h"
#include <linux/nfsd_netlink.h>
#include <libmnl/libmnl.h>
#include <linux/genetlink.h>
/* Enums */
static const char * const nfsd_op_strmap[] = {
[NFSD_CMD_RPC_STATUS_GET] = "rpc-status-get",
};
const char *nfsd_op_str(int op)
{
if (op < 0 || op >= (int)MNL_ARRAY_SIZE(nfsd_op_strmap))
return NULL;
return nfsd_op_strmap[op];
}
/* Policies */
struct ynl_policy_attr nfsd_rpc_status_policy[NFSD_A_RPC_STATUS_MAX + 1] = {
[NFSD_A_RPC_STATUS_XID] = { .name = "xid", .type = YNL_PT_U32, },
[NFSD_A_RPC_STATUS_FLAGS] = { .name = "flags", .type = YNL_PT_U32, },
[NFSD_A_RPC_STATUS_PROG] = { .name = "prog", .type = YNL_PT_U32, },
[NFSD_A_RPC_STATUS_VERSION] = { .name = "version", .type = YNL_PT_U8, },
[NFSD_A_RPC_STATUS_PROC] = { .name = "proc", .type = YNL_PT_U32, },
[NFSD_A_RPC_STATUS_SERVICE_TIME] = { .name = "service_time", .type = YNL_PT_U64, },
[NFSD_A_RPC_STATUS_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, },
[NFSD_A_RPC_STATUS_SADDR4] = { .name = "saddr4", .type = YNL_PT_U32, },
[NFSD_A_RPC_STATUS_DADDR4] = { .name = "daddr4", .type = YNL_PT_U32, },
[NFSD_A_RPC_STATUS_SADDR6] = { .name = "saddr6", .type = YNL_PT_BINARY,},
[NFSD_A_RPC_STATUS_DADDR6] = { .name = "daddr6", .type = YNL_PT_BINARY,},
[NFSD_A_RPC_STATUS_SPORT] = { .name = "sport", .type = YNL_PT_U16, },
[NFSD_A_RPC_STATUS_DPORT] = { .name = "dport", .type = YNL_PT_U16, },
[NFSD_A_RPC_STATUS_COMPOUND_OPS] = { .name = "compound-ops", .type = YNL_PT_U32, },
};
struct ynl_policy_nest nfsd_rpc_status_nest = {
.max_attr = NFSD_A_RPC_STATUS_MAX,
.table = nfsd_rpc_status_policy,
};
/* Common nested types */
/* ============== NFSD_CMD_RPC_STATUS_GET ============== */
/* NFSD_CMD_RPC_STATUS_GET - dump */
int nfsd_rpc_status_get_rsp_dump_parse(const struct nlmsghdr *nlh, void *data)
{
struct nfsd_rpc_status_get_rsp_dump *dst;
struct ynl_parse_arg *yarg = data;
unsigned int n_compound_ops = 0;
const struct nlattr *attr;
int i;
dst = yarg->data;
if (dst->compound_ops)
return ynl_error_parse(yarg, "attribute already present (rpc-status.compound-ops)");
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
unsigned int type = mnl_attr_get_type(attr);
if (type == NFSD_A_RPC_STATUS_XID) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.xid = 1;
dst->xid = mnl_attr_get_u32(attr);
} else if (type == NFSD_A_RPC_STATUS_FLAGS) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.flags = 1;
dst->flags = mnl_attr_get_u32(attr);
} else if (type == NFSD_A_RPC_STATUS_PROG) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.prog = 1;
dst->prog = mnl_attr_get_u32(attr);
} else if (type == NFSD_A_RPC_STATUS_VERSION) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.version = 1;
dst->version = mnl_attr_get_u8(attr);
} else if (type == NFSD_A_RPC_STATUS_PROC) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.proc = 1;
dst->proc = mnl_attr_get_u32(attr);
} else if (type == NFSD_A_RPC_STATUS_SERVICE_TIME) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.service_time = 1;
dst->service_time = mnl_attr_get_u64(attr);
} else if (type == NFSD_A_RPC_STATUS_SADDR4) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.saddr4 = 1;
dst->saddr4 = mnl_attr_get_u32(attr);
} else if (type == NFSD_A_RPC_STATUS_DADDR4) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.daddr4 = 1;
dst->daddr4 = mnl_attr_get_u32(attr);
} else if (type == NFSD_A_RPC_STATUS_SADDR6) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = mnl_attr_get_payload_len(attr);
dst->_present.saddr6_len = len;
dst->saddr6 = malloc(len);
memcpy(dst->saddr6, mnl_attr_get_payload(attr), len);
} else if (type == NFSD_A_RPC_STATUS_DADDR6) {
unsigned int len;
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
len = mnl_attr_get_payload_len(attr);
dst->_present.daddr6_len = len;
dst->daddr6 = malloc(len);
memcpy(dst->daddr6, mnl_attr_get_payload(attr), len);
} else if (type == NFSD_A_RPC_STATUS_SPORT) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.sport = 1;
dst->sport = mnl_attr_get_u16(attr);
} else if (type == NFSD_A_RPC_STATUS_DPORT) {
if (ynl_attr_validate(yarg, attr))
return MNL_CB_ERROR;
dst->_present.dport = 1;
dst->dport = mnl_attr_get_u16(attr);
} else if (type == NFSD_A_RPC_STATUS_COMPOUND_OPS) {
n_compound_ops++;
}
}
if (n_compound_ops) {
dst->compound_ops = calloc(n_compound_ops, sizeof(*dst->compound_ops));
dst->n_compound_ops = n_compound_ops;
i = 0;
mnl_attr_for_each(attr, nlh, sizeof(struct genlmsghdr)) {
if (mnl_attr_get_type(attr) == NFSD_A_RPC_STATUS_COMPOUND_OPS) {
dst->compound_ops[i] = mnl_attr_get_u32(attr);
i++;
}
}
}
return MNL_CB_OK;
}
void
nfsd_rpc_status_get_rsp_list_free(struct nfsd_rpc_status_get_rsp_list *rsp)
{
struct nfsd_rpc_status_get_rsp_list *next = rsp;
while ((void *)next != YNL_LIST_END) {
rsp = next;
next = rsp->next;
free(rsp->obj.saddr6);
free(rsp->obj.daddr6);
free(rsp->obj.compound_ops);
free(rsp);
}
}
struct nfsd_rpc_status_get_rsp_list *
nfsd_rpc_status_get_dump(struct ynl_sock *ys)
{
struct ynl_dump_state yds = {};
struct nlmsghdr *nlh;
int err;
yds.ys = ys;
yds.alloc_sz = sizeof(struct nfsd_rpc_status_get_rsp_list);
yds.cb = nfsd_rpc_status_get_rsp_dump_parse;
yds.rsp_cmd = NFSD_CMD_RPC_STATUS_GET;
yds.rsp_policy = &nfsd_rpc_status_nest;
nlh = ynl_gemsg_start_dump(ys, ys->family_id, NFSD_CMD_RPC_STATUS_GET, 1);
err = ynl_exec_dump(ys, nlh, &yds);
if (err < 0)
goto free_list;
return yds.first;
free_list:
nfsd_rpc_status_get_rsp_list_free(yds.first);
return NULL;
}
const struct ynl_family ynl_nfsd_family = {
.name = "nfsd",
};
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
/* Do not edit directly, auto-generated from: */
/* Documentation/netlink/specs/nfsd.yaml */
/* YNL-GEN user header */
#ifndef _LINUX_NFSD_GEN_H
#define _LINUX_NFSD_GEN_H
#include <stdlib.h>
#include <string.h>
#include <linux/types.h>
#include <linux/nfsd_netlink.h>
struct ynl_sock;
extern const struct ynl_family ynl_nfsd_family;
/* Enums */
const char *nfsd_op_str(int op);
/* Common nested types */
/* ============== NFSD_CMD_RPC_STATUS_GET ============== */
/* NFSD_CMD_RPC_STATUS_GET - dump */
struct nfsd_rpc_status_get_rsp_dump {
struct {
__u32 xid:1;
__u32 flags:1;
__u32 prog:1;
__u32 version:1;
__u32 proc:1;
__u32 service_time:1;
__u32 saddr4:1;
__u32 daddr4:1;
__u32 saddr6_len;
__u32 daddr6_len;
__u32 sport:1;
__u32 dport:1;
} _present;
__u32 xid /* big-endian */;
__u32 flags;
__u32 prog;
__u8 version;
__u32 proc;
__s64 service_time;
__u32 saddr4 /* big-endian */;
__u32 daddr4 /* big-endian */;
void *saddr6;
void *daddr6;
__u16 sport /* big-endian */;
__u16 dport /* big-endian */;
unsigned int n_compound_ops;
__u32 *compound_ops;
};
struct nfsd_rpc_status_get_rsp_list {
struct nfsd_rpc_status_get_rsp_list *next;
struct nfsd_rpc_status_get_rsp_dump obj __attribute__((aligned(8)));
};
void
nfsd_rpc_status_get_rsp_list_free(struct nfsd_rpc_status_get_rsp_list *rsp);
struct nfsd_rpc_status_get_rsp_list *
nfsd_rpc_status_get_dump(struct ynl_sock *ys);
#endif /* _LINUX_NFSD_GEN_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment