Skip to content

Commit f6fede8

Browse files
lmbAlexei Starovoitov
authored andcommitted
bpf: sockmap: Don't attach programs to UDP sockets
The stream parser infrastructure isn't set up to deal with UDP sockets, so we mustn't try to attach programs to them. I remember making this change at some point, but I must have lost it while rebasing or something similar. Fixes: 7b98cd4 ("bpf: sockmap: Add UDP support") Signed-off-by: Lorenz Bauer <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Jakub Sitnicki <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 2c7269b commit f6fede8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

net/core/sock_map.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,7 @@ static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next)
424424
return 0;
425425
}
426426

427-
static bool sock_map_redirect_allowed(const struct sock *sk)
428-
{
429-
return sk->sk_state != TCP_LISTEN;
430-
}
427+
static bool sock_map_redirect_allowed(const struct sock *sk);
431428

432429
static int sock_map_update_common(struct bpf_map *map, u32 idx,
433430
struct sock *sk, u64 flags)
@@ -508,6 +505,11 @@ static bool sk_is_udp(const struct sock *sk)
508505
sk->sk_protocol == IPPROTO_UDP;
509506
}
510507

508+
static bool sock_map_redirect_allowed(const struct sock *sk)
509+
{
510+
return sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN;
511+
}
512+
511513
static bool sock_map_sk_is_suitable(const struct sock *sk)
512514
{
513515
return sk_is_tcp(sk) || sk_is_udp(sk);

0 commit comments

Comments
 (0)