diff options
Diffstat (limited to 'tools/lib/bpf/bpf.c')
-rw-r--r-- | tools/lib/bpf/bpf.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index bf2772566240..9c88f6e4156d 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c | |||
@@ -32,6 +32,10 @@ | |||
32 | #include <sys/socket.h> | 32 | #include <sys/socket.h> |
33 | #include <errno.h> | 33 | #include <errno.h> |
34 | 34 | ||
35 | #ifndef SOL_NETLINK | ||
36 | #define SOL_NETLINK 270 | ||
37 | #endif | ||
38 | |||
35 | /* | 39 | /* |
36 | * When building perf, unistd.h is overridden. __NR_bpf is | 40 | * When building perf, unistd.h is overridden. __NR_bpf is |
37 | * required to be defined explicitly. | 41 | * required to be defined explicitly. |
@@ -436,6 +440,7 @@ int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) | |||
436 | struct nlmsghdr *nh; | 440 | struct nlmsghdr *nh; |
437 | struct nlmsgerr *err; | 441 | struct nlmsgerr *err; |
438 | socklen_t addrlen; | 442 | socklen_t addrlen; |
443 | int one = 1; | ||
439 | 444 | ||
440 | memset(&sa, 0, sizeof(sa)); | 445 | memset(&sa, 0, sizeof(sa)); |
441 | sa.nl_family = AF_NETLINK; | 446 | sa.nl_family = AF_NETLINK; |
@@ -445,6 +450,11 @@ int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) | |||
445 | return -errno; | 450 | return -errno; |
446 | } | 451 | } |
447 | 452 | ||
453 | if (setsockopt(sock, SOL_NETLINK, NETLINK_EXT_ACK, | ||
454 | &one, sizeof(one)) < 0) { | ||
455 | fprintf(stderr, "Netlink error reporting not supported\n"); | ||
456 | } | ||
457 | |||
448 | if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) { | 458 | if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) { |
449 | ret = -errno; | 459 | ret = -errno; |
450 | goto cleanup; | 460 | goto cleanup; |
@@ -521,6 +531,7 @@ int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) | |||
521 | if (!err->error) | 531 | if (!err->error) |
522 | continue; | 532 | continue; |
523 | ret = err->error; | 533 | ret = err->error; |
534 | nla_dump_errormsg(nh); | ||
524 | goto cleanup; | 535 | goto cleanup; |
525 | case NLMSG_DONE: | 536 | case NLMSG_DONE: |
526 | break; | 537 | break; |