From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f50.google.com ([74.125.83.50]:37880 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751663AbeB0EZa (ORCPT ); Mon, 26 Feb 2018 23:25:30 -0500 Received: by mail-pg0-f50.google.com with SMTP id y26so7081602pgv.4 for ; Mon, 26 Feb 2018 20:25:30 -0800 (PST) Date: Mon, 26 Feb 2018 20:25:27 -0800 From: Alexei Starovoitov To: Jakub Kicinski Cc: daniel@iogearbox.net, netdev@vger.kernel.org, oss-drivers@netronome.com, Jiong Wang Subject: Re: [PATCH bpf-next 3/8] tools: bpftool: detect sub-programs from the eBPF sequence Message-ID: <20180227042525.gbfn3ul4baghipcv@ast-mbp> References: <20180227041254.32442-1-jakub.kicinski@netronome.com> <20180227041254.32442-4-jakub.kicinski@netronome.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180227041254.32442-4-jakub.kicinski@netronome.com> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, Feb 26, 2018 at 08:12:49PM -0800, Jakub Kicinski wrote: > From: Jiong Wang > > This patch detect all sub-programs from the eBPF sequence and keep the > information in the new CFG data structure. > > The detection algorithm is basically the same as the one in verifier except > we need to use insn->off instead of insn->imm to get the pc-relative call > offset. Because verifier has modified insn->off/insn->imm during finishing > the verification. > > Also, we don't need to do some sanity checks as verifier has done them. > > Signed-off-by: Jiong Wang > Acked-by: Jakub Kicinski overall idea looks good to me. One step towards proper decompiler ;) > diff --git a/tools/bpf/bpftool/cfg.c b/tools/bpf/bpftool/cfg.c > new file mode 100644 > index 000000000000..42a0d4c4271c > --- /dev/null > +++ b/tools/bpf/bpftool/cfg.c > @@ -0,0 +1,143 @@ > +/* > + * Copyright (C) 2018 Netronome Systems, Inc. > + * > + * This software is dual licensed under the GNU General License Version 2, > + * June 1991 as shown in the file COPYING in the top-level directory of this > + * source tree or the BSD 2-Clause License provided below. You have the > + * option to license this software under the complete terms of either license. please use SPDX instead.