From 7c58513246ce5c436b344790cdb1e34037b9a4e4 Mon Sep 17 00:00:00 2001 From: Jason Dellaluce Date: Tue, 11 Jun 2024 17:46:05 +0000 Subject: [PATCH 1/3] fix(userspace/libsinsp)!: return truthful data in 'type' exported field of fd tables Note, this is a potential breaking change due to the type of the exported field needing to change. However, whoever tried to access this information up until now have accessed random byte blobs, so this is effectively breaking something that never worked since its first release. Signed-off-by: Jason Dellaluce --- userspace/libsinsp/fdinfo.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/userspace/libsinsp/fdinfo.cpp b/userspace/libsinsp/fdinfo.cpp index 39448d3acc..302b31bac1 100644 --- a/userspace/libsinsp/fdinfo.cpp +++ b/userspace/libsinsp/fdinfo.cpp @@ -131,7 +131,18 @@ sinsp_fdinfo::sinsp_fdinfo(std::shared_ptr Date: Tue, 11 Jun 2024 17:48:04 +0000 Subject: [PATCH 2/3] update(userspace/libsinsp): export 'fd' field in fdtables Signed-off-by: Jason Dellaluce --- userspace/libsinsp/fdinfo.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/userspace/libsinsp/fdinfo.cpp b/userspace/libsinsp/fdinfo.cpp index 302b31bac1..af127b4164 100644 --- a/userspace/libsinsp/fdinfo.cpp +++ b/userspace/libsinsp/fdinfo.cpp @@ -152,6 +152,7 @@ libsinsp::state::static_struct::field_infos sinsp_fdinfo::static_fields() const define_static_field(ret, this, m_mount_id, "mount_id"); define_static_field(ret, this, m_ino, "ino"); define_static_field(ret, this, m_pid, "pid"); + define_static_field(ret, this, m_fd, "fd"); // in this case we have a union, so many of the following exposed fields // will point to the same memory areas, but this should not be an issue @@ -176,6 +177,7 @@ libsinsp::state::static_struct::field_infos sinsp_fdinfo::static_fields() const define_static_field(ret, this, m_sockinfo.m_ipv6serverinfo.m_l4proto, "socket_ipv6_server_l4_proto"); define_static_field(ret, this, m_sockinfo.m_unixinfo.m_fields.m_source, "socket_unix_src"); define_static_field(ret, this, m_sockinfo.m_unixinfo.m_fields.m_dest, "socket_unix_dest"); + return ret; } From 03eea673fb88a1ae0bd57ff1f4152ca9114d3375 Mon Sep 17 00:00:00 2001 From: Jason Dellaluce Date: Tue, 11 Jun 2024 20:34:50 +0000 Subject: [PATCH 3/3] test(userpsace/libsinsp): update subtable tests Signed-off-by: Jason Dellaluce --- userspace/libsinsp/test/state.ut.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/userspace/libsinsp/test/state.ut.cpp b/userspace/libsinsp/test/state.ut.cpp index 50d5f01ffc..4d3334a7ef 100644 --- a/userspace/libsinsp/test/state.ut.cpp +++ b/userspace/libsinsp/test/state.ut.cpp @@ -394,7 +394,7 @@ TEST(thread_manager, table_access) TEST(thread_manager, fdtable_access) { // note: used for regression checks, keep this updated as we make new fields available - static const int s_fdinfo_static_fields_count = 31; + static const int s_fdinfo_static_fields_count = 32; sinsp inspector; auto& reg = inspector.get_table_registry();