From: Alexei Starovoitov When an lwt prog runs on a route, the skb always has a dst. To push an SRH, bpf_lwt_push_encap() reads the device from this dst. But bpf_prog_test_run_skb() sets a dst for lwt_xmit progs only. Thus the helper dereferences a NULL dst in a test run of an lwt_in prog. Set the same dst, ip6_null_entry, for lwt_in progs. When IPv6 is disabled or not built, their test run now fails with -EOPNOTSUPP too. An lwt_out prog cannot call this helper. Fixes: fe94cc290f53 ("bpf: Add IPv6 Segment Routing helpers") Signed-off-by: Alexei Starovoitov --- net/bpf/test_run.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 3043a7393c29..d6c9dc62182e 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -1210,7 +1210,8 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr, skb->ip_summed = CHECKSUM_COMPLETE; } - if (prog->type == BPF_PROG_TYPE_LWT_XMIT) { + if (prog->type == BPF_PROG_TYPE_LWT_IN || + prog->type == BPF_PROG_TYPE_LWT_XMIT) { if (!ipv6_mod_enabled()) { pr_warn_once("Please test this program with IPv6 enabled kernel\n"); ret = -EOPNOTSUPP; -- 2.55.0