From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexei Starovoitov Subject: Re: [PATCH bpf-next v6 03/11] bpf: Add write access to tcp_sock and sock fields Date: Fri, 19 Jan 2018 19:54:45 -0800 Message-ID: <20180120035443.sfm54gmdwfqw734s@ast-mbp> References: <20180120014548.2941040-1-brakmo@fb.com> <20180120014548.2941040-4-brakmo@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: netdev , Kernel Team , Blake Matheny , Alexei Starovoitov , Daniel Borkmann , Eric Dumazet , Neal Cardwell , Yuchung Cheng To: Lawrence Brakmo Return-path: Received: from mail-pf0-f193.google.com ([209.85.192.193]:39202 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750974AbeATDys (ORCPT ); Fri, 19 Jan 2018 22:54:48 -0500 Received: by mail-pf0-f193.google.com with SMTP id e11so2837853pff.6 for ; Fri, 19 Jan 2018 19:54:48 -0800 (PST) Content-Disposition: inline In-Reply-To: <20180120014548.2941040-4-brakmo@fb.com> Sender: netdev-owner@vger.kernel.org List-ID: On Fri, Jan 19, 2018 at 05:45:40PM -0800, Lawrence Brakmo wrote: > This patch adds a macro, SOCK_OPS_SET_FIELD, for writing to > struct tcp_sock or struct sock fields. This required adding a new > field "temp" to struct bpf_sock_ops_kern for temporary storage that > is used by sock_ops_convert_ctx_access. It is used to store and recover > the contents of a register, so the register can be used to store the > address of the sk. Since we cannot overwrite the dst_reg because it > contains the pointer to ctx, nor the src_reg since it contains the value > we want to store, we need an extra register to contain the address > of the sk. > > Also adds the macro SOCK_OPS_GET_OR_SET_FIELD that calls one of the > GET or SET macros depending on the value of the TYPE field. > > Signed-off-by: Lawrence Brakmo Acked-by: Alexei Starovoitov that is really clever way of doing inline writes into fields. I suspect we will be using this approach in other places.