diff options
author | Andrii Nakryiko <andriin@fb.com> | 2020-04-28 17:16:05 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-04-28 17:27:07 -0700 |
commit | f9d041271cf44ca02eed0cc82e1a6d8c814c53ed (patch) | |
tree | a248c1de80b38d6ab048574215a164431ce8ea83 /kernel/bpf/syscall.c | |
parent | 9b329d0dbe413bf46eb5010edd06b3076960a60a (diff) | |
download | linux-f9d041271cf44ca02eed0cc82e1a6d8c814c53ed.tar.bz2 |
bpf: Refactor bpf_link update handling
Make bpf_link update support more generic by making it into another
bpf_link_ops methods. This allows generic syscall handling code to be agnostic
to various conditionally compiled features (e.g., the case of
CONFIG_CGROUP_BPF). This also allows to keep link type-specific code to remain
static within respective code base. Refactor existing bpf_cgroup_link code and
take advantage of this.
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200429001614.1544-2-andriin@fb.com
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 7626b8024471..f5358e1462eb 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -3645,13 +3645,10 @@ static int link_update(union bpf_attr *attr) goto out_put_progs; } -#ifdef CONFIG_CGROUP_BPF - if (link->ops == &bpf_cgroup_link_lops) { - ret = cgroup_bpf_replace(link, old_prog, new_prog); - goto out_put_progs; - } -#endif - ret = -EINVAL; + if (link->ops->update_prog) + ret = link->ops->update_prog(link, new_prog, old_prog); + else + ret = EINVAL; out_put_progs: if (old_prog) |