Re: [PATCH] kernel/bpf/syscall: fix warning defined but not used

2018-04-04 Thread Daniel Borkmann
On 04/03/2018 02:09 PM, Anders Roxell wrote:
> There will be a build warning -Wunused-function if CONFIG_CGROUP_BPF
> isn't defined, since the only user is inside #ifdef CONFIG_CGROUP_BPF:
> kernel/bpf/syscall.c:1229:12: warning: ‘bpf_prog_attach_check_attach_type’
> defined but not used [-Wunused-function]
>  static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
> ^
> 
> Current code moves function bpf_prog_attach_check_attach_type inside
> ifdef CONFIG_CGROUP_BPF.
> 
> Fixes: 5e43f899b03a ("bpf: Check attach type at prog load time")
> Signed-off-by: Anders Roxell 

Applied to bpf tree, thanks Anders!


Re: [PATCH] kernel/bpf/syscall: fix warning defined but not used

2018-04-04 Thread Daniel Borkmann
On 04/03/2018 02:09 PM, Anders Roxell wrote:
> There will be a build warning -Wunused-function if CONFIG_CGROUP_BPF
> isn't defined, since the only user is inside #ifdef CONFIG_CGROUP_BPF:
> kernel/bpf/syscall.c:1229:12: warning: ‘bpf_prog_attach_check_attach_type’
> defined but not used [-Wunused-function]
>  static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
> ^
> 
> Current code moves function bpf_prog_attach_check_attach_type inside
> ifdef CONFIG_CGROUP_BPF.
> 
> Fixes: 5e43f899b03a ("bpf: Check attach type at prog load time")
> Signed-off-by: Anders Roxell 

Applied to bpf tree, thanks Anders!


[PATCH] kernel/bpf/syscall: fix warning defined but not used

2018-04-03 Thread Anders Roxell
There will be a build warning -Wunused-function if CONFIG_CGROUP_BPF
isn't defined, since the only user is inside #ifdef CONFIG_CGROUP_BPF:
kernel/bpf/syscall.c:1229:12: warning: ‘bpf_prog_attach_check_attach_type’
defined but not used [-Wunused-function]
 static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
^

Current code moves function bpf_prog_attach_check_attach_type inside
ifdef CONFIG_CGROUP_BPF.

Fixes: 5e43f899b03a ("bpf: Check attach type at prog load time")
Signed-off-by: Anders Roxell 
---
 kernel/bpf/syscall.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 7457f2676c6d..56f49557adda 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1226,18 +1226,6 @@ bpf_prog_load_check_attach_type(enum bpf_prog_type 
prog_type,
}
 }
 
-static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
-enum bpf_attach_type attach_type)
-{
-   switch (prog->type) {
-   case BPF_PROG_TYPE_CGROUP_SOCK:
-   case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
-   return attach_type == prog->expected_attach_type ? 0 : -EINVAL;
-   default:
-   return 0;
-   }
-}
-
 /* last field in 'union bpf_attr' used by this command */
 #defineBPF_PROG_LOAD_LAST_FIELD expected_attach_type
 
@@ -1465,6 +1453,18 @@ static int bpf_raw_tracepoint_open(const union bpf_attr 
*attr)
 
 #ifdef CONFIG_CGROUP_BPF
 
+static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
+enum bpf_attach_type attach_type)
+{
+   switch (prog->type) {
+   case BPF_PROG_TYPE_CGROUP_SOCK:
+   case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
+   return attach_type == prog->expected_attach_type ? 0 : -EINVAL;
+   default:
+   return 0;
+   }
+}
+
 #define BPF_PROG_ATTACH_LAST_FIELD attach_flags
 
 static int sockmap_get_from_fd(const union bpf_attr *attr,
-- 
2.16.2



[PATCH] kernel/bpf/syscall: fix warning defined but not used

2018-04-03 Thread Anders Roxell
There will be a build warning -Wunused-function if CONFIG_CGROUP_BPF
isn't defined, since the only user is inside #ifdef CONFIG_CGROUP_BPF:
kernel/bpf/syscall.c:1229:12: warning: ‘bpf_prog_attach_check_attach_type’
defined but not used [-Wunused-function]
 static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
^

Current code moves function bpf_prog_attach_check_attach_type inside
ifdef CONFIG_CGROUP_BPF.

Fixes: 5e43f899b03a ("bpf: Check attach type at prog load time")
Signed-off-by: Anders Roxell 
---
 kernel/bpf/syscall.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 7457f2676c6d..56f49557adda 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1226,18 +1226,6 @@ bpf_prog_load_check_attach_type(enum bpf_prog_type 
prog_type,
}
 }
 
-static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
-enum bpf_attach_type attach_type)
-{
-   switch (prog->type) {
-   case BPF_PROG_TYPE_CGROUP_SOCK:
-   case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
-   return attach_type == prog->expected_attach_type ? 0 : -EINVAL;
-   default:
-   return 0;
-   }
-}
-
 /* last field in 'union bpf_attr' used by this command */
 #defineBPF_PROG_LOAD_LAST_FIELD expected_attach_type
 
@@ -1465,6 +1453,18 @@ static int bpf_raw_tracepoint_open(const union bpf_attr 
*attr)
 
 #ifdef CONFIG_CGROUP_BPF
 
+static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
+enum bpf_attach_type attach_type)
+{
+   switch (prog->type) {
+   case BPF_PROG_TYPE_CGROUP_SOCK:
+   case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
+   return attach_type == prog->expected_attach_type ? 0 : -EINVAL;
+   default:
+   return 0;
+   }
+}
+
 #define BPF_PROG_ATTACH_LAST_FIELD attach_flags
 
 static int sockmap_get_from_fd(const union bpf_attr *attr,
-- 
2.16.2