aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/filter.c
diff options
context:
space:
mode:
authorMartin KaFai Lau <kafai@fb.com>2022-08-16 23:17:58 -0700
committerAlexei Starovoitov <ast@kernel.org>2022-08-18 17:06:13 -0700
commitebf9e8e653667e834372e9435217a7bf33bec7a0 (patch)
treeb951efbf49bca89da732b97ab6c30a0db405f178 /net/core/filter.c
parentbpf: Initialize the bpf_run_ctx in bpf_iter_run_prog() (diff)
downloadlinux-dev-ebf9e8e653667e834372e9435217a7bf33bec7a0.tar.xz
linux-dev-ebf9e8e653667e834372e9435217a7bf33bec7a0.zip
bpf: Embed kernel CONFIG check into the if statement in bpf_setsockopt
This patch moves the "#ifdef CONFIG_XXX" check into the "if/else" statement itself. The change is done for the bpf_setsockopt() function only. It will make the latter patches easier to follow without the surrounding ifdef macro. Reviewed-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Martin KaFai Lau <kafai@fb.com> Link: https://lore.kernel.org/r/20220817061758.4178374-1-kafai@fb.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'net/core/filter.c')
-rw-r--r--net/core/filter.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index e8508aaafd27..a663d7b96bad 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5116,8 +5116,7 @@ static int __bpf_setsockopt(struct sock *sk, int level, int optname,
default:
ret = -EINVAL;
}
-#ifdef CONFIG_INET
- } else if (level == SOL_IP) {
+ } else if (IS_ENABLED(CONFIG_INET) && level == SOL_IP) {
if (optlen != sizeof(int) || sk->sk_family != AF_INET)
return -EINVAL;
@@ -5138,8 +5137,7 @@ static int __bpf_setsockopt(struct sock *sk, int level, int optname,
default:
ret = -EINVAL;
}
-#if IS_ENABLED(CONFIG_IPV6)
- } else if (level == SOL_IPV6) {
+ } else if (IS_ENABLED(CONFIG_IPV6) && level == SOL_IPV6) {
if (optlen != sizeof(int) || sk->sk_family != AF_INET6)
return -EINVAL;
@@ -5160,8 +5158,7 @@ static int __bpf_setsockopt(struct sock *sk, int level, int optname,
default:
ret = -EINVAL;
}
-#endif
- } else if (level == SOL_TCP &&
+ } else if (IS_ENABLED(CONFIG_INET) && level == SOL_TCP &&
sk->sk_prot->setsockopt == tcp_setsockopt) {
if (optname == TCP_CONGESTION) {
char name[TCP_CA_NAME_MAX];
@@ -5253,7 +5250,6 @@ static int __bpf_setsockopt(struct sock *sk, int level, int optname,
ret = -EINVAL;
}
}
-#endif
} else {
ret = -EINVAL;
}