Skip to content

Commit

Permalink
samples: bpf: syscall_nrs: use mmap2 if defined
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Jonathan Lemon <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
  • Loading branch information
ikhorn authored and borkmann committed Aug 21, 2019
1 parent 624676e commit bb4b5c0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions samples/bpf/syscall_nrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@ void syscall_defines(void)
COMMENT("Linux system call numbers.");
SYSNR(__NR_write);
SYSNR(__NR_read);
#ifdef __NR_mmap2
SYSNR(__NR_mmap2);
#endif
#ifdef __NR_mmap
SYSNR(__NR_mmap);
#endif

}
13 changes: 13 additions & 0 deletions samples/bpf/tracex5_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,25 @@ PROG(SYS__NR_read)(struct pt_regs *ctx)
return 0;
}

#ifdef __NR_mmap2
PROG(SYS__NR_mmap2)(struct pt_regs *ctx)
{
char fmt[] = "mmap2\n";

bpf_trace_printk(fmt, sizeof(fmt));
return 0;
}
#endif

#ifdef __NR_mmap
PROG(SYS__NR_mmap)(struct pt_regs *ctx)
{
char fmt[] = "mmap\n";

bpf_trace_printk(fmt, sizeof(fmt));
return 0;
}
#endif

char _license[] SEC("license") = "GPL";
u32 _version SEC("version") = LINUX_VERSION_CODE;

0 comments on commit bb4b5c0

Please sign in to comment.