Skip to content

Commit 9b8d543

Browse files
Tao Chenanakryiko
authored andcommitted
bpf: Remove attach_type in bpf_cgroup_link
Use attach_type in bpf_link, and remove it in bpf_cgroup_link. Signed-off-by: Tao Chen <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent b725441 commit 9b8d543

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

include/linux/bpf-cgroup.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ struct bpf_cgroup_storage {
103103
struct bpf_cgroup_link {
104104
struct bpf_link link;
105105
struct cgroup *cgroup;
106-
enum bpf_attach_type type;
107106
};
108107

109108
struct bpf_prog_list {

kernel/bpf/cgroup.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ static int __cgroup_bpf_replace(struct cgroup *cgrp,
984984
struct hlist_head *progs;
985985
bool found = false;
986986

987-
atype = bpf_cgroup_atype_find(link->type, new_prog->aux->attach_btf_id);
987+
atype = bpf_cgroup_atype_find(link->link.attach_type, new_prog->aux->attach_btf_id);
988988
if (atype < 0)
989989
return -EINVAL;
990990

@@ -1396,8 +1396,8 @@ static void bpf_cgroup_link_release(struct bpf_link *link)
13961396
}
13971397

13981398
WARN_ON(__cgroup_bpf_detach(cg_link->cgroup, NULL, cg_link,
1399-
cg_link->type, 0));
1400-
if (cg_link->type == BPF_LSM_CGROUP)
1399+
link->attach_type, 0));
1400+
if (link->attach_type == BPF_LSM_CGROUP)
14011401
bpf_trampoline_unlink_cgroup_shim(cg_link->link.prog);
14021402

14031403
cg = cg_link->cgroup;
@@ -1439,7 +1439,7 @@ static void bpf_cgroup_link_show_fdinfo(const struct bpf_link *link,
14391439
"cgroup_id:\t%llu\n"
14401440
"attach_type:\t%d\n",
14411441
cg_id,
1442-
cg_link->type);
1442+
link->attach_type);
14431443
}
14441444

14451445
static int bpf_cgroup_link_fill_link_info(const struct bpf_link *link,
@@ -1455,7 +1455,7 @@ static int bpf_cgroup_link_fill_link_info(const struct bpf_link *link,
14551455
cgroup_unlock();
14561456

14571457
info->cgroup.cgroup_id = cg_id;
1458-
info->cgroup.attach_type = cg_link->type;
1458+
info->cgroup.attach_type = link->attach_type;
14591459
return 0;
14601460
}
14611461

@@ -1497,7 +1497,6 @@ int cgroup_bpf_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
14971497
bpf_link_init(&link->link, BPF_LINK_TYPE_CGROUP, &bpf_cgroup_link_lops,
14981498
prog, attr->link_create.attach_type);
14991499
link->cgroup = cgrp;
1500-
link->type = attr->link_create.attach_type;
15011500

15021501
err = bpf_link_prime(&link->link, &link_primer);
15031502
if (err) {
@@ -1506,7 +1505,7 @@ int cgroup_bpf_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
15061505
}
15071506

15081507
err = cgroup_bpf_attach(cgrp, NULL, NULL, link,
1509-
link->type, BPF_F_ALLOW_MULTI | attr->link_create.flags,
1508+
link->link.attach_type, BPF_F_ALLOW_MULTI | attr->link_create.flags,
15101509
attr->link_create.cgroup.relative_fd,
15111510
attr->link_create.cgroup.expected_revision);
15121511
if (err) {

0 commit comments

Comments
 (0)