[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220218095612.52082-4-laoar.shao@gmail.com>
Date: Fri, 18 Feb 2022 09:56:12 +0000
From: Yafang Shao <laoar.shao@...il.com>
To: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
kafai@...com, songliubraving@...com, yhs@...com,
john.fastabend@...il.com, kpsingh@...nel.org
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org,
Yafang Shao <laoar.shao@...il.com>
Subject: [PATCH RFC 3/3] bpf: set attached sockmap id in attach_name
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@...il.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
Powered by blists - more mailing lists