All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Zvi Effron <zeffron@riotgames.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	Cody Haas <chaas@riotgames.com>,
	Lisa Watanabe <lwatanabe@riotgames.com>
Subject: Re: [PATCH bpf-next v2 3/3] selftests/bpf: Add test for xdp_md context in BPF_PROG_TEST_RUN
Date: Thu, 27 May 2021 20:21:51 -0700	[thread overview]
Message-ID: <CAEf4BzZ-DdZk2rnzc40aoepJn=zS1o=-mdW15uz5Cm4Vi6rH5Q@mail.gmail.com> (raw)
In-Reply-To: <CAC1LvL1JM4Wu43XU4aVHHheChtSQQmKRx7RaVBG5Kmkt-edbBA@mail.gmail.com>

On Thu, May 27, 2021 at 7:11 PM Zvi Effron <zeffron@riotgames.com> wrote:
>
> On Thu, May 27, 2021 at 6:28 PM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
> >
> > On Thu, May 27, 2021 at 1:14 PM Zvi Effron <zeffron@riotgames.com> wrote:
> > >
> > > +
> > > +       /* Data past the end of the kernel's struct xdp_md must be 0 */
> > > +       bad_ctx[sizeof(bad_ctx) - 1] = 1;
> > > +       tattr.ctx_in = bad_ctx;
> > > +       tattr.ctx_size_in = sizeof(bad_ctx);
> > > +       err = bpf_prog_test_run_opts(prog_fd, &tattr);
> > > +       ASSERT_ERR(err, "bpf_prog_test_run(test2)");
> > > +       ASSERT_EQ(errno, 22, "test2-errno");
> >
> > by the time you are checking errno it might get overwritten. If you
> > want to check errno, you have to remember it right after the function
> > returns
>
> Is it sufficient to simply make the errno ASSERT the first thing after
> the function returns? Or would we still need to preserve it into a
> local variable?

Yes, doing ASSERT_EQ(errno, 22, "test2-errno") right after
bpf_prog_test_run_opts() will work reliably.

  reply	other threads:[~2021-05-28  3:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-27 20:13 [PATCH bpf-next v2 0/3] bpf: support input xdp_md context in BPF_PROG_TEST_RUN Zvi Effron
2021-05-27 20:13 ` [PATCH bpf-next v2 1/3] " Zvi Effron
2021-05-28  9:30   ` Maciej Fijalkowski
2021-05-28 18:40     ` Zvi Effron
2021-05-27 20:13 ` [PATCH bpf-next v2 2/3] bpf: support specifying ingress via " Zvi Effron
2021-05-27 20:13 ` [PATCH bpf-next v2 3/3] selftests/bpf: Add test for " Zvi Effron
2021-05-28  1:28   ` Andrii Nakryiko
2021-05-28  2:10     ` Zvi Effron
2021-05-28  3:21       ` Andrii Nakryiko [this message]
2021-05-28 18:35     ` Zvi Effron

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='CAEf4BzZ-DdZk2rnzc40aoepJn=zS1o=-mdW15uz5Cm4Vi6rH5Q@mail.gmail.com' \
    --to=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chaas@riotgames.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=lwatanabe@riotgames.com \
    --cc=zeffron@riotgames.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.