netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Andrii Nakryiko <andriin@fb.com>, Jiri Olsa <jolsa@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	Yonghong Song <yhs@fb.com>, Martin Lau <kafai@fb.com>,
	"andrii.nakryiko@gmail.com" <andrii.nakryiko@gmail.com>
Subject: Re: [PATCHv2] bpftool: Try to read btf as raw data if elf read fails
Date: Fri, 25 Oct 2019 18:32:28 +0200	[thread overview]
Message-ID: <20191025163228.GB10170@krava> (raw)
In-Reply-To: <20191025093116.67756660@cakuba.hsd1.ca.comcast.net>

On Fri, Oct 25, 2019 at 09:31:16AM -0700, Jakub Kicinski wrote:
> On Fri, 25 Oct 2019 05:01:17 +0000, Andrii Nakryiko wrote:
> > >> +static bool is_btf_raw(const char *file)
> > >> +{
> > >> +	__u16 magic = 0;
> > >> +	int fd;
> > >> +
> > >> +	fd = open(file, O_RDONLY);
> > >> +	if (fd < 0)
> > >> +		return false;
> > >> +
> > >> +	read(fd, &magic, sizeof(magic));
> > >> +	close(fd);
> > >> +	return magic == BTF_MAGIC;  
> > > 
> > > Isn't it suspicious to read() 2 bytes into an u16 and compare to a
> > > constant like endianness doesn't matter? Quick grep doesn't reveal
> > > BTF_MAGIC being endian-aware..  
> > 
> > Right now we support only loading BTF in native endianness, so I think 
> > this should do. If we ever add ability to load non-native endianness, 
> > then we'll have to adjust this.
> 
> This doesn't do native endianness, this does LE-only. It will not work
> on BE machines.

hum, let me try.. I thought it would

jirka


  reply	other threads:[~2019-10-25 16:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-24 13:23 [PATCHv2] bpftool: Try to read btf as raw data if elf read fails Jiri Olsa
2019-10-24 13:31 ` Jiri Olsa
2019-10-24 17:54 ` Jakub Kicinski
2019-10-25  5:01   ` Andrii Nakryiko
2019-10-25 16:31     ` Jakub Kicinski
2019-10-25 16:32       ` Jiri Olsa [this message]
2019-10-25 16:53       ` Andrii Nakryiko
2019-10-25 17:32         ` 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=20191025163228.GB10170@krava \
    --to=jolsa@redhat.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=yhs@fb.com \
    /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;
as well as URLs for NNTP newsgroup(s).