]> granicus.if.org Git - strace/commitdiff
netlink: print descriptor attributes using printfd
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 15 Nov 2017 15:30:49 +0000 (15:30 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 15 Nov 2017 15:30:49 +0000 (15:30 +0000)
* 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.

NEWS
nlattr.c
nlattr.h
rtnl_link.c
rtnl_nsid.c

diff --git a/NEWS b/NEWS
index c5150f04c4e5e2020e23fbe9c8e5322319206f75..3e95029e7618ef9c54c4f457e2c7c47a7a1094c3 100644 (file)
--- 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)
 ===============================================
 
index 6f35b99443ce665dc8e41aa6b9bddeeda0ee302e..ac430f4fe18cfefb007982d7a3913674cca99fef 100644 (file)
--- 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,
index 323f1d6b73672f0f3493318d51ae1202e427b460..00cbfd52c2adee48633d311de5cb5b0bb9320817 100644 (file)
--- 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);
index 13e56e0dcf708507d79584d6cb2f6df13cfc6cdc..46d78b6c908b0a642adbf5fcaad2183e2e1fefc8 100644 (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,
index 51ce37b41392a525cfc3fdb016bd716e3010e693..cf8cc9950b34e1361620ecc6f1528d7cb028be48 100644 (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)