From: Daniel Borkmann <daniel@iogearbox.net>
To: Rumen Telbizov <rumen.telbizov@menlosecurity.com>,
David Ahern <dsahern@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: bpf_fib_lookup support for firewall mark
Date: Thu, 10 Jun 2021 00:08:50 +0200 [thread overview]
Message-ID: <c2f77a3d-508f-236c-057c-6233fbc7e5d2@iogearbox.net> (raw)
In-Reply-To: <CA+FoirALjdwJ0=F6E4w2oNmC+fRkpwHx8AZb7mW1D=nU4_qZUQ@mail.gmail.com>
Hi Rumen, hi David,
(please avoid top-posting)
On 6/9/21 11:56 PM, Rumen Telbizov wrote:
> List,
>
> For what it's worth I patched the structure locally by introducing a
> new __u32 mark field
> to the structure and adding the proper assignment of the field in
> filter.c. Recompiled without any issues.
> With that patch a bpf lookup matches ip rule that contains fwmark.
>
> Still interested to know how much of a performance penalty adding an 4
> bytes to the
> structure brings. I'd certainly vote for adding at least the firewall
> mark to the set of fields used in the lookup.
I agree with David here that performance of the helper is paramount.
As a side-note, we should probably add a build_bug_on() to ensure that
the size of struct bpf_fib_lookup will stay at 64b / one cacheline.
That said, given h_vlan_proto/h_vlan_TCI are both output parameters,
maybe we could just union the two fields with a __u32 mark extension
that we then transfer into the flowi{4,6}?
Thanks,
Daniel
> On Wed, Jun 9, 2021 at 11:30 AM Rumen Telbizov
> <rumen.telbizov@menlosecurity.com> wrote:
>>
>> Hi David,
>>
>> Thanks for the quick response. I appreciate it.
>> A couple of quick follow up questions:
>> 1. Do you have any performance data that would indicate how much of a
>> performance drop adding an extra 4 or 8 bytes to the structure would
>> cause?
>> 2. If I patch locally the structure in libc and the kernel by adding
>> an extra _u32 mark member is there anything that such a modification
>> would break?
>>
>> Regards,
>> Rumen Telbizov
>>
>>
>> On Tue, Jun 8, 2021 at 6:21 PM David Ahern <dsahern@gmail.com> wrote:
>>>
>>> On 6/8/21 4:59 PM, Rumen Telbizov wrote:
>>>> Dear BPF list,
>>>>
>>>> I am new to eBPF so go easy on me.
>>>> It seems to me that currently eBPF has no support for route table
>>>> lookups including firewall marks. The bpf_fib_lookup structure itself
>>>> has no mark field as per
>>>> https://elixir.bootlin.com/linux/v5.10.28/source/include/uapi/linux/bpf.h#L4864
>>>>
>>>> Additionally bpf_fib_lookup() function does not incorporate the
>>>> firewall mark in its route lookup. It explicitly sets it to 0 as per
>>>> https://elixir.bootlin.com/linux/v5.10.28/source/net/core/filter.c#L5329
>>>> along with other fields which are used during the regular routing
>>>> policy database lookup.
>>>>
>>>> Thus lookups from within eBPF and outside of it result in different
>>>> outcomes if there are rules directing traffic based on fwmark.
>>>> Can you please advise what the rationale for this is or if there
>>>> anything that I might be missing.
>>>>
>>>> Let me know if I can provide any further information.
>>>>
>>>
>>> The API (struct bpf_fib_lookup) is constrained to 64B for performance.
>>> It is not possible to support all of the policy routing options that
>>> Linux has in 64B. Choices had to be made.
next prev parent reply other threads:[~2021-06-09 22:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-08 22:59 bpf_fib_lookup support for firewall mark Rumen Telbizov
2021-06-09 1:21 ` David Ahern
2021-06-09 18:30 ` Rumen Telbizov
2021-06-09 21:56 ` Rumen Telbizov
2021-06-09 22:08 ` Daniel Borkmann [this message]
2021-06-10 14:37 ` David Ahern
2021-06-10 17:41 ` Rumen Telbizov
2021-06-10 18:52 ` David Ahern
2021-06-10 20:58 ` Daniel Borkmann
2021-06-11 1:41 ` David Ahern
2021-06-11 17:32 ` Rumen Telbizov
[not found] ` <CA+FoirA-eAfux3PfxjgyO=--7duWCKuyeJfxWTdW6jiMWzShTw@mail.gmail.com>
2021-06-12 0:00 ` Rumen Telbizov
2021-06-12 1:13 ` David Ahern
2021-06-14 16:53 ` Rumen Telbizov
2021-06-29 17:18 ` Rumen Telbizov
2021-06-29 17:21 ` Greg KH
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=c2f77a3d-508f-236c-057c-6233fbc7e5d2@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=bpf@vger.kernel.org \
--cc=dsahern@gmail.com \
--cc=rumen.telbizov@menlosecurity.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).