From: Yonghong Song <yhs@fb.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
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: Tue, 16 Mar 2021 22:58:03 -0700 [thread overview]
Message-ID: <58a10cec-180b-d8d5-e1d3-de9b695a8878@fb.com> (raw)
In-Reply-To: <CAADnVQLY1ftbZxFqAMSN4amWoYZN0ka3DyVLXAWhgsTO7V9V+Q@mail.gmail.com>
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?
> Consider that BTF_TYPE_EMIT macro is serving similar purpose
> and it's scattered around net/core/filter.c
next prev parent reply other threads:[~2021-03-17 5:59 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 [this message]
2021-03-17 16:45 ` Alexei Starovoitov
2021-03-17 16:58 ` Yonghong Song
2021-03-17 16:59 ` Daniel Borkmann
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=58a10cec-180b-d8d5-e1d3-de9b695a8878@fb.com \
--to=yhs@fb.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@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