bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Yonghong Song <yhs@fb.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Kernel Team <kernel-team@fb.com>,
	Andrii Nakryiko <andrii@kernel.org>
Subject: Re: [PATCH bpf-next v2] bpf: net: emit anonymous enum with BPF_TCP_CLOSE value explicitly
Date: Wed, 17 Mar 2021 17:59:50 +0100	[thread overview]
Message-ID: <c768692d-5a61-df68-a89a-b7ba64b5c188@iogearbox.net> (raw)
In-Reply-To: <CAADnVQ+hUjX-Hk9=9X+=ii1SusfsZJrsxXUn4krH1bUvNjuVRg@mail.gmail.com>

On 3/17/21 5:45 PM, Alexei Starovoitov wrote:
> On Tue, Mar 16, 2021 at 10:58 PM Yonghong Song <yhs@fb.com> wrote:
>> On 3/16/21 10:44 PM, Alexei Starovoitov wrote:
>>> On Tue, Mar 16, 2021 at 9:29 PM Yonghong Song <yhs@fb.com> 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.

      parent reply	other threads:[~2021-03-17 17:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17  4:29 [PATCH bpf-next v2] bpf: net: emit anonymous enum with BPF_TCP_CLOSE value explicitly Yonghong Song
2021-03-17  5:44 ` Alexei Starovoitov
2021-03-17  5:58   ` Yonghong Song
2021-03-17 16:45     ` Alexei Starovoitov
2021-03-17 16:58       ` Yonghong Song
2021-03-17 16:59       ` Daniel Borkmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c768692d-5a61-df68-a89a-b7ba64b5c188@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=kernel-team@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).