Skip to content

Commit

Permalink
sock_map: Simplify sock_map_link() a bit
Browse files Browse the repository at this point in the history
sock_map_link() passes down map progs, but it is confusing
to see both map progs and psock progs. Make the map progs
more obvious by retrieving it directly with sock_map_progs()
inside sock_map_link(). Now it is aligned with
sock_map_link_no_progs() too.

Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20210331023237.41094-8-xiyou.wangcong@gmail.com
  • Loading branch information
Cong Wang authored and Alexei Starovoitov committed Apr 1, 2021
1 parent 190179f commit 2004fdb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions net/core/sock_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct bpf_stab {

static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,
struct bpf_prog *old, u32 which);
static struct sk_psock_progs *sock_map_progs(struct bpf_map *map);

static struct bpf_map *sock_map_alloc(union bpf_attr *attr)
{
Expand Down Expand Up @@ -224,10 +225,10 @@ static struct sk_psock *sock_map_psock_get_checked(struct sock *sk)
return psock;
}

static int sock_map_link(struct bpf_map *map, struct sk_psock_progs *progs,
struct sock *sk)
static int sock_map_link(struct bpf_map *map, struct sock *sk)
{
struct bpf_prog *msg_parser, *stream_parser, *stream_verdict;
struct sk_psock_progs *progs = sock_map_progs(map);
struct sk_psock *psock;
int ret;

Expand Down Expand Up @@ -492,7 +493,7 @@ static int sock_map_update_common(struct bpf_map *map, u32 idx,
* and sk_write_space callbacks overridden.
*/
if (sock_map_redirect_allowed(sk))
ret = sock_map_link(map, &stab->progs, sk);
ret = sock_map_link(map, sk);
else
ret = sock_map_link_no_progs(map, sk);
if (ret < 0)
Expand Down Expand Up @@ -1004,7 +1005,7 @@ static int sock_hash_update_common(struct bpf_map *map, void *key,
* and sk_write_space callbacks overridden.
*/
if (sock_map_redirect_allowed(sk))
ret = sock_map_link(map, &htab->progs, sk);
ret = sock_map_link(map, sk);
else
ret = sock_map_link_no_progs(map, sk);
if (ret < 0)
Expand Down

0 comments on commit 2004fdb

Please sign in to comment.