| .. | .. |
|---|
| 16 | 16 | #include <linux/netlink.h> |
|---|
| 17 | 17 | #include <linux/rtnetlink.h> |
|---|
| 18 | 18 | #include <linux/types.h> |
|---|
| 19 | | -#include <sys/types.h> |
|---|
| 20 | 19 | #include <sys/socket.h> |
|---|
| 21 | 20 | #include <sys/syscall.h> |
|---|
| 22 | 21 | #include <sys/ioctl.h> |
|---|
| .. | .. |
|---|
| 41 | 40 | int prog_array_fd = -1; |
|---|
| 42 | 41 | |
|---|
| 43 | 42 | struct bpf_map_data map_data[MAX_MAPS]; |
|---|
| 44 | | -int map_data_count = 0; |
|---|
| 43 | +int map_data_count; |
|---|
| 45 | 44 | |
|---|
| 46 | 45 | static int populate_prog_array(const char *event, int prog_fd) |
|---|
| 47 | 46 | { |
|---|
| .. | .. |
|---|
| 66 | 65 | else |
|---|
| 67 | 66 | flags = O_WRONLY | O_APPEND; |
|---|
| 68 | 67 | |
|---|
| 69 | | - fd = open("/sys/kernel/debug/tracing/kprobe_events", flags); |
|---|
| 68 | + fd = open(DEBUGFS "kprobe_events", flags); |
|---|
| 70 | 69 | |
|---|
| 71 | 70 | ret = write(fd, val, strlen(val)); |
|---|
| 72 | 71 | close(fd); |
|---|
| .. | .. |
|---|
| 302 | 301 | numa_node); |
|---|
| 303 | 302 | } |
|---|
| 304 | 303 | if (map_fd[i] < 0) { |
|---|
| 305 | | - printf("failed to create a map: %d %s\n", |
|---|
| 306 | | - errno, strerror(errno)); |
|---|
| 304 | + printf("failed to create map %d (%s): %d %s\n", |
|---|
| 305 | + i, maps[i].name, errno, strerror(errno)); |
|---|
| 307 | 306 | return 1; |
|---|
| 308 | 307 | } |
|---|
| 309 | 308 | maps[i].fd = map_fd[i]; |
|---|
| .. | .. |
|---|
| 491 | 490 | |
|---|
| 492 | 491 | /* Verify no newer features were requested */ |
|---|
| 493 | 492 | if (validate_zero) { |
|---|
| 494 | | - addr = (unsigned char*) def + map_sz_copy; |
|---|
| 495 | | - end = (unsigned char*) def + map_sz_elf; |
|---|
| 493 | + addr = (unsigned char *) def + map_sz_copy; |
|---|
| 494 | + end = (unsigned char *) def + map_sz_elf; |
|---|
| 496 | 495 | for (; addr < end; addr++) { |
|---|
| 497 | 496 | if (*addr != 0) { |
|---|
| 498 | 497 | free(sym); |
|---|
| .. | .. |
|---|
| 665 | 664 | int load_bpf_file_fixup_map(const char *path, fixup_map_cb fixup_map) |
|---|
| 666 | 665 | { |
|---|
| 667 | 666 | return do_load_bpf_file(path, fixup_map); |
|---|
| 668 | | -} |
|---|
| 669 | | - |
|---|
| 670 | | -void read_trace_pipe(void) |
|---|
| 671 | | -{ |
|---|
| 672 | | - int trace_fd; |
|---|
| 673 | | - |
|---|
| 674 | | - trace_fd = open(DEBUGFS "trace_pipe", O_RDONLY, 0); |
|---|
| 675 | | - if (trace_fd < 0) |
|---|
| 676 | | - return; |
|---|
| 677 | | - |
|---|
| 678 | | - while (1) { |
|---|
| 679 | | - static char buf[4096]; |
|---|
| 680 | | - ssize_t sz; |
|---|
| 681 | | - |
|---|
| 682 | | - sz = read(trace_fd, buf, sizeof(buf) - 1); |
|---|
| 683 | | - if (sz > 0) { |
|---|
| 684 | | - buf[sz] = 0; |
|---|
| 685 | | - puts(buf); |
|---|
| 686 | | - } |
|---|
| 687 | | - } |
|---|
| 688 | 667 | } |
|---|