Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp719844ybg; Wed, 3 Jun 2020 11:46:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUzzUZqYANFe9bi+QGmRSfAeyTTGJzA9A1gUfD5NVlH226yNaY7Aoo741Mi6of8LYmeyuy X-Received: by 2002:aa7:d0c5:: with SMTP id u5mr765126edo.51.1591209987067; Wed, 03 Jun 2020 11:46:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591209987; cv=none; d=google.com; s=arc-20160816; b=zS/klVyb12AVheu+XgARS936K5qHtI2Ha8YtSv/eiT9YhEzPRJMv/s9z7JaNxnbdlo WBg0TidpT9JoJq1lj3Bdrz1SuaCVX6SwZomNv9dLMRMz0P1fOwllPuVC7HLfK6yn1Bgr 0y4EgxAaKrryMBNXC2/S5Xo9whbpmQH4mmFS90dCiWiGswSXdlHoZBAmCML1LMUDul6w T9aJ+fcRhp6K7M9YGhxRLV1CYCZx1tjgrYvI/SXJM2NTGTgnsssRgKksHFZpOEAeJe/n 3P+l/fWvtxvIzVJPyjFSciyDuaGT7ImpJSsPHr0Wo0CaE6KQxZ6BfPAF4Uxg83Op18G6 ttQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=0JtjVDE29MCLUy8xo6bhPCvI/GjrzGqHCR8IT29ZGyo=; b=IiUcyJ+jEN6818CGNoAOOn64Qgi5oWLSDnbokd5uBP9m6rzPKODgr9ZwzRsIwXx2uV FLMFIQ1I/K5n1hEVLP/uvWGUQ0BLTLTOBKrDS0/QQHrnmGGcj8EgrDi44YKAJENBb7Qc /RgPw8ATYvFD8vEMdR3x+lzPrJstQkFajjxoRz6235GXLcYrrZ/O2Tk6JayGP8QXKjTF dyvU6aY2ATkDS5wGU1mhh9gyUyu+uIp7KRSHHCpIxoFAsY8knB8ObJVbxb5LAwZ9fgF6 XnB6Gr/bIULZcNc7/+reMUq3hzrfs3L5PkAGhGp3JvdglZo761rBDlMe0CFwKFuxuoi7 G2Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iV1rUWoe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hb8si224163ejb.207.2020.06.03.11.46.02; Wed, 03 Jun 2020 11:46:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iV1rUWoe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726034AbgFCSoH (ORCPT + 99 others); Wed, 3 Jun 2020 14:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbgFCSoG (ORCPT ); Wed, 3 Jun 2020 14:44:06 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F9E0C08C5C0; Wed, 3 Jun 2020 11:44:06 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id m18so4070312ljo.5; Wed, 03 Jun 2020 11:44:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=0JtjVDE29MCLUy8xo6bhPCvI/GjrzGqHCR8IT29ZGyo=; b=iV1rUWoetNNHqfxdbVy+yYhQHKioYKhsY+4smiKl/hWx7bEpA2Vh0UUZVSDC7v/fDl 9PeNQV+86W6yM0oLzhF1nm/VnsLqKqPDMTx4IIZ80ebYgIPiu4QN3ZIxC6dDnKAJJ3Qd 7eJWkJgrfEgNFWwAXzxEuc1uMqXlpAIHAcU2WwRKm2V3mHL1S5t9QFXEv2PkD+5pTKO+ T953CehXyAbrxXN1UyQVGDAXhx7q9tsRbYOGmFehPojmOmMSDhDmUzDdqkuqOE8RB7ZY DW97JwsuKCiRGGEgd4J1bABeAIB6CjxXt1+4ujoLz9s1eBqoe1xYKD7tZDdXTFMK9kTG JOIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=0JtjVDE29MCLUy8xo6bhPCvI/GjrzGqHCR8IT29ZGyo=; b=dSm8eurOU4DCK5/W+y6ckBiQBa6qq2MqrQ5LR7N+zDUtjDRjWKFvextWyckiuURxz+ 4/m/Zeq5ASZEN/uSuw7p330JARfWfL4XHZhGRmbKJbvQTyt97V3KIykVRZmgnubWkiXv 85huHCbdayMjDsNe3jHfyocTOWkKMYVvga8kWK4YtmJbL/BtCVQmt5O9+tLZZMkf/uuE lXqYtOOqeGfpB5yg/x0JlMvzsMSFJ3S1MVqtzEVFPc8EsDdJv7+18lIRLiaiiScO0Sy+ BrCXN076se/bGaqQFLS9Mq9RKVK+mUtEa9Fysthv51C2S6Vmw9BVLhCQ8JBtw9w/zymt +Iig== X-Gm-Message-State: AOAM531yT+oXaJTNwwiCxjDcoQDddwYkSB5mGl7Ky/R/hFb2ZgQxF0FL guRENxDkHZ+V9h4nIOiiCft4Al2df6Ltv2fWJac= X-Received: by 2002:a2e:9187:: with SMTP id f7mr299407ljg.450.1591209844436; Wed, 03 Jun 2020 11:44:04 -0700 (PDT) MIME-Version: 1.0 References: <20200603081124.1627600-1-matthieu.baerts@tessares.net> <1cb3266c-7c8c-ebe6-0b6e-6d970e0adbd1@tessares.net> <20200603181455.4sajgdyat7rkxxnf@ast-mbp.dhcp.thefacebook.com> <3573c0dd-baa8-5313-067a-eec6b04f0f36@tessares.net> In-Reply-To: <3573c0dd-baa8-5313-067a-eec6b04f0f36@tessares.net> From: Alexei Starovoitov Date: Wed, 3 Jun 2020 11:43:53 -0700 Message-ID: Subject: Re: [PATCH bpf] bpf: fix unused-var without NETDEVICES To: Matthieu Baerts Cc: Ferenc Fejes , Network Development , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , "David S. Miller" , Jakub Kicinski , bpf , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 3, 2020 at 11:41 AM Matthieu Baerts wrote: > > Hi Alexei, > > On 03/06/2020 20:14, Alexei Starovoitov wrote: > > On Wed, Jun 03, 2020 at 11:12:01AM +0200, Matthieu Baerts wrote: > >> Hi Ferenc, > >> > >> On 03/06/2020 10:56, Ferenc Fejes wrote: > >>> Matthieu Baerts ezt =C3=ADrta (id=C5= =91pont: > >>> 2020. j=C3=BAn. 3., Sze, 10:11): > >>>> > >>>> A recent commit added new variables only used if CONFIG_NETDEVICES i= s > >>>> set. > >>> > >>> Thank you for noticing and fixed this! > >>> > >>>> A simple fix is to only declare these variables if the same > >>>> condition is valid. > >>>> > >>>> Other solutions could be to move the code related to SO_BINDTODEVICE > >>>> option from _bpf_setsockopt() function to a dedicated one or only > >>>> declare these variables in the related "case" section. > >>> > >>> Yes thats indeed a cleaner way to approach this. I will prepare a fix= for that. > >> > >> I should have maybe added that I didn't take this approach because in = the > >> rest of the code, I don't see that variables are declared only in a "c= ase" > >> section (no "{" ... "}" after "case") and code is generally not moved = into a > >> dedicated function in these big switch/cases. But maybe it makes sense= here > >> because of the #ifdef! > >> At the end, I took the simple approach because it is for -net. > >> > >> In other words, I don't know what maintainers would prefer here but I = am > >> happy to see any another solutions implemented to remove these compile= r > >> warnings :) > > > > since CONFIG_NETDEVICES doesn't change anything in .h > > I think the best is to remove #ifdef CONFIG_NETDEVICES from net/core/fi= lter.c > > and rely on sock_bindtoindex() returning ENOPROTOOPT > > in the extreme case of oddly configured kernels. > > Good idea, thank you! > I can send a patch implementing that. Please do. Your 'Notes:' section was absolutely correct in terms of different trees relationship :) Thank you.