diff options
author | Yonghong Song <yhs@fb.com> | 2020-05-13 11:02:19 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-05-13 12:30:50 -0700 |
commit | 15172a46fa2796c1a1358a36babd31274716ed41 (patch) | |
tree | c03b6ee05a943f83193860af50c6a9b364b13d4f /kernel/bpf/map_iter.c | |
parent | 2e3ed68bfcd9c5ca2cf8b88ba23a34992ccd0b1f (diff) | |
download | lwn-15172a46fa2796c1a1358a36babd31274716ed41.tar.gz lwn-15172a46fa2796c1a1358a36babd31274716ed41.zip |
bpf: net: Refactor bpf_iter target registration
Currently bpf_iter_reg_target takes parameters from target
and allocates memory to save them. This is really not
necessary, esp. in the future we may grow information
passed from targets to bpf_iter manager.
The patch refactors the code so target reg_info
becomes static and bpf_iter manager can just take
a reference to it.
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200513180219.2949605-1-yhs@fb.com
Diffstat (limited to 'kernel/bpf/map_iter.c')
-rw-r--r-- | kernel/bpf/map_iter.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/kernel/bpf/map_iter.c b/kernel/bpf/map_iter.c index 8162e0c00b9f..c6216a5fe56e 100644 --- a/kernel/bpf/map_iter.c +++ b/kernel/bpf/map_iter.c @@ -81,17 +81,17 @@ static const struct seq_operations bpf_map_seq_ops = { .show = bpf_map_seq_show, }; +static const struct bpf_iter_reg bpf_map_reg_info = { + .target = "bpf_map", + .seq_ops = &bpf_map_seq_ops, + .init_seq_private = NULL, + .fini_seq_private = NULL, + .seq_priv_size = sizeof(struct bpf_iter_seq_map_info), +}; + static int __init bpf_map_iter_init(void) { - struct bpf_iter_reg reg_info = { - .target = "bpf_map", - .seq_ops = &bpf_map_seq_ops, - .init_seq_private = NULL, - .fini_seq_private = NULL, - .seq_priv_size = sizeof(struct bpf_iter_seq_map_info), - }; - - return bpf_iter_reg_target(®_info); + return bpf_iter_reg_target(&bpf_map_reg_info); } late_initcall(bpf_map_iter_init); |