Skip to content

Commit 2004fdb

Browse files
Cong WangAlexei Starovoitov
authored andcommitted
sock_map: Simplify sock_map_link() a bit
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 <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: John Fastabend <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 190179f commit 2004fdb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

net/core/sock_map.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct bpf_stab {
2626

2727
static int sock_map_prog_update(struct bpf_map *map, struct bpf_prog *prog,
2828
struct bpf_prog *old, u32 which);
29+
static struct sk_psock_progs *sock_map_progs(struct bpf_map *map);
2930

3031
static struct bpf_map *sock_map_alloc(union bpf_attr *attr)
3132
{
@@ -224,10 +225,10 @@ static struct sk_psock *sock_map_psock_get_checked(struct sock *sk)
224225
return psock;
225226
}
226227

227-
static int sock_map_link(struct bpf_map *map, struct sk_psock_progs *progs,
228-
struct sock *sk)
228+
static int sock_map_link(struct bpf_map *map, struct sock *sk)
229229
{
230230
struct bpf_prog *msg_parser, *stream_parser, *stream_verdict;
231+
struct sk_psock_progs *progs = sock_map_progs(map);
231232
struct sk_psock *psock;
232233
int ret;
233234

@@ -492,7 +493,7 @@ static int sock_map_update_common(struct bpf_map *map, u32 idx,
492493
* and sk_write_space callbacks overridden.
493494
*/
494495
if (sock_map_redirect_allowed(sk))
495-
ret = sock_map_link(map, &stab->progs, sk);
496+
ret = sock_map_link(map, sk);
496497
else
497498
ret = sock_map_link_no_progs(map, sk);
498499
if (ret < 0)
@@ -1004,7 +1005,7 @@ static int sock_hash_update_common(struct bpf_map *map, void *key,
10041005
* and sk_write_space callbacks overridden.
10051006
*/
10061007
if (sock_map_redirect_allowed(sk))
1007-
ret = sock_map_link(map, &htab->progs, sk);
1008+
ret = sock_map_link(map, sk);
10081009
else
10091010
ret = sock_map_link_no_progs(map, sk);
10101011
if (ret < 0)

0 commit comments

Comments
 (0)