History

bpf: Create anonymous bpf iterator

A new bpf command BPF_ITER_CREATE is added. The anonymous bpf iterator is seq_file based. The seq_file private data are referenced by targets. The bpf_iter infrastructure allocated additional space at seq_file->private before the space used by targets to store some meta data, e.g., prog: prog to run session_id: an unique id for each opened seq_file seq_num: how many times bpf programs are queried in this session done_stop: an internal state to decide whether bpf program should be called in seq_ops->stop() or not The seq_num will start from 0 for valid objects. The bpf program may see the same seq_num more than once if - seq_file buffer overflow happens and the same object is retried by bpf_seq_read(), or - the bpf program explicitly requests a retry of the same object Since module is not supported for bpf_iter, all target registeration happens at __init time, so there is no need to change bpf_iter_unreg_target() as it is used mostly in error path of the init function at which time no bpf iterators have been created yet.

Yonghong Song committed 6 years ago

Commit ac51d991 parent fd4f12b5 files · +168 −0Browse files

Showing the changes to include/linux (1 of 5 files). Show all

Unified · Split

include/linux/bpf.h+1−0
@@ -1144,6 +1144,7 @@ int bpf_iter_reg_target(struct bpf_iter_reg *reg_info); · 1143 unmodified lines
11441144 void bpf_iter_unreg_target(const char *target);
11451145 bool bpf_iter_prog_supported(struct bpf_prog *prog);
11461146 int bpf_iter_link_attach(const union bpf_attr *attr, struct bpf_prog *prog);
1147+int bpf_iter_new_fd(struct bpf_link *link);
11471148
11481149 int bpf_percpu_hash_copy(struct bpf_map *map, void *key, void *value);
11491150 int bpf_percpu_array_copy(struct bpf_map *map, void *key, void *value);

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