aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Roxell <anders.roxell@linaro.org>2018-04-03 08:09:47 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2018-04-04 05:08:36 -0400
commit33491588c1fb2c76ed114a211ad0ee76c16b5a0c (patch)
tree24c992d27bcb56eec8b175cbdce7b5c4fa200c32
parent0e94d87fcfc81883b72574a5cc4638bd87adbb10 (diff)
kernel/bpf/syscall: fix warning defined but not used
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 <anders.roxell@linaro.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r--kernel/bpf/syscall.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 0244973ee544..4ca46df19c9a 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,
1226 } 1226 }
1227} 1227}
1228 1228
1229static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
1230 enum bpf_attach_type attach_type)
1231{
1232 switch (prog->type) {
1233 case BPF_PROG_TYPE_CGROUP_SOCK:
1234 case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
1235 return attach_type == prog->expected_attach_type ? 0 : -EINVAL;
1236 default:
1237 return 0;
1238 }
1239}
1240
1241/* last field in 'union bpf_attr' used by this command */ 1229/* last field in 'union bpf_attr' used by this command */
1242#define BPF_PROG_LOAD_LAST_FIELD expected_attach_type 1230#define BPF_PROG_LOAD_LAST_FIELD expected_attach_type
1243 1231
@@ -1465,6 +1453,18 @@ out_free_tp:
1465 1453
1466#ifdef CONFIG_CGROUP_BPF 1454#ifdef CONFIG_CGROUP_BPF
1467 1455
1456static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog,
1457 enum bpf_attach_type attach_type)
1458{
1459 switch (prog->type) {
1460 case BPF_PROG_TYPE_CGROUP_SOCK:
1461 case BPF_PROG_TYPE_CGROUP_SOCK_ADDR:
1462 return attach_type == prog->expected_attach_type ? 0 : -EINVAL;
1463 default:
1464 return 0;
1465 }
1466}
1467
1468#define BPF_PROG_ATTACH_LAST_FIELD attach_flags 1468#define BPF_PROG_ATTACH_LAST_FIELD attach_flags
1469 1469
1470static int sockmap_get_from_fd(const union bpf_attr *attr, 1470static int sockmap_get_from_fd(const union bpf_attr *attr,