]> 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)
commit3591a6e4f40f0bb381bb144e89b3c8d84f6384d0
treeb56407cffddf4ca487a888d9f2cb75b45e53a9e8
parent10cdaf06fd4e80fbb601de3ec2aa318260c646d4
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