netlink: print descriptor attributes using printfd

* nlattr.h (DECL_NLA(fd)): New prototype.
* nlattr.c (decode_nla_fd): New function.
* rtnl_link.c (ifla_xdp_nla_decoders) <IFLA_XDP_FD>: Use it.
(ifinfomsg_nla_decoders) <IFLA_NET_NS_FD>: Likewise.
* rtnl_nsid.c (rtgenmsg_nla_decoders) <NETNSA_FD>: Likewise.
* NEWS: Mention this.
This commit is contained in:
Дмитрий Левин 2017-11-15 15:30:49 +00:00
parent 252667882a
commit 300d9f1fee
5 changed files with 23 additions and 3 deletions

3
NEWS
View File

@ -1,6 +1,9 @@
Noteworthy changes in release ?.?? (????-??-??)
===============================================
* Improvements
* Implemented decoding of netlink descriptor attributes as file descriptors.
Noteworthy changes in release 4.20 (2017-11-13)
===============================================

View File

@ -207,6 +207,22 @@ decode_nla_meminfo(struct tcb *const tcp,
return true;
}
bool
decode_nla_fd(struct tcb *const tcp,
const kernel_ulong_t addr,
const unsigned int len,
const void *const opaque_data)
{
int fd;
if (len < sizeof(fd))
return false;
else if (!umove_or_printaddr(tcp, addr, &fd))
printfd(tcp, fd);
return true;
}
bool
decode_nla_ifindex(struct tcb *const tcp,
const kernel_ulong_t addr,

View File

@ -60,6 +60,7 @@ DECL_NLA(be16);
DECL_NLA(be64);
DECL_NLA(str);
DECL_NLA(strn);
DECL_NLA(fd);
DECL_NLA(ifindex);
DECL_NLA(meminfo);
DECL_NLA(rt_class);

View File

@ -356,7 +356,7 @@ decode_ifla_xdp_flags(struct tcb *const tcp,
}
static const nla_decoder_t ifla_xdp_nla_decoders[] = {
[IFLA_XDP_FD] = decode_nla_s32,
[IFLA_XDP_FD] = decode_nla_fd,
[IFLA_XDP_ATTACHED] = decode_nla_u8,
[IFLA_XDP_FLAGS] = decode_ifla_xdp_flags,
[IFLA_XDP_PROG_ID] = decode_nla_u32
@ -403,7 +403,7 @@ static const nla_decoder_t ifinfomsg_nla_decoders[] = {
[IFLA_PORT_SELF] = decode_ifla_port,
[IFLA_AF_SPEC] = NULL, /* unimplemented */
[IFLA_GROUP] = decode_nla_u32,
[IFLA_NET_NS_FD] = decode_nla_u32,
[IFLA_NET_NS_FD] = decode_nla_fd,
[IFLA_EXT_MASK] = decode_nla_u32,
[IFLA_PROMISCUITY] = decode_nla_u32,
[IFLA_NUM_TX_QUEUES] = decode_nla_u32,

View File

@ -40,7 +40,7 @@
static const nla_decoder_t rtgenmsg_nla_decoders[] = {
[NETNSA_NSID] = decode_nla_s32,
[NETNSA_PID] = decode_nla_u32,
[NETNSA_FD] = decode_nla_u32
[NETNSA_FD] = decode_nla_fd
};
DECL_NETLINK_ROUTE_DECODER(decode_rtgenmsg)