From: planck kernel size experiment Subject: [PATCH 6/6] net: replace unreachable BPF hooks with tiny stubs NET normally forces CONFIG_BPF because generic receive, flow dissection, netlink filters and XDP-capable drivers expose optional BPF entry points. The planck workload cannot attach a program: it has no BPF syscall, no netlink userspace and socket filter options were removed in the preceding patch. Consequently every program pointer is permanently NULL. Supply the cold error/no-op side of that API in one tiny object. This lets the linker discard the BPF VM while keeping ordinary skb and virtio receive paths intact. These are deliberately not general-purpose Linux semantics; the contract is the stage's exact TCP/UDP receipt, durable-file verification, and final raw-ICMP commit proof. diff --git a/net/core/Makefile b/net/core/Makefile --- a/net/core/Makefile +++ b/net/core/Makefile @@ -5,6 +5,6 @@ obj-y := sock.o request_sock.o skbuff.o datagram.o stream.o scm.o \ gen_stats.o gen_estimator.o net_namespace.o secure_seq.o \ - flow_dissector.o + flow_dissector.o planck_minimal.o obj-$(CONFIG_SYSCTL) += sysctl_net_core.o diff --git a/net/core/planck_minimal.c b/net/core/planck_minimal.c new file mode 100644 --- /dev/null +++ b/net/core/planck_minimal.c @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Unreachable networking feature stubs for the fixed-function planck logger. */ +#include +#include +#include +#include + +DEFINE_STATIC_KEY_FALSE(bpf_stats_enabled_key); +DEFINE_STATIC_KEY_FALSE(bpf_master_redirect_enabled_key); + +int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, + unsigned int cap, enum skb_drop_reason *reason) +{ + return 0; +} + +void reuseport_has_conns_set(struct sock *sk) +{ +} + +u32 xdp_master_redirect(struct xdp_buff *xdp) +{ + return XDP_ABORTED; +} + +int xdp_do_generic_redirect(struct net_device *dev, struct sk_buff *skb, + struct xdp_buff *xdp, + const struct bpf_prog *prog) +{ + return -EOPNOTSUPP; +} + +int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp, + const struct bpf_prog *prog) +{ + return -EOPNOTSUPP; +} + +int xdp_do_redirect_frame(struct net_device *dev, struct xdp_buff *xdp, + struct xdp_frame *xdpf, + const struct bpf_prog *prog) +{ + return -EOPNOTSUPP; +} + +void xdp_do_flush(void) +{ +} + +void bpf_warn_invalid_xdp_action(const struct net_device *dev, + const struct bpf_prog *prog, u32 act) +{ +} + +void bpf_prog_change_xdp(struct bpf_prog *prev_prog, struct bpf_prog *prog) +{ +}