]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Implement bpf_seq_read() for bpf iterator
authorYonghong Song <yhs@fb.com>
Sat, 9 May 2020 17:59:04 +0000 (10:59 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 10 May 2020 00:05:26 +0000 (17:05 -0700)
commit93a965cf07fef35ffb21a64b820e623b59e39c3a
treeb56407cffddf4ca487a888d9f2cb75b45e53a9e8
parent151bd6ceeea49b577c1220c79dc9a0c57c9968cb
bpf: Implement bpf_seq_read() for bpf iterator

bpf iterator uses seq_file to provide a lossless
way to transfer data to user space. But we want to call
bpf program after all objects have been traversed, and
bpf program may write additional data to the
seq_file buffer. The current seq_read() does not work
for this use case.

Besides allowing stop() function to write to the buffer,
the bpf_seq_read() also fixed the buffer size to one page.
If any single call of show() or stop() will emit data
more than one page to cause overflow, -E2BIG error code
will be returned to user space.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200509175904.2475468-1-yhs@fb.com
kernel/bpf/bpf_iter.c