From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754554AbdA3VQr convert rfc822-to-8bit (ORCPT ); Mon, 30 Jan 2017 16:16:47 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:44736 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754535AbdA3VQp (ORCPT ); Mon, 30 Jan 2017 16:16:45 -0500 X-Originating-IP: 209.85.220.177 MIME-Version: 1.0 In-Reply-To: <20170130202813.GG4546@kernel.org> References: <20170126212001.14103-1-joe@ovn.org> <20170126212001.14103-2-joe@ovn.org> <20170130202506.GF4546@kernel.org> <20170130202813.GG4546@kernel.org> From: Joe Stringer Date: Mon, 30 Jan 2017 13:16:18 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv3 perf/core 1/6] tools lib bpf: Add BPF program pinning APIs. To: Arnaldo Carvalho de Melo Cc: Wang Nan , ast@fb.com, Daniel Borkmann , LKML , netdev Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30 January 2017 at 12:28, Arnaldo Carvalho de Melo wrote: > Em Mon, Jan 30, 2017 at 05:25:06PM -0300, Arnaldo Carvalho de Melo escreveu: >> Em Thu, Jan 26, 2017 at 01:19:56PM -0800, Joe Stringer escreveu: >> > Add new APIs to pin a BPF program (or specific instances) to the filesystem. >> > The user can specify the path full path within a BPF filesystem to pin the >> > program. >> > >> > bpf_program__pin_instance(prog, path, n) will pin the nth instance of >> > 'prog' to the specified path. >> > bpf_program__pin(prog, path) will create the directory 'path' (if it >> > does not exist) and pin each instance within that directory. For >> > instance, path/0, path/1, path/2. >> > >> > Signed-off-by: Joe Stringer >> >> make: Entering directory '/home/acme/git/linux/tools/perf' >> BUILD: Doing 'make -j4' parallel build >> CC /tmp/build/perf/builtin-record.o >> CC /tmp/build/perf/libbpf.o >> CC /tmp/build/perf/util/parse-events.o >> INSTALL trace_plugins >> libbpf.c: In function ‘make_dir’: >> libbpf.c:1303:6: error: implicit declaration of function ‘mkdir’ [-Werror=implicit-function-declaration] >> if (mkdir(path, 0700) && errno != EEXIST) >> ^~~~~ >> libbpf.c:1303:2: error: nested extern declaration of ‘mkdir’ [-Werror=nested-externs] >> if (mkdir(path, 0700) && errno != EEXIST) >> ^~ >> cc1: all warnings being treated as errors >> mv: cannot stat '/tmp/build/perf/.libbpf.o.tmp': No such file or directory >> /home/acme/git/linux/tools/build/Makefile.build:101: recipe for target '/tmp/build/perf/libbpf.o' failed Not sure why but I didn't see this. Appreciate the fix. >> >> >> And strdup() is not checked for failure, I'm fixing those, >> >> +++ b/tools/lib/bpf/libbpf.c >> @@ -36,6 +36,8 @@ >> #include >> #include >> #include >> +#include >> +#include >> #include > > This as well: > > @@ -1338,7 +1343,7 @@ int bpf_program__pin(struct bpf_program *prog, > const char *path) > len = snprintf(buf, PATH_MAX, "%s/%d", path, i); > if (len < 0) > return -EINVAL; > - else if (len > PATH_MAX) > + else if (len >= PATH_MAX) > return -ENAMETOOLONG; > > > See 'man snprintf', return value: > > --- > Thus, a return value of size or more means that the output was > truncated. > --- Good spotting, I looked over the committed versions and tested them, they seem good to me. Thanks!