* [PATCH iproute2 net-next] bpf: Fix number of retries when growing log buffer
@ 2016-12-07 9:47 Thomas Graf
2016-12-09 20:42 ` Stephen Hemminger
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Graf @ 2016-12-07 9:47 UTC (permalink / raw)
To: stephen; +Cc: netdev, daniel, alexei.starovoitov
The log buffer is automatically grown when the verifier output does not
fit into the default buffer size. The number of growing attempts was
not sufficient to reach the maximum buffer size so far.
Perform 9 iterations to reach max and let the 10th one fail.
j:0 i:65536 max:16777215
j:1 i:131072 max:16777215
j:2 i:262144 max:16777215
j:3 i:524288 max:16777215
j:4 i:1048576 max:16777215
j:5 i:2097152 max:16777215
j:6 i:4194304 max:16777215
j:7 i:8388608 max:16777215
j:8 i:16777216 max:16777215
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
---
lib/bpf.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/lib/bpf.c b/lib/bpf.c
index 8a5b84b..f3dace2 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -912,15 +912,18 @@ bpf_dump_error(struct bpf_elf_ctx *ctx, const char *format, ...)
static int bpf_log_realloc(struct bpf_elf_ctx *ctx)
{
+ const size_t log_max = UINT_MAX >> 8;
size_t log_size = ctx->log_size;
void *ptr;
if (!ctx->log) {
log_size = 65536;
- } else {
+ } else if (log_size < log_max) {
log_size <<= 1;
- if (log_size > (UINT_MAX >> 8))
- return -EINVAL;
+ if (log_size > log_max)
+ log_size = log_max;
+ } else {
+ return -EINVAL;
}
ptr = realloc(ctx->log, log_size);
@@ -1259,7 +1262,7 @@ retry:
* log for the user, so enlarge it and re-fail.
*/
if (fd < 0 && (errno == ENOSPC || !ctx->log_size)) {
- if (tries++ < 6 && !bpf_log_realloc(ctx))
+ if (tries++ < 10 && !bpf_log_realloc(ctx))
goto retry;
fprintf(stderr, "Log buffer too small to dump verifier log %zu bytes (%d tries)!\n",
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2 net-next] bpf: Fix number of retries when growing log buffer
2016-12-07 9:47 [PATCH iproute2 net-next] bpf: Fix number of retries when growing log buffer Thomas Graf
@ 2016-12-09 20:42 ` Stephen Hemminger
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2016-12-09 20:42 UTC (permalink / raw)
To: Thomas Graf; +Cc: netdev, daniel, alexei.starovoitov
On Wed, 7 Dec 2016 10:47:59 +0100
Thomas Graf <tgraf@suug.ch> wrote:
> The log buffer is automatically grown when the verifier output does not
> fit into the default buffer size. The number of growing attempts was
> not sufficient to reach the maximum buffer size so far.
>
> Perform 9 iterations to reach max and let the 10th one fail.
>
> j:0 i:65536 max:16777215
> j:1 i:131072 max:16777215
> j:2 i:262144 max:16777215
> j:3 i:524288 max:16777215
> j:4 i:1048576 max:16777215
> j:5 i:2097152 max:16777215
> j:6 i:4194304 max:16777215
> j:7 i:8388608 max:16777215
> j:8 i:16777216 max:16777215
>
> Signed-off-by: Thomas Graf <tgraf@suug.ch>
> Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Applied to net-next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-09 20:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-07 9:47 [PATCH iproute2 net-next] bpf: Fix number of retries when growing log buffer Thomas Graf
2016-12-09 20:42 ` Stephen Hemminger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.