From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tushar Dave Subject: Re: [RFC v2 PATCH 2/4] ebpf: Add sg_filter_run and sg helper Date: Fri, 29 Jun 2018 17:27:22 -0700 Message-ID: References: <1529431217-5264-1-git-send-email-tushar.n.dave@oracle.com> <1529431217-5264-3-git-send-email-tushar.n.dave@oracle.com> <160bb237-f453-b1cb-0e75-f4ca6d4e6559@iogearbox.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit To: Daniel Borkmann , ast@kernel.org, davem@davemloft.net, jakub.kicinski@netronome.com, quentin.monnet@netronome.com, jiong.wang@netronome.com, guro@fb.com, sandipan@linux.vnet.ibm.com, john.fastabend@gmail.com, kafai@fb.com, rdna@fb.com, brakmo@fb.com, netdev@vger.kernel.org, acme@redhat.com, sowmini.varadhan@oracle.com Return-path: Received: from userp2130.oracle.com ([156.151.31.86]:60480 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752549AbeF3Ame (ORCPT ); Fri, 29 Jun 2018 20:42:34 -0400 In-Reply-To: <160bb237-f453-b1cb-0e75-f4ca6d4e6559@iogearbox.net> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 06/29/2018 01:32 AM, Daniel Borkmann wrote: > On 06/19/2018 08:00 PM, Tushar Dave wrote: > [...] >> +int sg_filter_run(struct sock *sk, struct scatterlist *sg) >> +{ >> + struct sk_filter *filter; >> + int err; >> + >> + rcu_read_lock(); >> + filter = rcu_dereference(sk->sk_filter); >> + if (filter) { >> + struct bpf_scatterlist bpfsg; >> + int num_sg; >> + >> + if (!sg) { >> + err = -EINVAL; >> + goto out; >> + } >> + >> + num_sg = sg_nents(sg); >> + if (num_sg <= 0) { >> + err = -EINVAL; >> + goto out; >> + } >> + >> + /* We store a reference to the sg list so it can later used by >> + * eBPF helpers to retrieve the next sg element. >> + */ >> + bpfsg.num_sg = num_sg; >> + bpfsg.cur_sg = 0; >> + bpfsg.sg = sg; >> + >> + /* For the first sg element, we store the pkt access pointers >> + * into start and end so eBPF program can have pkt access using >> + * data and data_end. The pkt access for subsequent element of >> + * sg list is possible when eBPF program invokes bpf_sg_next >> + * which takes care of setting start and end to the correct sg >> + * element. >> + */ >> + bpfsg.start = sg_virt(sg); >> + bpfsg.end = bpfsg.start + sg->length; >> + BPF_PROG_RUN(filter->prog, &bpfsg); > > Return code here from BPF prog is ignored entirely, I thought you wanted to > use it also for dropping packets? If UAPI would get frozen like this then it's > baked in stone. Yeah, I am going to add return code necessary for pass, drop and forward. I will do that. Thanks. -Tushar > >> + } >> +out: >> + rcu_read_unlock(); >> + >> + return err; >> +} >> +EXPORT_SYMBOL(sg_filter_run); >