[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200510003402.3a4ozoynwm4mryi5@ast-mbp>
Date: Sat, 9 May 2020 17:34:02 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Yonghong Song <yhs@...com>
Cc: Andrii Nakryiko <andriin@...com>, bpf@...r.kernel.org,
Martin KaFai Lau <kafai@...com>, netdev@...r.kernel.org,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>, kernel-team@...com
Subject: Re: [PATCH bpf-next v4 21/21] tools/bpf: selftests: add bpf_iter
selftests
On Sat, May 09, 2020 at 10:59:23AM -0700, Yonghong Song wrote:
> +static volatile const __u32 ret1;
> +
> +SEC("iter/bpf_map")
> +int dump_bpf_map(struct bpf_iter__bpf_map *ctx)
> +{
> + struct seq_file *seq = ctx->meta->seq;
> + struct bpf_map *map = ctx->map;
> + __u64 seq_num;
> + int i, ret = 0;
> +
> + if (map == (void *)0)
> + return 0;
> +
> + /* only dump map1_id and map2_id */
> + if (map->id != map1_id && map->id != map2_id)
> + return 0;
> +
> + seq_num = ctx->meta->seq_num;
> + if (map->id == map1_id) {
> + map1_seqnum = seq_num;
> + map1_accessed++;
> + }
> +
> + if (map->id == map2_id) {
> + if (map2_accessed == 0) {
> + map2_seqnum1 = seq_num;
> + if (ret1)
> + ret = 1;
> + } else {
> + map2_seqnum2 = seq_num;
> + }
> + map2_accessed++;
> + }
> +
> + /* fill seq_file buffer */
> + for (i = 0; i < print_len; i++)
> + bpf_seq_write(seq, &seq_num, sizeof(seq_num));
> +
> + return ret;
> +}
I couldn't find where 'return 1' behavior is documented clearly.
I think it's a workaround for overflow.
When bpf prog detects overflow it can request replay of the element?
What if it keeps returning 1 ? read() will never finish?
Powered by blists - more mailing lists