From: Yafang Shao <laoar.shao@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
kafai@fb.com, songliubraving@fb.com, yhs@fb.com,
john.fastabend@gmail.com, kpsingh@kernel.org
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH RFC 3/3] bpf: set attached sockmap id in attach_name
Date: Fri, 18 Feb 2022 09:56:12 +0000 [thread overview]
Message-ID: <20220218095612.52082-4-laoar.shao@gmail.com> (raw)
In-Reply-To: <20220218095612.52082-1-laoar.shao@gmail.com>
Set the attached name when a bpf prog is attached to a sockmap, and
unset it when the bpf prog is detached.
Below is the result after this change,
$ cat progs.debug
id name attached
5 dump_bpf_map bpf_iter_bpf_map
7 dump_bpf_prog bpf_iter_bpf_prog
17 bpf_sockmap cgroup:/
19 bpf_redir_proxy sockmap:9
$ cat maps.debug
id name max_entries
3 iterator.rodata 1
9 ltcp_map 65535
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
net/core/sock_map.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index f39ef79ced67..ce8d0bbba6cc 100644
--- a/net/core/sock_map.c
+++ b/net/core/sock_map.c
@@ -1411,6 +1411,7 @@ static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,
{
struct sk_psock_progs *progs = sock_map_progs(map);
struct bpf_prog **pprog;
+ char sockmap_info[16];
if (!progs)
return -EOPNOTSUPP;
@@ -1438,8 +1439,13 @@ static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,
return -EOPNOTSUPP;
}
- if (old)
+ if (old) {
+ kfree(prog->aux->attach_name);
return psock_replace_prog(pprog, prog, old);
+ }
+
+ snprintf(sockmap_info, 16, "sockmap:%d", map->id);
+ prog->aux->attach_name = kstrdup(sockmap_info, GFP_KERNEL);
psock_set_prog(pprog, prog);
return 0;
--
2.17.1
prev parent reply other threads:[~2022-02-18 9:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-18 9:56 [PATCH RFC 0/3] bpf: show attached name for progs without btf name Yafang Shao
2022-02-18 9:56 ` [PATCH RFC 1/3] bpf: rename attach_func_name to attach_name Yafang Shao
2022-02-18 9:56 ` [PATCH RFC 2/3] bpf: set attached cgroup name in attach_name Yafang Shao
2022-02-19 18:27 ` Alexei Starovoitov
2022-02-20 14:17 ` Yafang Shao
2022-02-20 20:59 ` Alexei Starovoitov
2022-02-21 2:33 ` Yafang Shao
2022-02-21 14:26 ` Yafang Shao
2022-02-22 4:30 ` Alexei Starovoitov
2022-02-22 8:34 ` Yafang Shao
2022-02-18 9:56 ` Yafang Shao [this message]
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=20220218095612.52082-4-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--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).