bpf: load firewall with name only if supported
authorJulia Kartseva <hex@fb.com>
Fri, 28 Jan 2022 00:36:25 +0000 (16:36 -0800)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 28 Jan 2022 03:42:18 +0000 (12:42 +0900)
commite0c694c73d9bf68b4d79b140afce29b737bfc256
tree72272308ba5b5a8fbb1bfbb6f2bf6ee66fc35a50
parent673a18170259b3d31189c76f75c7f1278e4f04c8
bpf: load firewall with name only if supported

BPF firewall is supported starting from v4.9 kernel where
BPF_PROG_TYPE_SOCKET_FILTER support was added [0].

However, program name support was added to v4.15 [1] and BPF_PROG_LOAD
syscall will fail on older kernels if called with prog_name attribute.
BPF_F_ALLOW_MULTI was also added to v4.15 kernel which allows reusing
BPF_F_ALLOW_MULTI probe to indicate that program name is also supported.

It is no problem for BPF_PROG_TYPE_CGROUP_DEVICE since it was added in
v4.15.

[0] https://elixir.bootlin.com/linux/v4.9/source/include/uapi/linux/bpf.h#L92
[1] https://elixir.bootlin.com/linux/v4.15/source/include/uapi/linux/bpf.h#L191

Follow-up of https://github.com/systemd/systemd/pull/22214
src/core/bpf-devices.c
src/core/bpf-firewall.c