Sfoglia il codice sorgente

btf: emit xdp_buff via BTF_TYPE_EMIT to fix sublevel-43 resolve_btfids

Oldest sublevels (5.10.43) reference struct xdp_buff via
BTF_ID_LIST_SINGLE(bpf_xdp_output_btf_ids) in net/core/filter.c but never
emit it into vmlinux BTF, so resolve_btfids aborts with 'unresolved symbol
xdp_buff'. Force emission with BTF_TYPE_EMIT inside bpf_xdp_event_output
(the same pattern already used for tcp6_sock/inet_timewait_sock). Verified
the patch applies to both sublevel-43 and sublevel-258 trees; harmless no-op
on newer sublevels that already emit xdp_buff.
TheWildJames 1 mese fa
parent
commit
36689922fd

+ 13 - 0
.github/actions/btf/action.yml

@@ -30,6 +30,19 @@ runs:
         set -euo pipefail
         patch -p1 -N < ${{ github.action_path }}/patches/0002-resolve_btfids-inherit-host-linker-flags.patch
 
+    - name: Apply xdp_buff BTF-emit fix (android12-5.10)
+      shell: bash
+      working-directory: ${{ github.workspace }}/kernel/common
+      if: ${{ inputs.version == 'android12-5.10' }}
+      run: |
+        set -euo pipefail
+        # bpf_types.h references struct xdp_buff via
+        # BTF_ID_LIST_SINGLE(bpf_xdp_output_btf_ids) in net/core/filter.c, but
+        # the oldest sublevels (5.10.43) never emit xdp_buff into vmlinux BTF,
+        # so resolve_btfids aborts with "unresolved symbol xdp_buff". Force BTF
+        # emission with BTF_TYPE_EMIT. Idempotent/harmless on newer sublevels.
+        patch -p1 -N < ${{ github.action_path }}/patches/0003-btf-emit-xdp-buff.patch
+
     - name: Expose host dd for hermetic BTF generation (android12-5.10)
       shell: bash
       working-directory: ${{ github.workspace }}/kernel/common

+ 14 - 0
.github/actions/btf/patches/0003-btf-emit-xdp-buff.patch

@@ -0,0 +1,14 @@
+--- a/net/core/filter.c
++++ b/net/core/filter.c
+@@ -4630,6 +4630,11 @@
+ {
+ 	u64 xdp_size = (flags & BPF_F_CTXLEN_MASK) >> 32;
+ 
++	/* xdp_buff is referenced via BTF_ID_LIST_SINGLE(bpf_xdp_output_btf_ids)
++	 * below but is not otherwise emitted into vmlinux BTF, so resolve_btfids
++	 * aborts with "unresolved symbol xdp_buff". Force BTF emission. */
++	BTF_TYPE_EMIT(struct xdp_buff);
++
+ 	if (unlikely(flags & ~(BPF_F_CTXLEN_MASK | BPF_F_INDEX_MASK)))
+ 		return -EINVAL;
+ 	if (unlikely(!xdp ||