summaryrefslogtreecommitdiff
path: root/lib/idiag
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-08-26 15:49:17 +0200
committerThomas Haller <thaller@redhat.com>2019-08-26 15:52:26 +0200
commit194069516dcd16071314c110b18c3f325eac414f (patch)
treed999af13a48c8d0a58ad05876d0bd83fceb36436 /lib/idiag
parent73c1d0479643cf743b72879084e70f738f11bded (diff)
downloadlibnl-194069516dcd16071314c110b18c3f325eac414f.tar.gz
idiag: workaround and add comment about idiagnl_send_simple() only handling 8 bit flags
Related: https://github.com/thom311/libnl/pull/222#issuecomment-521956236
Diffstat (limited to 'lib/idiag')
-rw-r--r--lib/idiag/idiag.c3
-rw-r--r--lib/idiag/idiag_msg_obj.c12
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/idiag/idiag.c b/lib/idiag/idiag.c
index cae8c1f6..23a8413a 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 9a154938..a1beb2c7 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 = {