From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH bpf-next v5 05/11] bpf: Adds field bpf_sock_ops_flags to tcp_sock Date: Tue, 09 Jan 2018 15:30:28 -0800 Message-ID: <1515540628.131759.15.camel@gmail.com> References: <20180109210704.893375-1-brakmo@fb.com> <20180109210704.893375-6-brakmo@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: Kernel Team , Blake Matheny , Alexei Starovoitov , Daniel Borkmann , Neal Cardwell , Yuchung Cheng To: Lawrence Brakmo , netdev Return-path: Received: from mail-pg0-f67.google.com ([74.125.83.67]:46759 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759152AbeAIXaa (ORCPT ); Tue, 9 Jan 2018 18:30:30 -0500 Received: by mail-pg0-f67.google.com with SMTP id r2so9165562pgq.13 for ; Tue, 09 Jan 2018 15:30:30 -0800 (PST) In-Reply-To: <20180109210704.893375-6-brakmo@fb.com> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, 2018-01-09 at 13:06 -0800, Lawrence Brakmo wrote: > Adds field bpf_sock_ops_flags to tcp_sock and bpf_sock_ops. Its primary > use is to determine if there should be calls to sock_ops bpf program at > various points in the TCP code. The field is initialized to zero, > disabling the calls. A sock_ops BPF program can set, per connection and > as necessary, when the connection is established. > > It also adds support for reading and writting the field within a > sock_ops BPF program. > > Examples of where to call the bpf program: > > 1) When RTO fires > 2) When a packet is retransmitted > 3) When the connection terminates > 4) When a packet is sent > 5) When a packet is received > > Signed-off-by: Lawrence Brakmo > --- > include/linux/tcp.h | 8 ++++++++ > include/uapi/linux/bpf.h | 1 + > net/core/filter.c | 7 +++++++ > 3 files changed, 16 insertions(+) > > diff --git a/include/linux/tcp.h b/include/linux/tcp.h > index 4f93f095..62f4388 100644 > --- a/include/linux/tcp.h > +++ b/include/linux/tcp.h > @@ -373,6 +373,14 @@ struct tcp_sock { > */ > struct request_sock *fastopen_rsk; > u32 *saved_syn; > + > +/* Sock_ops bpf program related variables */ > +#ifdef CONFIG_BPF > + u32 bpf_sock_ops_flags; /* values defined in uapi/linux/tcp.h */ > +#define BPF_SOCK_OPS_TEST_FLAG(TP, ARG) (TP->bpf_sock_ops_flags & ARG) > +#else > +#define BPF_SOCK_OPS_TEST_FLAG(TP, ARG) 0 > +#endif > }; > It looks like we add yet another TCP socket field for some feature that is only used by you or FB :/ At least please try to fill a hole (on 64bit kernels), instead of adding one more. Also, should not we reject attempts to use bits that are not yet supported by the kernel ? If a BPF filter expects to be called for every retransmit, but kernel is too old, this wont work.