* [PATCH iproute2 1/2] vrf: print BPF log buffer if bpf_program_load fails
@ 2021-01-17 22:54 Luca Boccassi
2021-01-17 22:54 ` [PATCH iproute2 2/2] vrf: fix ip vrf exec with libbpf Luca Boccassi
2021-01-18 3:53 ` [PATCH iproute2 1/2] vrf: print BPF log buffer if bpf_program_load fails David Ahern
0 siblings, 2 replies; 4+ messages in thread
From: Luca Boccassi @ 2021-01-17 22:54 UTC (permalink / raw)
To: netdev; +Cc: stephen
Necessary to understand what is going on when bpf_program_load fails
Signed-off-by: Luca Boccassi <bluca@debian.org>
---
ip/ipvrf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ip/ipvrf.c b/ip/ipvrf.c
index 42779e5c..91578031 100644
--- a/ip/ipvrf.c
+++ b/ip/ipvrf.c
@@ -278,8 +278,8 @@ static int vrf_configure_cgroup(const char *path, int ifindex)
*/
prog_fd = prog_load(ifindex);
if (prog_fd < 0) {
- fprintf(stderr, "Failed to load BPF prog: '%s'\n",
- strerror(errno));
+ fprintf(stderr, "Failed to load BPF prog: '%s'\n%s",
+ strerror(errno), bpf_log_buf);
if (errno != EPERM) {
fprintf(stderr,
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH iproute2 2/2] vrf: fix ip vrf exec with libbpf
2021-01-17 22:54 [PATCH iproute2 1/2] vrf: print BPF log buffer if bpf_program_load fails Luca Boccassi
@ 2021-01-17 22:54 ` Luca Boccassi
2021-01-18 3:53 ` David Ahern
2021-01-18 3:53 ` [PATCH iproute2 1/2] vrf: print BPF log buffer if bpf_program_load fails David Ahern
1 sibling, 1 reply; 4+ messages in thread
From: Luca Boccassi @ 2021-01-17 22:54 UTC (permalink / raw)
To: netdev; +Cc: stephen
The size of bpf_insn is passed to bpf_load_program instead of the number
of elements as it expects, so ip vrf exec fails with:
$ sudo ip link add vrf-blue type vrf table 10
$ sudo ip link set dev vrf-blue up
$ sudo ip/ip vrf exec vrf-blue ls
Failed to load BPF prog: 'Invalid argument'
last insn is not an exit or jmp
processed 0 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
Kernel compiled with CGROUP_BPF enabled?
https://bugs.debian.org/980046
Reported-by: Emmanuel DECAEN <Emmanuel.Decaen@xsalto.com>
Signed-off-by: Luca Boccassi <bluca@debian.org>
---
lib/bpf_glue.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/bpf_glue.c b/lib/bpf_glue.c
index fa609bfe..d00a0dc1 100644
--- a/lib/bpf_glue.c
+++ b/lib/bpf_glue.c
@@ -14,7 +14,8 @@ int bpf_program_load(enum bpf_prog_type type, const struct bpf_insn *insns,
size_t size_log)
{
#ifdef HAVE_LIBBPF
- return bpf_load_program(type, insns, size_insns, license, 0, log, size_log);
+ return bpf_load_program(type, insns, size_insns / sizeof(struct bpf_insn),
+ license, 0, log, size_log);
#else
return bpf_prog_load_dev(type, insns, size_insns, license, 0, log, size_log);
#endif
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH iproute2 2/2] vrf: fix ip vrf exec with libbpf
2021-01-17 22:54 ` [PATCH iproute2 2/2] vrf: fix ip vrf exec with libbpf Luca Boccassi
@ 2021-01-18 3:53 ` David Ahern
0 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2021-01-18 3:53 UTC (permalink / raw)
To: Luca Boccassi, netdev; +Cc: stephen
On 1/17/21 3:54 PM, Luca Boccassi wrote:
> The size of bpf_insn is passed to bpf_load_program instead of the number
> of elements as it expects, so ip vrf exec fails with:
>
> $ sudo ip link add vrf-blue type vrf table 10
> $ sudo ip link set dev vrf-blue up
> $ sudo ip/ip vrf exec vrf-blue ls
> Failed to load BPF prog: 'Invalid argument'
> last insn is not an exit or jmp
> processed 0 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
> Kernel compiled with CGROUP_BPF enabled?
>
> https://bugs.debian.org/980046
>
> Reported-by: Emmanuel DECAEN <Emmanuel.Decaen@xsalto.com>
>
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
> lib/bpf_glue.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH iproute2 1/2] vrf: print BPF log buffer if bpf_program_load fails
2021-01-17 22:54 [PATCH iproute2 1/2] vrf: print BPF log buffer if bpf_program_load fails Luca Boccassi
2021-01-17 22:54 ` [PATCH iproute2 2/2] vrf: fix ip vrf exec with libbpf Luca Boccassi
@ 2021-01-18 3:53 ` David Ahern
1 sibling, 0 replies; 4+ messages in thread
From: David Ahern @ 2021-01-18 3:53 UTC (permalink / raw)
To: Luca Boccassi, netdev; +Cc: stephen
On 1/17/21 3:54 PM, Luca Boccassi wrote:
> Necessary to understand what is going on when bpf_program_load fails
>
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
> ip/ipvrf.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-01-18 3:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-17 22:54 [PATCH iproute2 1/2] vrf: print BPF log buffer if bpf_program_load fails Luca Boccassi
2021-01-17 22:54 ` [PATCH iproute2 2/2] vrf: fix ip vrf exec with libbpf Luca Boccassi
2021-01-18 3:53 ` David Ahern
2021-01-18 3:53 ` [PATCH iproute2 1/2] vrf: print BPF log buffer if bpf_program_load fails David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).