Skip to content

Commit 11d8b82

Browse files
yonghong-songAlexei Starovoitov
authored andcommitted
bpf: rename *_info_cnt to nr_*_info in bpf_prog_info
In uapi bpf.h, currently we have the following fields in the struct bpf_prog_info: __u32 func_info_cnt; __u32 line_info_cnt; __u32 jited_line_info_cnt; The above field names "func_info_cnt" and "line_info_cnt" also appear in union bpf_attr for program loading. The original intention is to keep the names the same between bpf_prog_info and bpf_attr so it will imply what we returned to user space will be the same as what the user space passed to the kernel. Such a naming convention in bpf_prog_info is not consistent with other fields like: __u32 nr_jited_ksyms; __u32 nr_jited_func_lens; This patch made this adjustment so in bpf_prog_info newly introduced *_info_cnt becomes nr_*_info. Acked-by: Song Liu <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Signed-off-by: Yonghong Song <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 7a5725d commit 11d8b82

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

include/uapi/linux/bpf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,11 +2696,11 @@ struct bpf_prog_info {
26962696
__u32 btf_id;
26972697
__u32 func_info_rec_size;
26982698
__aligned_u64 func_info;
2699-
__u32 func_info_cnt;
2700-
__u32 line_info_cnt;
2699+
__u32 nr_func_info;
2700+
__u32 nr_line_info;
27012701
__aligned_u64 line_info;
27022702
__aligned_u64 jited_line_info;
2703-
__u32 jited_line_info_cnt;
2703+
__u32 nr_jited_line_info;
27042704
__u32 line_info_rec_size;
27052705
__u32 jited_line_info_rec_size;
27062706
} __attribute__((aligned(8)));

kernel/bpf/syscall.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,15 +2055,15 @@ static int set_info_rec_size(struct bpf_prog_info *info)
20552055
* _rec_size back to the info.
20562056
*/
20572057

2058-
if ((info->func_info_cnt || info->func_info_rec_size) &&
2058+
if ((info->nr_func_info || info->func_info_rec_size) &&
20592059
info->func_info_rec_size != sizeof(struct bpf_func_info))
20602060
return -EINVAL;
20612061

2062-
if ((info->line_info_cnt || info->line_info_rec_size) &&
2062+
if ((info->nr_line_info || info->line_info_rec_size) &&
20632063
info->line_info_rec_size != sizeof(struct bpf_line_info))
20642064
return -EINVAL;
20652065

2066-
if ((info->jited_line_info_cnt || info->jited_line_info_rec_size) &&
2066+
if ((info->nr_jited_line_info || info->jited_line_info_rec_size) &&
20672067
info->jited_line_info_rec_size != sizeof(__u64))
20682068
return -EINVAL;
20692069

@@ -2125,9 +2125,9 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
21252125
info.xlated_prog_len = 0;
21262126
info.nr_jited_ksyms = 0;
21272127
info.nr_jited_func_lens = 0;
2128-
info.func_info_cnt = 0;
2129-
info.line_info_cnt = 0;
2130-
info.jited_line_info_cnt = 0;
2128+
info.nr_func_info = 0;
2129+
info.nr_line_info = 0;
2130+
info.nr_jited_line_info = 0;
21312131
goto done;
21322132
}
21332133

@@ -2268,14 +2268,14 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
22682268
if (prog->aux->btf)
22692269
info.btf_id = btf_id(prog->aux->btf);
22702270

2271-
ulen = info.func_info_cnt;
2272-
info.func_info_cnt = prog->aux->func_info_cnt;
2273-
if (info.func_info_cnt && ulen) {
2271+
ulen = info.nr_func_info;
2272+
info.nr_func_info = prog->aux->func_info_cnt;
2273+
if (info.nr_func_info && ulen) {
22742274
if (bpf_dump_raw_ok()) {
22752275
char __user *user_finfo;
22762276

22772277
user_finfo = u64_to_user_ptr(info.func_info);
2278-
ulen = min_t(u32, info.func_info_cnt, ulen);
2278+
ulen = min_t(u32, info.nr_func_info, ulen);
22792279
if (copy_to_user(user_finfo, prog->aux->func_info,
22802280
info.func_info_rec_size * ulen))
22812281
return -EFAULT;
@@ -2284,14 +2284,14 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
22842284
}
22852285
}
22862286

2287-
ulen = info.line_info_cnt;
2288-
info.line_info_cnt = prog->aux->nr_linfo;
2289-
if (info.line_info_cnt && ulen) {
2287+
ulen = info.nr_line_info;
2288+
info.nr_line_info = prog->aux->nr_linfo;
2289+
if (info.nr_line_info && ulen) {
22902290
if (bpf_dump_raw_ok()) {
22912291
__u8 __user *user_linfo;
22922292

22932293
user_linfo = u64_to_user_ptr(info.line_info);
2294-
ulen = min_t(u32, info.line_info_cnt, ulen);
2294+
ulen = min_t(u32, info.nr_line_info, ulen);
22952295
if (copy_to_user(user_linfo, prog->aux->linfo,
22962296
info.line_info_rec_size * ulen))
22972297
return -EFAULT;
@@ -2300,18 +2300,18 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
23002300
}
23012301
}
23022302

2303-
ulen = info.jited_line_info_cnt;
2303+
ulen = info.nr_jited_line_info;
23042304
if (prog->aux->jited_linfo)
2305-
info.jited_line_info_cnt = prog->aux->nr_linfo;
2305+
info.nr_jited_line_info = prog->aux->nr_linfo;
23062306
else
2307-
info.jited_line_info_cnt = 0;
2308-
if (info.jited_line_info_cnt && ulen) {
2307+
info.nr_jited_line_info = 0;
2308+
if (info.nr_jited_line_info && ulen) {
23092309
if (bpf_dump_raw_ok()) {
23102310
__u64 __user *user_linfo;
23112311
u32 i;
23122312

23132313
user_linfo = u64_to_user_ptr(info.jited_line_info);
2314-
ulen = min_t(u32, info.jited_line_info_cnt, ulen);
2314+
ulen = min_t(u32, info.nr_jited_line_info, ulen);
23152315
for (i = 0; i < ulen; i++) {
23162316
if (put_user((__u64)(long)prog->aux->jited_linfo[i],
23172317
&user_linfo[i]))

0 commit comments

Comments
 (0)