The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ebpf: fix parameter naming confusing
@ 2020-07-16 13:41 YangYuxi
  0 siblings, 0 replies; 3+ messages in thread
From: YangYuxi @ 2020-07-16 13:41 UTC (permalink / raw)
  To: ast, daniel, kafai, songliubraving, yhs, andriin, john.fastabend,
	kpsingh, netdev, bpf, linux-kernel

Signed-off-by: YangYuxi <yx.atom1@gmail.com>
---
 kernel/bpf/syscall.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 0fd80ac81f70..42406f7275b7 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1881,13 +1881,13 @@ struct bpf_prog *bpf_prog_inc_not_zero(struct bpf_prog *prog)
 EXPORT_SYMBOL_GPL(bpf_prog_inc_not_zero);
 
 bool bpf_prog_get_ok(struct bpf_prog *prog,
-			    enum bpf_prog_type *attach_type, bool attach_drv)
+			    enum bpf_prog_type *prog_type, bool attach_drv)
 {
 	/* not an attachment, just a refcount inc, always allow */
 	if (!attach_type)
 		return true;
 
-	if (prog->type != *attach_type)
+	if (prog->type != *prog_type)
 		return false;
 	if (bpf_prog_is_dev_bound(prog->aux) && !attach_drv)
 		return false;
@@ -1895,7 +1895,7 @@ bool bpf_prog_get_ok(struct bpf_prog *prog,
 	return true;
 }
 
-static struct bpf_prog *__bpf_prog_get(u32 ufd, enum bpf_prog_type *attach_type,
+static struct bpf_prog *__bpf_prog_get(u32 ufd, enum bpf_prog_type *prog_type,
 				       bool attach_drv)
 {
 	struct fd f = fdget(ufd);
@@ -1904,7 +1904,7 @@ static struct bpf_prog *__bpf_prog_get(u32 ufd, enum bpf_prog_type *attach_type,
 	prog = ____bpf_prog_get(f);
 	if (IS_ERR(prog))
 		return prog;
-	if (!bpf_prog_get_ok(prog, attach_type, attach_drv)) {
+	if (!bpf_prog_get_ok(prog, prog_type, attach_drv)) {
 		prog = ERR_PTR(-EINVAL);
 		goto out;
 	}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] ebpf: fix parameter naming confusing
@ 2020-07-17  2:08 YangYuxi
  2020-07-21 19:17 ` Alexei Starovoitov
  0 siblings, 1 reply; 3+ messages in thread
From: YangYuxi @ 2020-07-17  2:08 UTC (permalink / raw)
  To: ast, daniel, kafai, songliubraving, yhs, andriin, john.fastabend,
	kpsingh, netdev, bpf, linux-kernel

Signed-off-by: YangYuxi <yx.atom1@gmail.com>
---
 kernel/bpf/syscall.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 0fd80ac81f70..300ae16baffc 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1881,13 +1881,13 @@ struct bpf_prog *bpf_prog_inc_not_zero(struct bpf_prog *prog)
 EXPORT_SYMBOL_GPL(bpf_prog_inc_not_zero);
 
 bool bpf_prog_get_ok(struct bpf_prog *prog,
-			    enum bpf_prog_type *attach_type, bool attach_drv)
+			    enum bpf_prog_type *prog_type, bool attach_drv)
 {
 	/* not an attachment, just a refcount inc, always allow */
-	if (!attach_type)
+	if (!prog_type)
 		return true;
 
-	if (prog->type != *attach_type)
+	if (prog->type != *prog_type)
 		return false;
 	if (bpf_prog_is_dev_bound(prog->aux) && !attach_drv)
 		return false;
@@ -1895,7 +1895,7 @@ bool bpf_prog_get_ok(struct bpf_prog *prog,
 	return true;
 }
 
-static struct bpf_prog *__bpf_prog_get(u32 ufd, enum bpf_prog_type *attach_type,
+static struct bpf_prog *__bpf_prog_get(u32 ufd, enum bpf_prog_type *prog_type,
 				       bool attach_drv)
 {
 	struct fd f = fdget(ufd);
@@ -1904,7 +1904,7 @@ static struct bpf_prog *__bpf_prog_get(u32 ufd, enum bpf_prog_type *attach_type,
 	prog = ____bpf_prog_get(f);
 	if (IS_ERR(prog))
 		return prog;
-	if (!bpf_prog_get_ok(prog, attach_type, attach_drv)) {
+	if (!bpf_prog_get_ok(prog, prog_type, attach_drv)) {
 		prog = ERR_PTR(-EINVAL);
 		goto out;
 	}
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ebpf: fix parameter naming confusing
  2020-07-17  2:08 [PATCH] ebpf: fix parameter naming confusing YangYuxi
@ 2020-07-21 19:17 ` Alexei Starovoitov
  0 siblings, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2020-07-21 19:17 UTC (permalink / raw)
  To: YangYuxi
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, John Fastabend, KP Singh,
	Network Development, bpf, LKML

On Thu, Jul 16, 2020 at 7:08 PM YangYuxi <yx.atom1@gmail.com> wrote:
>
> Signed-off-by: YangYuxi <yx.atom1@gmail.com>
> ---
>  kernel/bpf/syscall.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 0fd80ac81f70..300ae16baffc 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -1881,13 +1881,13 @@ struct bpf_prog *bpf_prog_inc_not_zero(struct bpf_prog *prog)
>  EXPORT_SYMBOL_GPL(bpf_prog_inc_not_zero);
>
>  bool bpf_prog_get_ok(struct bpf_prog *prog,
> -                           enum bpf_prog_type *attach_type, bool attach_drv)
> +                           enum bpf_prog_type *prog_type, bool attach_drv)
>  {
>         /* not an attachment, just a refcount inc, always allow */
> -       if (!attach_type)
> +       if (!prog_type)
>                 return true;

I think it makes it worse.
Now the comment doesn't match the code.
And attach_drv name also looks out of place.
Technically program type is also an attach type to some degree.
The name could be a bit confusing, but in combination with type:
'enum bpf_prog_type *attach_type'
I think it's pretty clear what these functions are doing.
So I prefer to keep the code as-is.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-21 19:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-17  2:08 [PATCH] ebpf: fix parameter naming confusing YangYuxi
2020-07-21 19:17 ` Alexei Starovoitov
  -- strict thread matches above, loose matches on Subject: below --
2020-07-16 13:41 YangYuxi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox