From: Dmitry V. Levin Date: Wed, 15 Nov 2017 15:30:49 +0000 (+0000) Subject: netlink: print descriptor attributes using printfd X-Git-Tag: v4.21~317 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=300d9f1fee6fbd7090c605f97d82440d8a5a9b2a;p=strace 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) : Use it. (ifinfomsg_nla_decoders) : Likewise. * rtnl_nsid.c (rtgenmsg_nla_decoders) : Likewise. * NEWS: Mention this. --- diff --git a/NEWS b/NEWS index c5150f04..3e95029e 100644 --- a/NEWS +++ b/NEWS @@ -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) =============================================== diff --git a/nlattr.c b/nlattr.c index 6f35b994..ac430f4f 100644 --- a/nlattr.c +++ b/nlattr.c @@ -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, diff --git a/nlattr.h b/nlattr.h index 323f1d6b..00cbfd52 100644 --- a/nlattr.h +++ b/nlattr.h @@ -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); diff --git a/rtnl_link.c b/rtnl_link.c index 13e56e0d..46d78b6c 100644 --- a/rtnl_link.c +++ b/rtnl_link.c @@ -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, diff --git a/rtnl_nsid.c b/rtnl_nsid.c index 51ce37b4..cf8cc995 100644 --- a/rtnl_nsid.c +++ b/rtnl_nsid.c @@ -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)