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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 287BEC433DB for ; Wed, 17 Mar 2021 17:00:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA34264E90 for ; Wed, 17 Mar 2021 17:00:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232167AbhCQQ7y (ORCPT ); Wed, 17 Mar 2021 12:59:54 -0400 Received: from www62.your-server.de ([213.133.104.62]:43806 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232000AbhCQQ7w (ORCPT ); Wed, 17 Mar 2021 12:59:52 -0400 Received: from sslproxy03.your-server.de ([88.198.220.132]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1lMZWQ-0008vr-LU; Wed, 17 Mar 2021 17:59:50 +0100 Received: from [85.7.101.30] (helo=pc-9.home) by sslproxy03.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lMZWQ-000HRk-Fg; Wed, 17 Mar 2021 17:59:50 +0100 Subject: Re: [PATCH bpf-next v2] bpf: net: emit anonymous enum with BPF_TCP_CLOSE value explicitly To: Alexei Starovoitov , Yonghong Song Cc: bpf , Alexei Starovoitov , Kernel Team , Andrii Nakryiko References: <20210317042906.1011232-1-yhs@fb.com> <58a10cec-180b-d8d5-e1d3-de9b695a8878@fb.com> From: Daniel Borkmann Message-ID: Date: Wed, 17 Mar 2021 17:59:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.4/26111/Wed Mar 17 12:08:39 2021) Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 3/17/21 5:45 PM, Alexei Starovoitov wrote: > On Tue, Mar 16, 2021 at 10:58 PM Yonghong Song wrote: >> On 3/16/21 10:44 PM, Alexei Starovoitov wrote: >>> On Tue, Mar 16, 2021 at 9:29 PM Yonghong Song wrote: >>>> + BTF_TYPE_EMIT_ENUM(BPF_TCP_ESTABLISHED); >>>> + >>>> + return 0; >>>> +} >>>> +late_initcall(bpf_emit_btf_type); >>> >>> I think if we burn a dummy function on this it would be a wrong >>> pattern to follow. >> >> Maybe we can pick another initcall to piggyback? >> >>> This is just a nop C statement. >>> Typically we add BUILD_BUG_ON near the places that rely on that constraint. >>> There is such a function already. It's tcp_set_state() as you pointed out. >>> It's not using BTF of course, but I would move above BTF_TYPE_EMIT_ENUM there. >>> I'm not sure why you're calling it "pollute net/ipv4/tcp.c". >> >> This is the minor reason. I first coded in that place and feel awkward >> where we have macro referenced above and we still emit a BTF_TYPE_EMIT >> below although with some comments. >> >> The major reason is I think we may have some uapi type/enum's (e.g., in >> uapi/linux/bpf.h) which will be used in bpf program but not in kernel >> itself. So we cannot generate types in vmlinux btf because of this. So I >> used this case to find a place to generate these btf types. >> BPF_TCP_CLOSE is actually such an example, it happens we have a >> BUILD_BUG_ON in kernel to access it. >> Maybe I am too forward looking? > > It's great to be forward looking :) > I'm just having a hard time justifying an empty function with single 'ret' insn > that actually will be called at init time and it will stay empty like this for > foreseeable future. Static analysis tools and whatnot will start sending > patches to remove that empty function. +1, even empty function exported as symbol for modules (to avoid compiler optimization) might be better than initcall, imho.