From: Joe Stringer <joe@wand.net.nz>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Joe Stringer <joe@wand.net.nz>, bpf <bpf@vger.kernel.org>,
netdev <netdev@vger.kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Alexei Starovoitov <ast@kernel.org>,
Eric Dumazet <eric.dumazet@gmail.com>,
Lorenz Bauer <lmb@cloudflare.com>,
Martin KaFai Lau <kafai@fb.com>
Subject: Re: [PATCHv2 bpf-next 2/5] bpf: Prefetch established socket destinations
Date: Thu, 26 Mar 2020 14:45:57 -0700 [thread overview]
Message-ID: <CAOftzPgn_FeDc89O=cbAZRvZ5uyhD-hyN3s4kRdE_0Vqcnzt9g@mail.gmail.com> (raw)
In-Reply-To: <20200326211152.gcpvezl3753wxljv@ast-mbp>
On Thu, Mar 26, 2020 at 2:12 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Tue, Mar 24, 2020 at 10:57:42PM -0700, Joe Stringer wrote:
> > Enhance the sk_assign logic to temporarily store the socket
> > receive destination, to save the route lookup later on. The dst
> > reference is kept alive by the caller's socket reference.
> >
> > Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
> > Signed-off-by: Joe Stringer <joe@wand.net.nz>
> > ---
> > v2: Provide cookie to dst_check() for IPv6 case
> > v1: Initial version
> > ---
> > net/core/filter.c | 15 +++++++++++++++
> > 1 file changed, 15 insertions(+)
> >
> > diff --git a/net/core/filter.c b/net/core/filter.c
> > index f7f9b6631f75..0fada7fe9b75 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
> > @@ -5876,6 +5876,21 @@ BPF_CALL_3(bpf_sk_assign, struct sk_buff *, skb, struct sock *, sk, u64, flags)
> > skb_orphan(skb);
> > skb->sk = sk;
> > skb->destructor = sock_pfree;
> > + if (sk_fullsock(sk)) {
> > + struct dst_entry *dst = READ_ONCE(sk->sk_rx_dst);
> > + u32 cookie = 0;
> > +
> > +#if IS_ENABLED(CONFIG_IPV6)
> > + if (sk->sk_family == AF_INET6)
> > + cookie = inet6_sk(sk)->rx_dst_cookie;
> > +#endif
> > + if (dst)
> > + dst = dst_check(dst, cookie);
> > + if (dst) {
> > + skb_dst_drop(skb);
> > + skb_dst_set_noref(skb, dst);
> > + }
>
> I think the rest of the feedback for the patches can be addressed quickly and
> overall the set is imo ready to land within this cycle. My only concern is
> above dst_set().
> Since it's an optimization may be drop this patch? we can land
> the rest and this one can be introduced in the next cycle?
> I'm happy to be convinced otherwise, but would like a better explanation
> why it's safe to do so in this context.
[resend for lists; somehow gmail introduced some http gunk]
FWIW I found an issue with this implementation over the last day so
your concern is well-warranted. I'd be fine with dropping the
optimization for now and sending it out with other optimizations next
cycle.
Will respin ASAP.
Cheers,
Joe
next prev parent reply other threads:[~2020-03-26 21:46 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 5:57 [PATCHv2 bpf-next 0/5] Add bpf_sk_assign eBPF helper Joe Stringer
2020-03-25 5:57 ` [PATCHv2 bpf-next 1/5] bpf: Add socket assign support Joe Stringer
2020-03-26 6:23 ` Martin KaFai Lau
2020-03-26 6:31 ` Joe Stringer
2020-03-26 10:24 ` Lorenz Bauer
2020-03-26 22:52 ` Joe Stringer
2020-03-27 2:40 ` Joe Stringer
2020-03-25 5:57 ` [PATCHv2 bpf-next 2/5] bpf: Prefetch established socket destinations Joe Stringer
2020-03-26 21:11 ` Alexei Starovoitov
2020-03-26 21:45 ` Joe Stringer [this message]
2020-03-25 5:57 ` [PATCHv2 bpf-next 3/5] net: Track socket refcounts in skb_steal_sock() Joe Stringer
2020-03-25 5:57 ` [PATCHv2 bpf-next 4/5] bpf: Don't refcount LISTEN sockets in sk_assign() Joe Stringer
2020-03-25 10:29 ` Lorenz Bauer
2020-03-25 20:46 ` Joe Stringer
2020-03-26 10:20 ` Lorenz Bauer
2020-03-26 21:37 ` Joe Stringer
2020-03-25 5:57 ` [PATCHv2 bpf-next 5/5] selftests: bpf: add test for sk_assign Joe Stringer
2020-03-25 10:35 ` Lorenz Bauer
2020-03-25 20:55 ` Joe Stringer
2020-03-26 6:25 ` Martin KaFai Lau
2020-03-26 6:38 ` Joe Stringer
2020-03-26 23:39 ` Joe Stringer
2020-03-25 18:17 ` Yonghong Song
2020-03-25 21:20 ` Joe Stringer
2020-03-25 22:00 ` Yonghong Song
2020-03-25 23:07 ` Joe Stringer
2020-03-26 10:13 ` Lorenz Bauer
2020-03-26 21:07 ` call for bpf progs. " Alexei Starovoitov
2020-03-26 23:14 ` Yonghong Song
2020-03-27 10:02 ` Lorenz Bauer
2020-03-27 16:08 ` Alexei Starovoitov
2020-03-27 19:06 ` Joe Stringer
2020-03-27 20:16 ` Daniel Borkmann
2020-03-27 22:24 ` Alexei Starovoitov
2020-03-28 0:17 ` Andrii Nakryiko
2020-03-26 2:04 ` Andrii Nakryiko
2020-03-26 2:16 ` Andrii Nakryiko
2020-03-26 5:28 ` Joe Stringer
2020-03-26 6:31 ` Martin KaFai Lau
2020-03-26 19:36 ` Andrii Nakryiko
2020-03-26 21:38 ` Joe Stringer
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='CAOftzPgn_FeDc89O=cbAZRvZ5uyhD-hyN3s4kRdE_0Vqcnzt9g@mail.gmail.com' \
--to=joe@wand.net.nz \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eric.dumazet@gmail.com \
--cc=kafai@fb.com \
--cc=lmb@cloudflare.com \
--cc=netdev@vger.kernel.org \
/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).