Skip to content

Commit

Permalink
With BTF, users do not need libc headers installed for AF_INET/AF_INET6
Browse files Browse the repository at this point in the history
Signed-off-by: Bernhard Kaindl <bernhardkaindl7@gmail.com>
  • Loading branch information
bernhardkaindl authored and ajor committed May 8, 2024
1 parent 6fb72aa commit c0b9d25
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
8 changes: 7 additions & 1 deletion tools/tcpaccept.bt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions tools/tcpconnect.bt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
#include <net/sock.h>
#else
/*
* Note: you may need to install the glibc-headers package or other package
* containing sys/socket.h, which contains the AF_INET and AF_INET6 macros
* 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:
*/
#include <sys/socket.h>
#define AF_INET 2 /* IPv4 */
#define AF_INET6 10 /* IPv6 */
#endif

BEGIN
Expand Down
8 changes: 7 additions & 1 deletion tools/tcpdrop.bt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion tools/tcplife.bt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion tools/tcpretrans.bt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c0b9d25

Please sign in to comment.