iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.36k stars 3.86k forks source link

tcpretrans: use of undeclared identifier 'BPF_CGROUP_UNIX_*' #4883

Closed jeromemarchand closed 8 months ago

jeromemarchand commented 8 months ago

tcpretrans fails on recent kernels:

# uname -r
6.8.0-0.rc0.20240112git70d201a40823.5.fc40.x86_64
# /usr/share/bcc/tools/tcpretrans 
In file included from /virtual/main.c:4:
In file included from include/net/tcp.h:47:
include/linux/bpf-cgroup.h:51:2: error: use of undeclared identifier 'BPF_CGROUP_UNIX_CONNECT'
   51 |         CGROUP_ATYPE(CGROUP_UNIX_CONNECT);
      |         ^
include/linux/bpf-cgroup.h:36:7: note: expanded from macro 'CGROUP_ATYPE'
   36 |         case BPF_##type: return type
      |              ^
<scratch space>:197:1: note: expanded from here
  197 | BPF_CGROUP_UNIX_CONNECT
      | ^
In file included from /virtual/main.c:4:
In file included from include/net/tcp.h:47:
include/linux/bpf-cgroup.h:56:2: error: use of undeclared identifier 'BPF_CGROUP_UNIX_SENDMSG'
   56 |         CGROUP_ATYPE(CGROUP_UNIX_SENDMSG);
      |         ^
include/linux/bpf-cgroup.h:36:7: note: expanded from macro 'CGROUP_ATYPE'
   36 |         case BPF_##type: return type
      |              ^
<scratch space>:202:1: note: expanded from here
  202 | BPF_CGROUP_UNIX_SENDMSG
      | ^
In file included from /virtual/main.c:4:
In file included from include/net/tcp.h:47:
include/linux/bpf-cgroup.h:60:2: error: use of undeclared identifier 'BPF_CGROUP_UNIX_RECVMSG'
   60 |         CGROUP_ATYPE(CGROUP_UNIX_RECVMSG);
      |         ^
include/linux/bpf-cgroup.h:36:7: note: expanded from macro 'CGROUP_ATYPE'
   36 |         case BPF_##type: return type
      |              ^
<scratch space>:206:1: note: expanded from here
  206 | BPF_CGROUP_UNIX_RECVMSG
      | ^
In file included from /virtual/main.c:4:
In file included from include/net/tcp.h:47:
include/linux/bpf-cgroup.h:65:2: error: use of undeclared identifier 'BPF_CGROUP_UNIX_GETPEERNAME'
   65 |         CGROUP_ATYPE(CGROUP_UNIX_GETPEERNAME);
      |         ^
include/linux/bpf-cgroup.h:36:7: note: expanded from macro 'CGROUP_ATYPE'
   36 |         case BPF_##type: return type
      |              ^
<scratch space>:211:1: note: expanded from here
  211 | BPF_CGROUP_UNIX_GETPEERNAME
      | ^
In file included from /virtual/main.c:4:
In file included from include/net/tcp.h:47:
include/linux/bpf-cgroup.h:68:2: error: use of undeclared identifier 'BPF_CGROUP_UNIX_GETSOCKNAME'
   68 |         CGROUP_ATYPE(CGROUP_UNIX_GETSOCKNAME);
      |         ^
include/linux/bpf-cgroup.h:36:7: note: expanded from macro 'CGROUP_ATYPE'
   36 |         case BPF_##type: return type
      |              ^
<scratch space>:2:1: note: expanded from here
    2 | BPF_CGROUP_UNIX_GETSOCKNAME
      | ^
5 errors generated.
Traceback (most recent call last):
  File "/usr/share/bcc/tools/tcpretrans", line 396, in <module>
    b = BPF(text=bpf_text)
        ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/bcc/__init__.py", line 479, in __init__
    raise Exception("Failed to compile BPF module %s" % (src_file or "<text>"))
Exception: Failed to compile BPF module <text>

The BPF_CGROUPUNIX* macros has been added by commit 859051dd165e ("bpf: Implement cgroup sockaddr hooks for unix sockets").

yonghong-song commented 8 months ago

@jeromemarchand This should be fixed with latest libbpf sync in the master branch. Could you help check?

jeromemarchand commented 8 months ago

Yes, the latest libbpf sync fixes this issue.