Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C49B1C282C4 for ; Mon, 4 Feb 2019 20:23:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 951AC2087C for ; Mon, 4 Feb 2019 20:23:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728387AbfBDUXQ (ORCPT ); Mon, 4 Feb 2019 15:23:16 -0500 Received: from www62.your-server.de ([213.133.104.62]:38578 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726542AbfBDUXQ (ORCPT ); Mon, 4 Feb 2019 15:23:16 -0500 Received: from [88.198.220.130] (helo=sslproxy01.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1gqklr-0005oQ-Je; Mon, 04 Feb 2019 21:23:11 +0100 Received: from [178.197.249.40] (helo=linux.home) by sslproxy01.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1gqklr-0000EG-BR; Mon, 04 Feb 2019 21:23:11 +0100 Subject: Re: [PATCH bpf-next] bpf: support SO_DEBUG in bpf_setsockopt() To: Alexei Starovoitov , Yafang Shao Cc: kafai@fb.com, brakmo@fb.com, ast@kernel.org, netdev@vger.kernel.org, shaoyafang@didiglobal.com References: <1549181707-16864-1-git-send-email-laoar.shao@gmail.com> <20190204173517.6o5v7yd5yn7pxjzi@ast-mbp.dhcp.thefacebook.com> From: Daniel Borkmann Message-ID: <7d5c07bf-ec6c-3fac-d4f0-ff0bb7b5d174@iogearbox.net> Date: Mon, 4 Feb 2019 21:23:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20190204173517.6o5v7yd5yn7pxjzi@ast-mbp.dhcp.thefacebook.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.2/25350/Mon Feb 4 11:34:43 2019) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 02/04/2019 06:35 PM, Alexei Starovoitov wrote: > On Sun, Feb 03, 2019 at 04:15:07PM +0800, Yafang Shao wrote: >> Then we can enable/disable socket debugging without modifying user code. >> That is more convenient for debugging. >> >> Signed-off-by: Yafang Shao >> --- >> include/net/sock.h | 8 ++++++++ >> net/core/filter.c | 3 +++ >> net/core/sock.c | 8 -------- >> 3 files changed, 11 insertions(+), 8 deletions(-) >> >> diff --git a/include/net/sock.h b/include/net/sock.h >> index 2b229f7..8decee9 100644 >> --- a/include/net/sock.h >> +++ b/include/net/sock.h >> @@ -1935,6 +1935,14 @@ static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n) >> } >> } >> >> +static inline void sock_valbool_flag(struct sock *sk, int bit, int valbool) >> +{ >> + if (valbool) >> + sock_set_flag(sk, bit); >> + else >> + sock_reset_flag(sk, bit); >> +} >> + >> bool sk_mc_loop(struct sock *sk); >> >> static inline bool sk_can_gso(const struct sock *sk) >> diff --git a/net/core/filter.c b/net/core/filter.c >> index 3a49f68..ce5da57 100644 >> --- a/net/core/filter.c >> +++ b/net/core/filter.c >> @@ -4111,6 +4111,9 @@ static unsigned long bpf_xdp_copy(void *dst_buff, const void *src_buff, >> >> /* Only some socketops are supported */ >> switch (optname) { >> + case SO_DEBUG: >> + sock_valbool_flag(sk, SOCK_DBG, val); >> + break; > > I'm missing the point here. > This flag has any effect only when SOCK_DEBUGGING is set. > But it is off in distros. > Since it's for custom debug kernel only why bother with > setting the flag via bpf prog? +1, this seems like some ancient debugging interface. Back at last netconf there was a proposal [0] to have a tcp_stats(sk, TCP_MIB_...) API for MIBs counter such that this can be traced via BPF on a per socket basis, for example. Might be worthwhile to work into that direction instead and potentially get rid of the SOCK_DEBUG() statements and convert (where appropriate) to such an interface. Thoughts? [0] page 14, http://vger.kernel.org/netconf2018_files/BrendanGregg_netconf2018.pdf