BPF Archive on lore.kernel.org
 help / color / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: "Toke Høiland-Jørgensen" <toke@redhat.com>,
	"David Ahern" <dsahern@gmail.com>,
	ast@fb.com
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next v2] bpf_fib_lookup: optionally skip neighbour lookup
Date: Sun, 11 Oct 2020 22:04:01 +0200
Message-ID: <393e17fc-d187-3a8d-2f0d-a627c7c63fca@iogearbox.net> (raw)
In-Reply-To: <87v9fitcxp.fsf@toke.dk>

On 10/10/20 3:42 PM, Toke Høiland-Jørgensen wrote:
> Daniel Borkmann <daniel@iogearbox.net> writes:
>> On 10/9/20 11:28 PM, David Ahern wrote:
>>> On 10/9/20 11:42 AM, Toke Høiland-Jørgensen wrote:
>>>> David Ahern <dsahern@gmail.com> writes:
>>>>> On 10/9/20 3:13 AM, Toke Høiland-Jørgensen wrote:
>>>>>> The bpf_fib_lookup() helper performs a neighbour lookup for the destination
>>>>>> IP and returns BPF_FIB_LKUP_NO_NEIGH if this fails, with the expectation
>>>>>> that the BPF program will pass the packet up the stack in this case.
>>>>>> However, with the addition of bpf_redirect_neigh() that can be used instead
>>>>>> to perform the neighbour lookup, at the cost of a bit of duplicated work.
>>>>>>
>>>>>> For that we still need the target ifindex, and since bpf_fib_lookup()
>>>>>> already has that at the time it performs the neighbour lookup, there is
>>>>>> really no reason why it can't just return it in any case. So let's just
>>>>>> always return the ifindex, and also add a flag that lets the caller turn
>>>>>> off the neighbour lookup entirely in bpf_fib_lookup().
>>>>>
>>>>> seems really odd to do the fib lookup only to skip the neighbor lookup
>>>>> and defer to a second helper to do a second fib lookup and send out.
>>>>>
>>>>> The better back-to-back calls is to return the ifindex and gateway on
>>>>> successful fib lookup regardless of valid neighbor. If the call to
>>>>> bpf_redirect_neigh is needed, it can have a flag to skip the fib lookup
>>>>> and just redirect to the given nexthop address + ifindex. ie.,
>>>>> bpf_redirect_neigh only does neighbor handling in this case.
>>>>
>>>> Hmm, yeah, I guess it would make sense to cache and reuse the lookup -
>>>> maybe stick it in bpf_redirect_info()? However, given the imminent
>>>
>>> That is not needed.
>>>
>>>> opening of the merge window, I don't see this landing before then. So
>>>> I'm going to respin this patch with just the original change to always
>>>> return the ifindex, then we can revisit the flags/reuse of the fib
>>>> lookup later.
>>>
>>> What I am suggesting is a change in API to bpf_redirect_neigh which
>>> should be done now, before the merge window, before it comes a locked
>>> API. Right now, bpf_redirect_neigh does a lookup to get the nexthop. It
>>> should take the gateway as an input argument. If set, then the lookup is
>>> not done - only the neighbor redirect.
>>
>> Sounds like a reasonable extension, agree. API freeze is not merge win, but
>> final v5.10 tag in this case as it always has been. In case it's not in time,
>> we can simply just move flags to arg3 and add a reserved param as arg2 which
>> must be zero (and thus indicate to perform the lookup as-is). Later we could
>> extend to pass params similar as in fib_lookup helper for the gw.
> 
> Right, I can take a look at this next week. Feel free to merge (v3 of)
> this patch now, that change will be needed in any case I think...

Ok, sounds reasonable, done. Lets fix the remaining one as David suggested until
rc1, at latest rc2 time frame. I'll be mostly offline next week during the day,
but happy to help till that deadline as well.

Thanks,
Daniel

      reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 10:13 Toke Høiland-Jørgensen
2020-10-09 16:17 ` David Ahern
2020-10-09 18:42   ` Toke Høiland-Jørgensen
2020-10-09 21:28     ` David Ahern
2020-10-09 23:05       ` Daniel Borkmann
2020-10-10 13:42         ` Toke Høiland-Jørgensen
2020-10-11 20:04           ` 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=393e17fc-d187-3a8d-2f0d-a627c7c63fca@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.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

BPF Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \
		bpf@vger.kernel.org
	public-inbox-index bpf

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.bpf


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git