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

samples: bpf: syscall_nrs: use mmap2 if defined

For arm32 xdp sockets mmap2 is preferred, so use it if it's defined.
Declaration of __NR_mmap can be skipped and it breaks build.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>

authored by

Ivan Khoronzhuk and committed by
Daniel Borkmann
bb4b5c08 624676e7

+21 -2
+6
samples/bpf/syscall_nrs.c
··· 9 9 COMMENT("Linux system call numbers."); 10 10 SYSNR(__NR_write); 11 11 SYSNR(__NR_read); 12 + #ifdef __NR_mmap2 13 + SYSNR(__NR_mmap2); 14 + #endif 15 + #ifdef __NR_mmap 12 16 SYSNR(__NR_mmap); 17 + #endif 18 + 13 19 }
+15 -2
samples/bpf/tracex5_kern.c
··· 68 68 return 0; 69 69 } 70 70 71 - PROG(SYS__NR_mmap)(struct pt_regs *ctx) 71 + #ifdef __NR_mmap2 72 + PROG(SYS__NR_mmap2)(struct pt_regs *ctx) 72 73 { 73 - char fmt[] = "mmap\n"; 74 + char fmt[] = "mmap2\n"; 75 + 74 76 bpf_trace_printk(fmt, sizeof(fmt)); 75 77 return 0; 76 78 } 79 + #endif 80 + 81 + #ifdef __NR_mmap 82 + PROG(SYS__NR_mmap)(struct pt_regs *ctx) 83 + { 84 + char fmt[] = "mmap\n"; 85 + 86 + bpf_trace_printk(fmt, sizeof(fmt)); 87 + return 0; 88 + } 89 + #endif 77 90 78 91 char _license[] SEC("license") = "GPL"; 79 92 u32 _version SEC("version") = LINUX_VERSION_CODE;