From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from shards.monkeyblade.net ([184.105.139.130]:50072 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751997AbeCOSlt (ORCPT ); Thu, 15 Mar 2018 14:41:49 -0400 Date: Thu, 15 Mar 2018 14:41:47 -0400 (EDT) Message-Id: <20180315.144147.81123006304884551.davem@davemloft.net> To: john.fastabend@gmail.com Cc: ast@kernel.org, daniel@iogearbox.net, davejwatson@fb.com, netdev@vger.kernel.org Subject: Re: [bpf-next PATCH v2 07/18] bpf: sockmap, add msg_cork_bytes() helper From: David Miller In-Reply-To: <20180312192339.8039.54134.stgit@john-Precision-Tower-5810> References: <20180312192034.8039.70022.stgit@john-Precision-Tower-5810> <20180312192339.8039.54134.stgit@john-Precision-Tower-5810> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: From: John Fastabend Date: Mon, 12 Mar 2018 12:23:39 -0700 > In the case where we need a specific number of bytes before a > verdict can be assigned, even if the data spans multiple sendmsg > or sendfile calls. The BPF program may use msg_cork_bytes(). > > The extreme case is a user can call sendmsg repeatedly with > 1-byte msg segments. Obviously, this is bad for performance but > is still valid. If the BPF program needs N bytes to validate > a header it can use msg_cork_bytes to specify N bytes and the > BPF program will not be called again until N bytes have been > accumulated. The infrastructure will attempt to coalesce data > if possible so in many cases (most my use cases at least) the > data will be in a single scatterlist element with data pointers > pointing to start/end of the element. However, this is dependent > on available memory so is not guaranteed. So BPF programs must > validate data pointer ranges, but this is the case anyways to > convince the verifier the accesses are valid. > > Signed-off-by: John Fastabend Acked-by: David S. Miller