diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2022-07-29 12:58:00 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2022-07-31 21:03:01 +0000 |
commit | e1965a819d7a623557268bd8cf2f22ff4e687146 (patch) | |
tree | adfad0a302ae9eee39e4bd3968611999e496594e | |
parent | dae4b8b1d6bda99d163ccbddf8879472590806f0 (diff) | |
download | strace-e1965a819d7a623557268bd8cf2f22ff4e687146.tar.gz |
rtnl_neigh: decode NDA_SRC_VNI as u32; similarly to NDA_VNI
* src/rtnl_neigh.c (ndmsg_nla_decoders) <[NDA_SRC_VNI]>: Set
to decode_nla_u32.
* tests/nlattr_ndmsg.c: Add checks.
-rw-r--r-- | src/rtnl_neigh.c | 2 | ||||
-rw-r--r-- | tests/nlattr_ndmsg.c | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/rtnl_neigh.c b/src/rtnl_neigh.c index cef703552..00e148ec8 100644 --- a/src/rtnl_neigh.c +++ b/src/rtnl_neigh.c @@ -117,7 +117,7 @@ static const nla_decoder_t ndmsg_nla_decoders[] = { [NDA_IFINDEX] = decode_nla_ifindex, [NDA_MASTER] = decode_nla_ifindex, [NDA_LINK_NETNSID] = decode_nla_u32, - [NDA_SRC_VNI] = NULL, + [NDA_SRC_VNI] = decode_nla_u32, [NDA_PROTOCOL] = decode_nla_u8, [NDA_NH_ID] = decode_nla_u32, [NDA_FDB_EXT_ATTRS] = decode_nda_fdb_ext_attrs, diff --git a/tests/nlattr_ndmsg.c b/tests/nlattr_ndmsg.c index 79ba30b42..c0a087893 100644 --- a/tests/nlattr_ndmsg.c +++ b/tests/nlattr_ndmsg.c @@ -131,6 +131,21 @@ main(void) for (unsigned int i = 0; i < sizeof(mac); ++i) printf("%s%02x", i ? ":" : "", mac[i])); + /* u32 attrs */ + static const struct strval16 u32_attrs[] = { + { ENUM_KNOWN(0x4, NDA_PROBES) }, + { ENUM_KNOWN(0x7, NDA_VNI) }, + { ENUM_KNOWN(0xa, NDA_LINK_NETNSID) }, + { ENUM_KNOWN(0xb, NDA_SRC_VNI) }, + { ENUM_KNOWN(0xd, NDA_NH_ID) }, + }; + void *nlh_u32 = midtail_alloc(NLMSG_SPACE(hdrlen), sizeof(uint32_t)); + + for (size_t i = 0; i < ARRAY_SIZE(u32_attrs); i++) { + check_u32_nlattr(fd, nlh_u32, hdrlen, init_ndmsg, print_ndmsg, + u32_attrs[i].val, u32_attrs[i].str, pattern, 0); + } + /* NDA_FDB_EXT_ATTRS: unknown, undecoded */ static const struct strval16 nfea_unk_attrs[] = { { ENUM_KNOWN(0, NFEA_UNSPEC) }, |