summaryrefslogtreecommitdiff
path: root/include/trace/bpf_probe.h
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2022-01-11 20:43:55 +0300
committerChuck Lever <chuck.lever@oracle.com>2022-02-28 18:26:38 +0300
commitd07c9ad622474616e94572e59e725c2c4a494fb4 (patch)
treec71f2fe4936d6d85155677704bef02b7bb62f5ca /include/trace/bpf_probe.h
parentadd1511c38166cf1036765f8c4aa939f0275a799 (diff)
downloadlinux-d07c9ad622474616e94572e59e725c2c4a494fb4.tar.xz
tracing: Introduce helpers to safely handle dynamic-sized sockaddrs
Enable a struct sockaddr to be stored in a trace record as a dynamically-sized field. The common cases are AF_INET and AF_INET6 which are different sizes, and are vastly smaller than a struct sockaddr_storage. These are safer because, when used properly, the size of the sockaddr destination field in each trace record is now guaranteed to be the same as the source address that is being copied into it. Link: https://lore.kernel.org/all/164182978641.8391.8277203495236105391.stgit@bazille.1015granger.net/ Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'include/trace/bpf_probe.h')
-rw-r--r--include/trace/bpf_probe.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h
index 7660a7846586..6a13220d2d27 100644
--- a/include/trace/bpf_probe.h
+++ b/include/trace/bpf_probe.h
@@ -21,6 +21,9 @@
#undef __get_bitmask
#define __get_bitmask(field) (char *)__get_dynamic_array(field)
+#undef __get_sockaddr
+#define __get_sockaddr(field) ((struct sockaddr *)__get_dynamic_array(field))
+
#undef __get_rel_dynamic_array
#define __get_rel_dynamic_array(field) \
((void *)(&__entry->__rel_loc_##field) + \
@@ -37,6 +40,9 @@
#undef __get_rel_bitmask
#define __get_rel_bitmask(field) (char *)__get_rel_dynamic_array(field)
+#undef __get_rel_sockaddr
+#define __get_rel_sockaddr(field) ((struct sockaddr *)__get_rel_dynamic_array(field))
+
#undef __perf_count
#define __perf_count(c) (c)