]> granicus.if.org Git - strace/commitdiff
rtnl_link: implement IFLA_INFO_DATA for tun devices
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 18 May 2018 16:08:25 +0000 (18:08 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 6 Jun 2018 15:10:37 +0000 (15:10 +0000)
* xlat/rtnl_ifla_info_data_tun_attrs.in: New file.
* xlat/tun_device_types.in: Likewise.
* rtnl_link.c: Include xlat/rtnl_ifla_info_data_tun_attrs.h and
xlat/tun_device_types.h.
(decode_nla_tun_type, decode_nla_linkinfo_data_tun): New functions.
(ifla_info_data_tun_nla_decoders): New decoder dispatcher table.
(decode_nla_linkinfo_data): Use decode_nla_linkinfo_data_tun if kind
is
"tun".

rtnl_link.c
xlat/rtnl_ifla_info_data_tun_attrs.in [new file with mode: 0644]
xlat/tun_device_types.in [new file with mode: 0644]

index 41e9ba42be66196fc60c7005dc6515088fad2c8c..24eec685084db960bd8673e7929c2bc3ca91ab05 100644 (file)
 #include "xlat/rtnl_ifla_events.h"
 #include "xlat/rtnl_ifla_info_attrs.h"
 #include "xlat/rtnl_ifla_info_data_bridge_attrs.h"
+#include "xlat/rtnl_ifla_info_data_tun_attrs.h"
 #include "xlat/rtnl_ifla_port_attrs.h"
 #include "xlat/rtnl_ifla_vf_port_attrs.h"
 #include "xlat/rtnl_ifla_xdp_attrs.h"
 #include "xlat/rtnl_link_attrs.h"
 #include "xlat/snmp_icmp6_stats.h"
 #include "xlat/snmp_ip_stats.h"
+#include "xlat/tun_device_types.h"
 #include "xlat/xdp_flags.h"
 
 static bool
@@ -344,6 +346,50 @@ decode_nla_linkinfo_data_bridge(struct tcb *const tcp,
        return true;
 }
 
+static bool
+decode_nla_tun_type(struct tcb *const tcp,
+                   const kernel_ulong_t addr,
+                   const unsigned int len,
+                   const void *const opaque_data)
+{
+       const struct decode_nla_xlat_opts opts = {
+               .xlat = tun_device_types,
+               .xlat_size = ARRAY_SIZE(tun_device_types),
+               .xt = XT_INDEXED,
+               .dflt = "IFF_???",
+               .size = 1,
+       };
+
+       return decode_nla_xval(tcp, addr, len, &opts);
+}
+
+static const nla_decoder_t ifla_info_data_tun_nla_decoders[] = {
+       [IFLA_TUN_UNSPEC]               = NULL,
+       [IFLA_TUN_OWNER]                = decode_nla_uid,
+       [IFLA_TUN_GROUP]                = decode_nla_gid,
+       [IFLA_TUN_TYPE]                 = decode_nla_tun_type,
+       [IFLA_TUN_PI]                   = decode_nla_u8,
+       [IFLA_TUN_VNET_HDR]             = decode_nla_u8,
+       [IFLA_TUN_PERSIST]              = decode_nla_u8,
+       [IFLA_TUN_MULTI_QUEUE]          = decode_nla_u8,
+       [IFLA_TUN_NUM_QUEUES]           = decode_nla_u32,
+       [IFLA_TUN_NUM_DISABLED_QUEUES]  = decode_nla_u32,
+};
+
+bool
+decode_nla_linkinfo_data_tun(struct tcb *const tcp,
+                            const kernel_ulong_t addr,
+                            const unsigned int len,
+                            const void *const opaque_data)
+{
+       decode_nlattr(tcp, addr, len, rtnl_ifla_info_data_tun_attrs,
+                     "IFLA_TUN_???", ifla_info_data_tun_nla_decoders,
+                     ARRAY_SIZE(rtnl_ifla_info_data_tun_attrs),
+                     opaque_data);
+
+       return true;
+}
+
 bool
 decode_nla_linkinfo_data(struct tcb *const tcp,
                         const kernel_ulong_t addr,
@@ -355,6 +401,8 @@ decode_nla_linkinfo_data(struct tcb *const tcp,
 
        if (!strcmp(ctx->kind, "bridge"))
                func = decode_nla_linkinfo_data_bridge;
+       else if (!strcmp(ctx->kind, "tun"))
+               func = decode_nla_linkinfo_data_tun;
 
        if (func)
                return func(tcp, addr, len, opaque_data);
diff --git a/xlat/rtnl_ifla_info_data_tun_attrs.in b/xlat/rtnl_ifla_info_data_tun_attrs.in
new file mode 100644 (file)
index 0000000..2ac187e
--- /dev/null
@@ -0,0 +1,11 @@
+#value_indexed
+IFLA_TUN_UNSPEC                        0
+IFLA_TUN_OWNER                 1
+IFLA_TUN_GROUP                 2
+IFLA_TUN_TYPE                  3
+IFLA_TUN_PI                    4
+IFLA_TUN_VNET_HDR              5
+IFLA_TUN_PERSIST               6
+IFLA_TUN_MULTI_QUEUE           7
+IFLA_TUN_NUM_QUEUES            8
+IFLA_TUN_NUM_DISABLED_QUEUES   9
diff --git a/xlat/tun_device_types.in b/xlat/tun_device_types.in
new file mode 100644 (file)
index 0000000..81af0bc
--- /dev/null
@@ -0,0 +1,3 @@
+#value_indexed
+IFF_TUN        1
+IFF_TAP 2