public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: netdev@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	jiri@resnulli.us, john.fastabend@gmail.com, kubakici@wp.pl
Subject: Re: [PATCHv3 net-next 05/15] bpf: enable non-core use of the verfier
Date: Thu, 15 Sep 2016 08:52:51 +0100	[thread overview]
Message-ID: <20160915085251.4de090a1@jkicinski-Precision-T1700> (raw)
In-Reply-To: <20160914230549.GB60248@ast-mbp.thefacebook.com>

On Wed, 14 Sep 2016 16:05:51 -0700, Alexei Starovoitov wrote:
> On Wed, Sep 14, 2016 at 08:00:13PM +0100, Jakub Kicinski wrote:
> > Advanced JIT compilers and translators may want to use
> > eBPF verifier as a base for parsers or to perform custom
> > checks and validations.
> > 
> > Add ability for external users to invoke the verifier
> > and provide callbacks to be invoked for every intruction
> > checked.  For now only add most basic callback for
> > per-instruction pre-interpretation checks is added.  More
> > advanced users may also like to have per-instruction post
> > callback and state comparison callback.
> > 
> > Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> > ---
> >  include/linux/bpf_parser.h |  89 ++++++++++++++++++++++++++++++
> >  kernel/bpf/verifier.c      | 134 +++++++++++++++++++++++----------------------
> >  2 files changed, 158 insertions(+), 65 deletions(-)
> >  create mode 100644 include/linux/bpf_parser.h
> > 
> > diff --git a/include/linux/bpf_parser.h b/include/linux/bpf_parser.h
> > new file mode 100644
> > index 000000000000..daa53b204f4d
> > --- /dev/null
> > +++ b/include/linux/bpf_parser.h  
> 
> 'bpf parser' is a bit misleading name, since it can be interpreted
> as parser written in bpf.
> Also the header file containes verifier bits, therefore I think
> the better name would be bpf_verifier.h ?
> 
> > +#define MAX_USED_MAPS 64 /* max number of maps accessed by one eBPF program */
> > +
> > +struct verifier_env;
> > +struct bpf_ext_parser_ops {
> > +	int (*insn_hook)(struct verifier_env *env,
> > +			 int insn_idx, int prev_insn_idx);
> > +};  
> 
> How about calling this bpf_ext_analyzer_ops
> and main entry bpf_analyzer() ?
> I think it will better convey what it's doing.
> 
> > +
> > +/* single container for all structs
> > + * one verifier_env per bpf_check() call
> > + */
> > +struct verifier_env {
> > +	struct bpf_prog *prog;		/* eBPF program being verified */
> > +	struct verifier_stack_elem *head; /* stack of verifier states to be processed */
> > +	int stack_size;			/* number of states to be processed */
> > +	struct verifier_state cur_state; /* current verifier state */
> > +	struct verifier_state_list **explored_states; /* search pruning optimization */
> > +	const struct bpf_ext_parser_ops *pops; /* external parser ops */
> > +	void *ppriv; /* pointer to external parser's private data */  
> 
> a bit hard to review, since move and addition is in one patch.

Agreed, I'll do move+prefix with bpf_ to one patch since they're both
"no functional changes" and additions to a separate one.

> I think ppriv and pops are too obscure names.
> May be analyzer_ops and analyzer_priv ?

I'll rename everything as suggested.
 
> Conceptually looks good.

Thanks!

  reply	other threads:[~2016-09-15  7:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-14 19:00 [PATCHv3 net-next 00/15] BPF hardware offload (cls_bpf for now) Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 01/15] net: cls_bpf: add hardware offload Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 02/15] net: cls_bpf: limit hardware offload by software-only flag Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 03/15] net: cls_bpf: add support for marking filters as hardware-only Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 04/15] bpf: don't (ab)use instructions to store state Jakub Kicinski
2016-09-14 22:58   ` Alexei Starovoitov
2016-09-14 19:00 ` [PATCHv3 net-next 05/15] bpf: enable non-core use of the verfier Jakub Kicinski
2016-09-14 23:05   ` Alexei Starovoitov
2016-09-15  7:52     ` Jakub Kicinski [this message]
2016-09-14 19:00 ` [PATCHv3 net-next 06/15] bpf: prefix structures in bpf_parser.h with bpf_ Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 07/15] bpf: recognize 64bit immediate loads as consts Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 08/15] nfp: add BPF to NFP code translator Jakub Kicinski
2016-09-14 23:15   ` Alexei Starovoitov
2016-09-15  7:53     ` Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 09/15] nfp: bpf: add hardware bpf offload Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 10/15] net: cls_bpf: allow offloaded filters to update stats Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 11/15] net: bpf: " Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 12/15] nfp: bpf: add packet marking support Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 13/15] net: act_mirred: allow statistic updates from offloaded actions Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 14/15] nfp: bpf: add support for legacy redirect action Jakub Kicinski
2016-09-14 19:00 ` [PATCHv3 net-next 15/15] nfp: bpf: add offload of TC direct action mode Jakub Kicinski

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=20160915085251.4de090a1@jkicinski-Precision-T1700 \
    --to=jakub.kicinski@netronome.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jiri@resnulli.us \
    --cc=john.fastabend@gmail.com \
    --cc=kubakici@wp.pl \
    --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