diff options
author | Lorenz Bauer <lmb@cloudflare.com> | 2020-06-11 19:25:20 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-06-13 00:13:43 +0200 |
commit | f6fede8569689dd31e7b0ed15024b25e5ce2e2e5 (patch) | |
tree | 05dd70a403a2cb4187a111008b6050126fda0acb /net | |
parent | bpf: tcp: Recv() should return 0 when the peer socket is closed (diff) | |
download | linux-f6fede8569689dd31e7b0ed15024b25e5ce2e2e5.tar.xz linux-f6fede8569689dd31e7b0ed15024b25e5ce2e2e5.zip |
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: 7b98cd42b049 ("bpf: sockmap: Add UDP support")
Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20200611172520.327602-1-lmb@cloudflare.com
Diffstat (limited to 'net')
-rw-r--r-- | net/core/sock_map.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/net/core/sock_map.c b/net/core/sock_map.c index 17a40a947546..a2dc64de5213 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -424,10 +424,7 @@ static int sock_map_get_next_key(struct bpf_map *map, void *key, void *next) return 0; } -static bool sock_map_redirect_allowed(const struct sock *sk) -{ - return sk->sk_state != TCP_LISTEN; -} +static bool sock_map_redirect_allowed(const struct sock *sk); static int sock_map_update_common(struct bpf_map *map, u32 idx, struct sock *sk, u64 flags) @@ -508,6 +505,11 @@ static bool sk_is_udp(const struct sock *sk) 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) { return sk_is_tcp(sk) || sk_is_udp(sk); |