diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2018-05-18 18:08:25 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2018-06-06 15:10:37 +0000 |
commit | 4eab3a43fd90aa0a1a085d303726f385950dfc6a (patch) | |
tree | 74b446d3858dac01b8188d1b3ed7fe73e34d809d | |
parent | 1e6d5a84b89b58844aee2633831d97985e54844d (diff) | |
download | strace-4eab3a43fd90aa0a1a085d303726f385950dfc6a.tar.gz |
rtnl_link: implement IFLA_INFO_DATA for tun devices
* 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".
-rw-r--r-- | rtnl_link.c | 48 | ||||
-rw-r--r-- | xlat/rtnl_ifla_info_data_tun_attrs.in | 11 | ||||
-rw-r--r-- | xlat/tun_device_types.in | 3 |
3 files changed, 62 insertions, 0 deletions
diff --git a/rtnl_link.c b/rtnl_link.c index 41e9ba42b..24eec6850 100644 --- a/rtnl_link.c +++ b/rtnl_link.c @@ -51,12 +51,14 @@ #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 index 000000000..2ac187e3f --- /dev/null +++ b/xlat/rtnl_ifla_info_data_tun_attrs.in @@ -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 index 000000000..81af0bc15 --- /dev/null +++ b/xlat/tun_device_types.in @@ -0,0 +1,3 @@ +#value_indexed +IFF_TUN 1 +IFF_TAP 2 |