summaryrefslogtreecommitdiffstats
path: root/net/core/filter.c
diff options
context:
space:
mode:
authorMartin KaFai Lau <martin.lau@kernel.org>2022-09-01 17:29:06 -0700
committerAlexei Starovoitov <ast@kernel.org>2022-09-02 20:34:31 -0700
commitc2b063ca34586758dcfd76e12696a71a1df849a0 (patch)
treef5d8b0d4ae8214f00d5d8faaae2197b5401660ec /net/core/filter.c
parent0f95f7d42611882a9a6250923dd493951a94961a (diff)
downloadlinux-c2b063ca34586758dcfd76e12696a71a1df849a0.tar.bz2
bpf: Embed kernel CONFIG check into the if statement in bpf_getsockopt
This patch moves the "#ifdef CONFIG_XXX" check into the "if/else" statement itself. The change is done for the bpf_getsockopt() function only. It will make the latter patches easier to follow without the surrounding ifdef macro. Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://lore.kernel.org/r/20220902002906.2893572-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.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index f57f78feb380..55795815cc44 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5222,8 +5222,8 @@ static int __bpf_getsockopt(struct sock *sk, int level, int optname,
default:
goto err_clear;
}
-#ifdef CONFIG_INET
- } else if (level == SOL_TCP && sk->sk_prot->getsockopt == tcp_getsockopt) {
+ } else if (IS_ENABLED(CONFIG_INET) &&
+ level == SOL_TCP && sk->sk_prot->getsockopt == tcp_getsockopt) {
struct inet_connection_sock *icsk;
struct tcp_sock *tp;
@@ -5247,7 +5247,7 @@ static int __bpf_getsockopt(struct sock *sk, int level, int optname,
default:
goto err_clear;
}
- } else if (level == SOL_IP) {
+ } else if (IS_ENABLED(CONFIG_INET) && level == SOL_IP) {
struct inet_sock *inet = inet_sk(sk);
if (optlen != sizeof(int) || sk->sk_family != AF_INET)
@@ -5261,8 +5261,7 @@ static int __bpf_getsockopt(struct sock *sk, int level, int optname,
default:
goto err_clear;
}
-#if IS_ENABLED(CONFIG_IPV6)
- } else if (level == SOL_IPV6) {
+ } else if (IS_ENABLED(CONFIG_IPV6) && level == SOL_IPV6) {
struct ipv6_pinfo *np = inet6_sk(sk);
if (optlen != sizeof(int) || sk->sk_family != AF_INET6)
@@ -5276,8 +5275,6 @@ static int __bpf_getsockopt(struct sock *sk, int level, int optname,
default:
goto err_clear;
}
-#endif
-#endif
} else {
goto err_clear;
}