diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2021-08-03 20:00:35 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2021-08-03 18:00:35 +0000 |
commit | ac0b2235e4cc11934a8f2cfee81771e192e984c1 (patch) | |
tree | 7b4992db44f0d3dacc659942e086002ca9040939 | |
parent | a9977b6e7f9c46b817eb38e7bdffa659da9cbda5 (diff) | |
download | strace-ac0b2235e4cc11934a8f2cfee81771e192e984c1.tar.gz |
rtnl_link: decode IFLA_PARENT_DEV{,_BUS}_NAME attributes
Introduced by Linux commit v5.14-rc1~119^2~191^2~2.
* src/rtnl_link.c (ifinfomsg_nla_decoders) <[IFLA_PARENT_DEV_NAME],
[IFLA_PARENT_DEV_BUS_NAME]>: New decoders, call decode_nla_str.
* src/xlat/rtnl_link_attrs.in (IFLA_PARENT_DEV_NAME,
IFLA_PARENT_DEV_BUS_NAME): New constants.
* tests/nlattr_ifinfomsg.c: Add checks.
-rw-r--r-- | src/rtnl_link.c | 2 | ||||
-rw-r--r-- | src/xlat/rtnl_link_attrs.in | 2 | ||||
-rw-r--r-- | tests/nlattr_ifinfomsg.c | 36 |
3 files changed, 27 insertions, 13 deletions
diff --git a/src/rtnl_link.c b/src/rtnl_link.c index 2769ad917..f6f585d4d 100644 --- a/src/rtnl_link.c +++ b/src/rtnl_link.c @@ -1003,6 +1003,8 @@ static const nla_decoder_t ifinfomsg_nla_decoders[] = { [IFLA_ALT_IFNAME] = decode_nla_str, [IFLA_PERM_ADDRESS] = decode_ifla_hwaddr, [IFLA_PROTO_DOWN_REASON] = decode_ifla_proto_down_reason, + [IFLA_PARENT_DEV_NAME] = decode_nla_str, + [IFLA_PARENT_DEV_BUS_NAME] = decode_nla_str, }; DECL_NETLINK_ROUTE_DECODER(decode_ifinfomsg) diff --git a/src/xlat/rtnl_link_attrs.in b/src/xlat/rtnl_link_attrs.in index 16f1bbb2c..6649d232f 100644 --- a/src/xlat/rtnl_link_attrs.in +++ b/src/xlat/rtnl_link_attrs.in @@ -56,3 +56,5 @@ IFLA_PROP_LIST IFLA_ALT_IFNAME IFLA_PERM_ADDRESS IFLA_PROTO_DOWN_REASON +IFLA_PARENT_DEV_NAME +IFLA_PARENT_DEV_BUS_NAME diff --git a/tests/nlattr_ifinfomsg.c b/tests/nlattr_ifinfomsg.c index ff09dc1cd..c09ea9dd4 100644 --- a/tests/nlattr_ifinfomsg.c +++ b/tests/nlattr_ifinfomsg.c @@ -446,20 +446,30 @@ main(void) print_quoted_memory(&buf, sizeof(buf)); printf("...")); - /* IFLA_ALT_IFNAME */ - static const char alt_ifname[] = "OH HAI THAR\r\n\t\377\0\v\x7e"; - TEST_NLATTR(fd, nlh0, hdrlen, - init_ifinfomsg, print_ifinfomsg, - IFLA_ALT_IFNAME, - sizeof(alt_ifname), alt_ifname, sizeof(alt_ifname), - print_quoted_memory(alt_ifname, sizeof(alt_ifname) - 1)); + /* IFLA_ALT_IFNAME, IFLA_PARENT_DEV_NAME, IFLA_PARENT_DEV_BUS_NAME */ + static const char str[] = "OH HAI THAR\r\n\t\377\0\v\x7e"; + static const struct { + uint32_t val; + const char *str; + } attrs[] = { + { ARG_STR(IFLA_ALT_IFNAME) }, + { ARG_STR(IFLA_PARENT_DEV_NAME) }, + { ARG_STR(IFLA_PARENT_DEV_BUS_NAME) }, + }; + for (size_t i = 0; i < ARRAY_SIZE(attrs); i++) { + TEST_NLATTR_(fd, nlh0, hdrlen, + init_ifinfomsg, print_ifinfomsg, + attrs[i].val, attrs[i].str, + sizeof(str), str, sizeof(str), + print_quoted_memory(str, sizeof(str) - 1)); - TEST_NLATTR(fd, nlh0, hdrlen, - init_ifinfomsg, print_ifinfomsg, - IFLA_ALT_IFNAME, - sizeof(alt_ifname) - 1, alt_ifname, sizeof(alt_ifname) - 1, - print_quoted_memory(alt_ifname, sizeof(alt_ifname) - 1); - printf("...")); + TEST_NLATTR_(fd, nlh0, hdrlen, + init_ifinfomsg, print_ifinfomsg, + attrs[i].val, attrs[i].str, + sizeof(str) - 1, str, sizeof(str) - 1, + print_quoted_memory(str, sizeof(str) - 1); + printf("...")); + } puts("+++ exited with 0 +++"); return 0; |