From 861bd3c312f7a119cebefda9dc3402e71cafdc0d Mon Sep 17 00:00:00 2001 From: Alan Maguire Date: Fri, 17 May 2024 13:48:21 +0000 Subject: [PATCH] tcp_buffer_tuner: fix load failure for 6.9+ TCP buffer tuner was failing to load on 6.9 and later. CO-RE relocation for sk_userlocks in struct sock was the cause; the problem is sk_userlocks changes from a bitfield to a plain u8 and the vmlinux.h that was generated had the old representation. We can use a Linux version check to guard check of sk_userlocks. Reported-by: HippieMitch Signed-off-by: Alan Maguire --- src/tcp_buffer_tuner.bpf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tcp_buffer_tuner.bpf.c b/src/tcp_buffer_tuner.bpf.c index e8b3fd1..8002cfc 100644 --- a/src/tcp_buffer_tuner.bpf.c +++ b/src/tcp_buffer_tuner.bpf.c @@ -242,8 +242,11 @@ BPF_FENTRY(tcp_rcv_space_adjust, struct sock *sk) return 0; #ifndef BPFTUNE_LEGACY - /* CO-RE does not support bitfields... */ - sk_userlocks = sk->sk_userlocks; + /* sk_userlocks is a bitfield prior to 6.9 */ + if (LINUX_KERNEL_VERSION < KERNEL_VERSION(6, 9, 0)) { + /* CO-RE does not support bitfields... */ + sk_userlocks = sk->sk_userlocks; + } #endif if ((sk_userlocks & SOCK_RCVBUF_LOCK) || near_memory_pressure || near_memory_exhaustion)