Commit 11d8b82d authored by Yonghong Song's avatar Yonghong Song Committed by Alexei Starovoitov

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: default avatarSong Liu <songliubraving@fb.com>
Acked-by: default avatarMartin KaFai Lau <kafai@fb.com>
Signed-off-by: default avatarYonghong Song <yhs@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 7a5725dd
...@@ -2696,11 +2696,11 @@ struct bpf_prog_info { ...@@ -2696,11 +2696,11 @@ struct bpf_prog_info {
__u32 btf_id; __u32 btf_id;
__u32 func_info_rec_size; __u32 func_info_rec_size;
__aligned_u64 func_info; __aligned_u64 func_info;
__u32 func_info_cnt; __u32 nr_func_info;
__u32 line_info_cnt; __u32 nr_line_info;
__aligned_u64 line_info; __aligned_u64 line_info;
__aligned_u64 jited_line_info; __aligned_u64 jited_line_info;
__u32 jited_line_info_cnt; __u32 nr_jited_line_info;
__u32 line_info_rec_size; __u32 line_info_rec_size;
__u32 jited_line_info_rec_size; __u32 jited_line_info_rec_size;
} __attribute__((aligned(8))); } __attribute__((aligned(8)));
......
...@@ -2055,15 +2055,15 @@ static int set_info_rec_size(struct bpf_prog_info *info) ...@@ -2055,15 +2055,15 @@ static int set_info_rec_size(struct bpf_prog_info *info)
* _rec_size back to the info. * _rec_size back to the info.
*/ */
if ((info->func_info_cnt || info->func_info_rec_size) && if ((info->nr_func_info || info->func_info_rec_size) &&
info->func_info_rec_size != sizeof(struct bpf_func_info)) info->func_info_rec_size != sizeof(struct bpf_func_info))
return -EINVAL; return -EINVAL;
if ((info->line_info_cnt || info->line_info_rec_size) && if ((info->nr_line_info || info->line_info_rec_size) &&
info->line_info_rec_size != sizeof(struct bpf_line_info)) info->line_info_rec_size != sizeof(struct bpf_line_info))
return -EINVAL; return -EINVAL;
if ((info->jited_line_info_cnt || info->jited_line_info_rec_size) && if ((info->nr_jited_line_info || info->jited_line_info_rec_size) &&
info->jited_line_info_rec_size != sizeof(__u64)) info->jited_line_info_rec_size != sizeof(__u64))
return -EINVAL; return -EINVAL;
...@@ -2125,9 +2125,9 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, ...@@ -2125,9 +2125,9 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
info.xlated_prog_len = 0; info.xlated_prog_len = 0;
info.nr_jited_ksyms = 0; info.nr_jited_ksyms = 0;
info.nr_jited_func_lens = 0; info.nr_jited_func_lens = 0;
info.func_info_cnt = 0; info.nr_func_info = 0;
info.line_info_cnt = 0; info.nr_line_info = 0;
info.jited_line_info_cnt = 0; info.nr_jited_line_info = 0;
goto done; goto done;
} }
...@@ -2268,14 +2268,14 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, ...@@ -2268,14 +2268,14 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
if (prog->aux->btf) if (prog->aux->btf)
info.btf_id = btf_id(prog->aux->btf); info.btf_id = btf_id(prog->aux->btf);
ulen = info.func_info_cnt; ulen = info.nr_func_info;
info.func_info_cnt = prog->aux->func_info_cnt; info.nr_func_info = prog->aux->func_info_cnt;
if (info.func_info_cnt && ulen) { if (info.nr_func_info && ulen) {
if (bpf_dump_raw_ok()) { if (bpf_dump_raw_ok()) {
char __user *user_finfo; char __user *user_finfo;
user_finfo = u64_to_user_ptr(info.func_info); user_finfo = u64_to_user_ptr(info.func_info);
ulen = min_t(u32, info.func_info_cnt, ulen); ulen = min_t(u32, info.nr_func_info, ulen);
if (copy_to_user(user_finfo, prog->aux->func_info, if (copy_to_user(user_finfo, prog->aux->func_info,
info.func_info_rec_size * ulen)) info.func_info_rec_size * ulen))
return -EFAULT; return -EFAULT;
...@@ -2284,14 +2284,14 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, ...@@ -2284,14 +2284,14 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
} }
} }
ulen = info.line_info_cnt; ulen = info.nr_line_info;
info.line_info_cnt = prog->aux->nr_linfo; info.nr_line_info = prog->aux->nr_linfo;
if (info.line_info_cnt && ulen) { if (info.nr_line_info && ulen) {
if (bpf_dump_raw_ok()) { if (bpf_dump_raw_ok()) {
__u8 __user *user_linfo; __u8 __user *user_linfo;
user_linfo = u64_to_user_ptr(info.line_info); user_linfo = u64_to_user_ptr(info.line_info);
ulen = min_t(u32, info.line_info_cnt, ulen); ulen = min_t(u32, info.nr_line_info, ulen);
if (copy_to_user(user_linfo, prog->aux->linfo, if (copy_to_user(user_linfo, prog->aux->linfo,
info.line_info_rec_size * ulen)) info.line_info_rec_size * ulen))
return -EFAULT; return -EFAULT;
...@@ -2300,18 +2300,18 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, ...@@ -2300,18 +2300,18 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
} }
} }
ulen = info.jited_line_info_cnt; ulen = info.nr_jited_line_info;
if (prog->aux->jited_linfo) if (prog->aux->jited_linfo)
info.jited_line_info_cnt = prog->aux->nr_linfo; info.nr_jited_line_info = prog->aux->nr_linfo;
else else
info.jited_line_info_cnt = 0; info.nr_jited_line_info = 0;
if (info.jited_line_info_cnt && ulen) { if (info.nr_jited_line_info && ulen) {
if (bpf_dump_raw_ok()) { if (bpf_dump_raw_ok()) {
__u64 __user *user_linfo; __u64 __user *user_linfo;
u32 i; u32 i;
user_linfo = u64_to_user_ptr(info.jited_line_info); user_linfo = u64_to_user_ptr(info.jited_line_info);
ulen = min_t(u32, info.jited_line_info_cnt, ulen); ulen = min_t(u32, info.nr_jited_line_info, ulen);
for (i = 0; i < ulen; i++) { for (i = 0; i < ulen; i++) {
if (put_user((__u64)(long)prog->aux->jited_linfo[i], if (put_user((__u64)(long)prog->aux->jited_linfo[i],
&user_linfo[i])) &user_linfo[i]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment