Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpftool: Reimplement large insn size limit feature probing

Reimplement bpf_probe_large_insn_limit() in bpftool, as that libbpf API
is scheduled for deprecation in v0.8.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Dave Marchevsky <davemarchevsky@fb.com>
Link: https://lore.kernel.org/bpf/20211217171202.3352835-4-andrii@kernel.org

authored by

Andrii Nakryiko and committed by
Daniel Borkmann
e967a20a 5a8ea82f

+23 -3
+23 -3
tools/bpf/bpftool/feature.c
··· 642 642 printf("\n"); 643 643 } 644 644 645 - static void 646 - probe_large_insn_limit(const char *define_prefix, __u32 ifindex) 645 + /* 646 + * Probe for availability of kernel commit (5.3): 647 + * 648 + * c04c0d2b968a ("bpf: increase complexity limit and maximum program size") 649 + */ 650 + static void probe_large_insn_limit(const char *define_prefix, __u32 ifindex) 647 651 { 652 + LIBBPF_OPTS(bpf_prog_load_opts, opts, 653 + .prog_ifindex = ifindex, 654 + ); 655 + struct bpf_insn insns[BPF_MAXINSNS + 1]; 648 656 bool res; 657 + int i, fd; 649 658 650 - res = bpf_probe_large_insn_limit(ifindex); 659 + for (i = 0; i < BPF_MAXINSNS; i++) 660 + insns[i] = BPF_MOV64_IMM(BPF_REG_0, 1); 661 + insns[BPF_MAXINSNS] = BPF_EXIT_INSN(); 662 + 663 + errno = 0; 664 + fd = bpf_prog_load(BPF_PROG_TYPE_SCHED_CLS, NULL, "GPL", 665 + insns, ARRAY_SIZE(insns), &opts); 666 + res = fd >= 0 || (errno != E2BIG && errno != EINVAL); 667 + 668 + if (fd >= 0) 669 + close(fd); 670 + 651 671 print_bool_feature("have_large_insn_limit", 652 672 "Large program size limit", 653 673 "LARGE_INSN_LIMIT",