Skip to contentSkip to conversation

ebpf: fix parameter naming confusing

PATCH In review YangYuxi 2 participants 2 messages Jul 17, 2020 – Jul 21, 2020

Subsystems (4)
lore
Share & tools
lore

YangYuxi

author
#0 lore raw

PATCH 1/1 ebpf: fix parameter naming confusing

---
 kernel/bpf/syscall.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/bpf/syscall.c +5 -5
index 0fd80ac81f70..300ae16baffc 100644
@@ -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;
 	}
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 11 lines · YangYuxi
---
 kernel/bpf/syscall.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/bpf/syscall.c +0 -0
index 0fd80ac81f70..300ae16baffc 100644

kernel/bpf/syscall.c struct bpf_prog *bpf_prog_inc_not_zero(struct bpf_prog *prog) · line 1888

Quoted 10 lines
kernel/bpf/syscall.c +2 -2
@@ -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.