lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <007b01d356c5$09575220$1c05f660$@lab.ntt.co.jp>
Date:   Mon, 6 Nov 2017 15:03:58 +0900
From:   "Prashant Bhole" <bhole_prashant_q7@....ntt.co.jp>
To:     "'Quentin Monnet'" <quentin.monnet@...ronome.com>
Cc:     <netdev@...r.kernel.org>, "'Alexei Starovoitov'" <ast@...nel.org>,
        "'Daniel Borkmann'" <daniel@...earbox.net>,
        "'Jakub Kicinski'" <jakub.kicinski@...ronome.com>,
        "'David S . Miller'" <davem@...emloft.net>
Subject: RE: [PATCH net-next V2 2/3] tools: bpftool: show filenames of pinned objects



> From: Quentin Monnet [mailto:quentin.monnet@...ronome.com]
> 
> 2017-11-02 16:59 UTC+0900 ~ Prashant Bhole
> <bhole_prashant_q7@....ntt.co.jp>
> > Added support to show filenames of pinned objects.
> >
> > For example:
> >
> 
> […]
> 
> >
> > Signed-off-by: Prashant Bhole <bhole_prashant_q7@....ntt.co.jp>
> > ---
> > v2:
> >  - Dynamically identify bpf-fs moutpoint
> >  - Close files descriptors before returning on error
> >  - Fixed line break for proper output formatting
> >  - Code style: wrapped lines > 80, used reverse christmastree style
> 
> Thanks for those changes!
> 
> >
> >  tools/bpf/bpftool/common.c | 93
> ++++++++++++++++++++++++++++++++++++++++++++++
> >  tools/bpf/bpftool/main.c   |  8 ++++
> >  tools/bpf/bpftool/main.h   | 17 +++++++++
> >  tools/bpf/bpftool/map.c    | 21 +++++++++++
> >  tools/bpf/bpftool/prog.c   | 24 ++++++++++++
> >  5 files changed, 163 insertions(+)
> >
> > diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
> > index 4556947709ee..78a16c02c778 100644
> > --- a/tools/bpf/bpftool/common.c
> > +++ b/tools/bpf/bpftool/common.c
> > @@ -45,6 +45,8 @@
> >  #include <sys/mount.h>
> >  #include <sys/types.h>
> >  #include <sys/vfs.h>
> > +#include <mntent.h>
> > +#include <fts.h>
> >
> >  #include <bpf.h>
> >
> > @@ -290,3 +292,94 @@ void print_hex_data_json(uint8_t *data, size_t len)
> >  		jsonw_printf(json_wtr, "\"0x%02hhx\"", data[i]);
> >  	jsonw_end_array(json_wtr);
> >  }
> > +
> > +int build_pinned_obj_table(struct pinned_obj_table *tab,
> > +			   enum bpf_obj_type type)
> > +{
> > +	struct bpf_prog_info pinned_info = {};
> > +	__u32 len = sizeof(pinned_info);
> > +	struct pinned_obj *obj_node = NULL;
> > +	enum bpf_obj_type objtype;
> > +	struct mntent *mntent = NULL;
> > +	FILE *mntfile = NULL;
> > +	char *bpf_dir = NULL;
> > +	FTSENT *ftse = NULL;
> > +	FTS *ftsp = NULL;
> > +	int fd, err;
> > +
> > +	mntfile = setmntent("/proc/mounts", "r");
> > +	if (!mntfile)
> > +		return -1;
> > +
> > +	while ((mntent = getmntent(mntfile)) != NULL) {
> > +		if (strncmp(mntent->mnt_type, "bpf", 3) == 0) {
> > +			bpf_dir = mntent->mnt_dir;
> > +			break;
> 
> It works well to find a bpf virtual file system, but it stops after the first one it
> finds, although it is possible to have several bpffs on the system. Since you
> already have all the logics, could you move the
> fts_read() step inside this loop, so as to browse all existing bpffs instead of just
> the first one?
> 

Thanks. Sending V3 soon with this change and other coding style fixes.

Prashant


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ