0bf9c7660f
tcp*.bt scripts tried to include glibc headers, which didn't work on nixos because bpftrace tried to call clang-major with some options to get the paths, but we never told it where to find it. Give bpftrace the path directly instead of giving it a path to clang. runqlat.bt doesn't work with glibc headers and requires kernel headers which are no longer extracted, just provide its value. Note the default clang output also had some clang-internal headers, but these seem to be included anyway through libclang API without having to give them here, so we only pass the glibc ones. While here: - also backport another bpftrace patch that made the tcp*.bt tools to actually not require these includes - and add tests that we can include these. Co-authored-by: Arian van Putten <arian.vanputten@gmail.com>
115 lines
3.1 KiB
Diff
115 lines
3.1 KiB
Diff
From ebb12512f6ea0a1113ad8ddf30db26128f7a3426 Mon Sep 17 00:00:00 2001
|
|
From: Dominique Martinet <asmadeus@codewreck.org>
|
|
Date: Sun, 23 Jun 2024 20:41:01 +0900
|
|
Subject: [PATCH] With BTF, users do not need libc headers installed for
|
|
AF_INET/AF_INET6
|
|
|
|
Signed-off-by: Bernhard Kaindl <bernhardkaindl7@gmail.com>
|
|
(cherry picked from commit c0b9d252a43f99b9091245dedb178a6874803306)
|
|
---
|
|
tools/tcpaccept.bt | 8 +++++++-
|
|
tools/tcpconnect.bt | 8 +++++++-
|
|
tools/tcpdrop.bt | 8 +++++++-
|
|
tools/tcplife.bt | 8 +++++++-
|
|
tools/tcpretrans.bt | 8 +++++++-
|
|
5 files changed, 35 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/tools/tcpaccept.bt b/tools/tcpaccept.bt
|
|
index 08e6af0158fc..cbffe36889ee 100755
|
|
--- a/tools/tcpaccept.bt
|
|
+++ b/tools/tcpaccept.bt
|
|
@@ -20,7 +20,13 @@
|
|
#include <linux/socket.h>
|
|
#include <net/sock.h>
|
|
#else
|
|
-#include <sys/socket.h>
|
|
+/*
|
|
+ * With BTF providing types, socket headers are not needed.
|
|
+ * We only need to supply the preprocessor defines in this script.
|
|
+ * AF_INET/AF_INET6 are part of the stable arch-independent Linux ABI
|
|
+ */
|
|
+#define AF_INET 2
|
|
+#define AF_INET6 10
|
|
#endif
|
|
|
|
BEGIN
|
|
diff --git a/tools/tcpconnect.bt b/tools/tcpconnect.bt
|
|
index 1ac1eb99e9ad..636337275cd8 100755
|
|
--- a/tools/tcpconnect.bt
|
|
+++ b/tools/tcpconnect.bt
|
|
@@ -22,7 +22,13 @@
|
|
#include <linux/socket.h>
|
|
#include <net/sock.h>
|
|
#else
|
|
-#include <sys/socket.h>
|
|
+/*
|
|
+ * BTF provides the types, we just need to define AF_INET and AF_INET6.
|
|
+ * These are Linux ABI defines, and are not architecture-specific.
|
|
+ * With BTF, this allows tcpconnect.bt to work without glibc headers:
|
|
+ */
|
|
+#define AF_INET 2 /* IPv4 */
|
|
+#define AF_INET6 10 /* IPv6 */
|
|
#endif
|
|
|
|
BEGIN
|
|
diff --git a/tools/tcpdrop.bt b/tools/tcpdrop.bt
|
|
index fd3e55f490bf..a56bf69fcc6c 100755
|
|
--- a/tools/tcpdrop.bt
|
|
+++ b/tools/tcpdrop.bt
|
|
@@ -24,7 +24,13 @@
|
|
#include <linux/socket.h>
|
|
#include <net/sock.h>
|
|
#else
|
|
-#include <sys/socket.h>
|
|
+/*
|
|
+ * With BTF providing types, socket headers are not needed.
|
|
+ * We only need to supply the preprocessor defines in this script.
|
|
+ * AF_INET/AF_INET6 are part of the stable arch-independent Linux ABI
|
|
+ */
|
|
+#define AF_INET 2
|
|
+#define AF_INET6 10
|
|
#endif
|
|
|
|
BEGIN
|
|
diff --git a/tools/tcplife.bt b/tools/tcplife.bt
|
|
index dd4c1d68284e..d5a09c4e5da9 100755
|
|
--- a/tools/tcplife.bt
|
|
+++ b/tools/tcplife.bt
|
|
@@ -19,7 +19,13 @@
|
|
#include <linux/socket.h>
|
|
#include <linux/tcp.h>
|
|
#else
|
|
-#include <sys/socket.h>
|
|
+/*
|
|
+ * With BTF providing types, socket headers are not needed.
|
|
+ * We only need to supply the preprocessor defines in this script.
|
|
+ * AF_INET/AF_INET6 are part of the stable arch-independent Linux ABI
|
|
+ */
|
|
+#define AF_INET 2
|
|
+#define AF_INET6 10
|
|
#endif
|
|
|
|
BEGIN
|
|
diff --git a/tools/tcpretrans.bt b/tools/tcpretrans.bt
|
|
index ee2975d6e545..32a11bfa81b2 100755
|
|
--- a/tools/tcpretrans.bt
|
|
+++ b/tools/tcpretrans.bt
|
|
@@ -21,7 +21,13 @@
|
|
#include <linux/socket.h>
|
|
#include <net/sock.h>
|
|
#else
|
|
-#include <sys/socket.h>
|
|
+/*
|
|
+ * With BTF providing types, socket headers are not needed.
|
|
+ * We only need to supply the preprocessor defines in this script.
|
|
+ * AF_INET/AF_INET6 are part of the stable arch-independent Linux ABI
|
|
+ */
|
|
+#define AF_INET 2
|
|
+#define AF_INET6 10
|
|
#endif
|
|
|
|
BEGIN
|
|
--
|
|
2.45.2
|
|
|