Re: [PATCH bpf-next 1/3] bpf: Disallow freplace on XDP with mismatched xdp_has_frags values

Toke Høiland-Jørgensen
2026-03-24T16:19:00Z

Leon Hwang <leon.hwang@linux.dev> writes:

> xdp_has_frags was introduced by the commit
> c2f2cdbeffda ("bpf: introduce BPF_F_XDP_HAS_FRAGS flag in prog_flags loading the ebpf program").
>
> The commit f45d5b6ce2e8 ("bpf: generalise tail call map compatibility check")
> was to ensure backwards compatibility against tail calls. However, it
> missed that XDP progs can be extended by freplace progs, which could break
> the backwards compatibility, e.g. xdp_has_frags=true freplace progs are
> allowed to attach to xdp_has_frags=false XDP progs.
>
> To avoid breaking the backwards compatibility via freplace, disallow
> freplace on XDP programs with different xdp_has_frags values.

The problem you describe is not actually a problem, though? A
frags-aware program can run on a non-frags interface just fine.

You're messing with long-standing behaviour (since 5.18!) to solve a
non-existent problem. In a way that completely breaks the frags handling
in libxdp[0]:

Running tests from ./test-libxdp.sh
[test_link_so] PASS
[test_link_a] PASS
[test_old_dispatcher] PASS
[test_xdp_devbound] PASS
[test_xdp_frags] FAIL
Kernel supports XDP programs with frags
check_load_frags: FAILED
check_load_nofrags_success: PASSED
check_load_nofrags_fail: PASSED
check_load_frags_multi: FAILED
check_load_mix_big: FAILED
check_load_mix_small: FAILED
Test test_xdp_frags exited with return code: 1

Please don't do that.

-Toke

[0] Run 'make test' here: https://github.com/xdp-project/xdp-tools