History

bpf: Add comments to interpret bpf_prog return values

Add a short comment in bpf_iter_run_prog() function to explain how bpf_prog return value is converted to seq_ops->show() return value: bpf_prog return seq_ops()->show() return 0 0 1 -EAGAIN When show() return value is -EAGAIN, the current bpf_seq_read() will end. If the current seq_file buffer is empty, -EAGAIN will return to user space. Otherwise, the buffer will be copied to user space. In both cases, the next bpf_seq_read() call will try to show the same object which returned -EAGAIN previously.

Yonghong Song committed 6 years ago

Commit 2e3ed681 parent 21aef701 file · +6 −0Browse files

Unified · Split

kernel/bpf/bpf_iter.c+6−0
@@ -526,5 +526,11 @@ int bpf_iter_run_prog(struct bpf_prog *prog, void *ctx) · 525 unmodified lines
526526 migrate_enable();
527527 rcu_read_unlock();
528528
529+ /* bpf program can only return 0 or 1:
530+ * 0 : okay
531+ * 1 : retry the same object
532+ * The bpf_iter_run_prog() return value
533+ * will be seq_ops->show() return value.
534+ */
529535 return ret == 0 ? 0 : -EAGAIN;
530536 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t