From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EEB9C19F21 for ; Wed, 27 Jul 2022 06:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230165AbiG0GJy (ORCPT ); Wed, 27 Jul 2022 02:09:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbiG0GJt (ORCPT ); Wed, 27 Jul 2022 02:09:49 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F6D93FA32 for ; Tue, 26 Jul 2022 23:09:49 -0700 (PDT) Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26QND15Q023034 for ; Tue, 26 Jul 2022 23:09:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=oBzZsS9YU5IlPp/uz4kK4qHUrMDYMlhpxpusLRYRTog=; b=JJWW+THEpRMbB2koL8w5JrY3Evu0esVMDTiSY+uGg8u4/Rl60+EefbIVVh9PyWQRAaxt ibYk9ZMmsbshiykcgC7RAXmgMJ1qFWHJnkV6WHs8jbt79aBL/X4Kwz3QrCA3xC0DvDNW v5i49nThodhAsm/VzBIP1lzUatJ2Q3sQEQ4= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3hjjnsmqkg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 26 Jul 2022 23:09:48 -0700 Received: from twshared14818.18.frc3.facebook.com (2620:10d:c085:108::4) by mail.thefacebook.com (2620:10d:c085:21d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 26 Jul 2022 23:09:48 -0700 Received: by devbig933.frc1.facebook.com (Postfix, from userid 6611) id AC832757CCF3; Tue, 26 Jul 2022 23:09:40 -0700 (PDT) From: Martin KaFai Lau To: , CC: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , David Miller , Eric Dumazet , Jakub Kicinski , , Paolo Abeni Subject: [PATCH bpf-next 07/14] bpf: Embed kernel CONFIG check into the if statement in bpf_setsockopt Date: Tue, 26 Jul 2022 23:09:40 -0700 Message-ID: <20220727060940.2376067-1-kafai@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220727060856.2370358-1-kafai@fb.com> References: <20220727060856.2370358-1-kafai@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: 4016TLRrTpWr3ZyoRA4qNFqCENiVwb1g X-Proofpoint-GUID: 4016TLRrTpWr3ZyoRA4qNFqCENiVwb1g X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_07,2022-07-26_01,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org 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. Signed-off-by: Martin KaFai Lau --- net/core/filter.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 5669248aff25..01cb4a01b1c1 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -5113,8 +5113,7 @@ static int __bpf_setsockopt(struct sock *sk, int le= vel, int optname, default: ret =3D -EINVAL; } -#ifdef CONFIG_INET - } else if (level =3D=3D SOL_IP) { + } else if (IS_ENABLED(CONFIG_INET) && level =3D=3D SOL_IP) { if (optlen !=3D sizeof(int) || sk->sk_family !=3D AF_INET) return -EINVAL; =20 @@ -5135,8 +5134,7 @@ static int __bpf_setsockopt(struct sock *sk, int le= vel, int optname, default: ret =3D -EINVAL; } -#if IS_ENABLED(CONFIG_IPV6) - } else if (level =3D=3D SOL_IPV6) { + } else if (IS_ENABLED(CONFIG_IPV6) && level =3D=3D SOL_IPV6) { if (optlen !=3D sizeof(int) || sk->sk_family !=3D AF_INET6) return -EINVAL; =20 @@ -5157,8 +5155,7 @@ static int __bpf_setsockopt(struct sock *sk, int le= vel, int optname, default: ret =3D -EINVAL; } -#endif - } else if (level =3D=3D SOL_TCP && + } else if (IS_ENABLED(CONFIG_INET) && level =3D=3D SOL_TCP && sk->sk_prot->setsockopt =3D=3D tcp_setsockopt) { if (optname =3D=3D TCP_CONGESTION) { char name[TCP_CA_NAME_MAX]; @@ -5250,7 +5247,6 @@ static int __bpf_setsockopt(struct sock *sk, int le= vel, int optname, ret =3D -EINVAL; } } -#endif } else { ret =3D -EINVAL; } --=20 2.30.2