diff options
author | Thomas Haller <thaller@redhat.com> | 2019-08-26 13:49:17 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-08-26 13:52:26 (GMT) |
commit | 194069516dcd16071314c110b18c3f325eac414f (patch) | |
tree | d999af13a48c8d0a58ad05876d0bd83fceb36436 | |
parent | 73c1d0479643cf743b72879084e70f738f11bded (diff) | |
download | libnl-194069516dcd16071314c110b18c3f325eac414f.zip libnl-194069516dcd16071314c110b18c3f325eac414f.tar.gz libnl-194069516dcd16071314c110b18c3f325eac414f.tar.bz2 |
idiag: workaround and add comment about idiagnl_send_simple() only handling 8 bit flags
Related: https://github.com/thom311/libnl/pull/222#issuecomment-521956236
-rw-r--r-- | lib/idiag/idiag.c | 3 | ||||
-rw-r--r-- | lib/idiag/idiag_msg_obj.c | 12 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/idiag/idiag.c b/lib/idiag/idiag.c index cae8c1f..23a8413 100644 --- a/lib/idiag/idiag.c +++ b/lib/idiag/idiag.c @@ -56,7 +56,8 @@ int idiagnl_connect(struct nl_sock *sk) * @arg flags Message flags * @arg family Address family * @arg states Socket states to query - * @arg ext Inet Diag attribute extensions to query + * @arg ext Inet Diag attribute extensions to query. Note that this only supports + * 8 bit arguments. Flags outside uint8_t range are silently ignored. * * @return 0 on success or a negative error code. Due to a bug, this function * returns the number of bytes sent. Treat any non-negative number as success. diff --git a/lib/idiag/idiag_msg_obj.c b/lib/idiag/idiag_msg_obj.c index 9a15493..a1beb2c 100644 --- a/lib/idiag/idiag_msg_obj.c +++ b/lib/idiag/idiag_msg_obj.c @@ -90,7 +90,17 @@ static int idiagnl_request_update(struct nl_cache *cache, struct nl_sock *sk) int family = cache->c_iarg1; int states = cache->c_iarg2; - return idiagnl_send_simple(sk, 0, family, states, _INET_DIAG_ALL); + /* idiagnl_send_simple()'s "ext" argument is u16, which is too small for _INET_DIAG_ALL, + * which is more than 16 bits on recent kernels. + * + * Actually, internally idiagnl_send_simple() sets "struct inet_diag_req"'s "idiag_ext" + * field, which is only 8 bits. So, it's even worse. + * + * FIXME: this probably should be fixed (by adding idiagnl_send_simple2() function), but for + * the moment it means we cannot request more than 0xFF. + */ + + return idiagnl_send_simple(sk, 0, family, states, (uint16_t) _INET_DIAG_ALL); } static struct nl_cache_ops idiagnl_msg_ops = { |