Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Benjamin Herrenschmidt <benh@amazon.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>, bpf <bpf@vger.kernel.org>,
Networking <netdev@vger.kernel.org>
Subject: Re: [PATCH v4 bpf-next 2/3] bpf: Support "%c" in bpf_bprintf_prepare().
Date: Wed, 11 Aug 2021 14:15:50 -0700 [thread overview]
Message-ID: <CAEf4BzZBxA2+nNtbOVEyMXDG9i_3zfxm78=--ssjrX4ESC_ixA@mail.gmail.com> (raw)
In-Reply-To: <20210810092807.13190-3-kuniyu@amazon.co.jp>
On Tue, Aug 10, 2021 at 2:29 AM Kuniyuki Iwashima <kuniyu@amazon.co.jp> wrote:
>
> /proc/net/unix uses "%c" to print a single-byte character to escape '\0' in
> the name of the abstract UNIX domain socket. The following selftest uses
> it, so this patch adds support for "%c". Note that it does not support
> wide character ("%lc" and "%llc") for simplicity.
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
> ---
> kernel/bpf/helpers.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
> index 15746f779fe1..6d3aaf94e9ac 100644
> --- a/kernel/bpf/helpers.c
> +++ b/kernel/bpf/helpers.c
> @@ -907,6 +907,20 @@ int bpf_bprintf_prepare(char *fmt, u32 fmt_size, const u64 *raw_args,
> tmp_buf += err;
> num_spec++;
>
> + continue;
> + } else if (fmt[i] == 'c') {
you are adding new features to printk-like helpers, please add
corresponding tests as well. I'm particularly curious how something
like "% 9c" (which is now allowed, along with a few other unusual
combinations) will work.
> + if (!tmp_buf)
> + goto nocopy_fmt;
> +
> + if (tmp_buf_end == tmp_buf) {
> + err = -ENOSPC;
> + goto out;
> + }
> +
> + *tmp_buf = raw_args[num_spec];
> + tmp_buf++;
> + num_spec++;
> +
> continue;
> }
>
> --
> 2.30.2
>
next prev parent reply other threads:[~2021-08-11 21:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-10 9:28 [PATCH v4 bpf-next 0/3] BPF iterator for UNIX domain socket Kuniyuki Iwashima
2021-08-10 9:28 ` [PATCH v4 bpf-next 1/3] bpf: af_unix: Implement " Kuniyuki Iwashima
2021-08-10 23:25 ` Yonghong Song
2021-08-10 9:28 ` [PATCH v4 bpf-next 2/3] bpf: Support "%c" in bpf_bprintf_prepare() Kuniyuki Iwashima
2021-08-10 23:32 ` Yonghong Song
2021-08-11 21:15 ` Andrii Nakryiko [this message]
2021-08-12 2:15 ` Kuniyuki Iwashima
2021-08-12 4:24 ` Andrii Nakryiko
2021-08-12 5:03 ` Kuniyuki Iwashima
2021-08-10 9:28 ` [PATCH v4 bpf-next 3/3] selftest/bpf: Implement sample UNIX domain socket iterator program Kuniyuki Iwashima
2021-08-10 23:46 ` Yonghong Song
2021-08-11 1:35 ` Kuniyuki Iwashima
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='CAEf4BzZBxA2+nNtbOVEyMXDG9i_3zfxm78=--ssjrX4ESC_ixA@mail.gmail.com' \
--to=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=benh@amazon.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@amazon.co.jp \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
--subject='Re: [PATCH v4 bpf-next 2/3] bpf: Support "%c" in bpf_bprintf_prepare().' \
/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
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).