Commit f6fede85 authored by Lorenz Bauer's avatar Lorenz Bauer Committed by Alexei Starovoitov

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: 7b98cd42 ("bpf: sockmap: Add UDP support")
Signed-off-by: default avatarLorenz Bauer <lmb@cloudflare.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20200611172520.327602-1-lmb@cloudflare.com
parent 2c7269b2
...@@ -424,10 +424,7 @@ static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next) ...@@ -424,10 +424,7 @@ static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next)
return 0; return 0;
} }
static bool sock_map_redirect_allowed(const struct sock *sk) static bool sock_map_redirect_allowed(const struct sock *sk);
{
return sk->sk_state != TCP_LISTEN;
}
static int sock_map_update_common(struct bpf_map *map, u32 idx, static int sock_map_update_common(struct bpf_map *map, u32 idx,
struct sock *sk, u64 flags) struct sock *sk, u64 flags)
...@@ -508,6 +505,11 @@ static bool sk_is_udp(const struct sock *sk) ...@@ -508,6 +505,11 @@ static bool sk_is_udp(const struct sock *sk)
sk->sk_protocol == IPPROTO_UDP; sk->sk_protocol == IPPROTO_UDP;
} }
static bool sock_map_redirect_allowed(const struct sock *sk)
{
return sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN;
}
static bool sock_map_sk_is_suitable(const struct sock *sk) static bool sock_map_sk_is_suitable(const struct sock *sk)
{ {
return sk_is_tcp(sk) || sk_is_udp(sk); return sk_is_tcp(sk) || sk_is_udp(sk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment