From: Cong Wang Date: Wed, 31 Mar 2021 02:32:35 +0000 (-0700) Subject: sock_map: Update sock type checks for UDP X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=122e6c79efe1;p=linux.git sock_map: Update sock type checks for UDP Now UDP supports sockmap and redirection, we can safely update the sock type checks for it accordingly. Signed-off-by: Cong Wang Signed-off-by: Alexei Starovoitov Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/20210331023237.41094-15-xiyou.wangcong@gmail.com --- diff --git a/net/core/sock_map.c b/net/core/sock_map.c index 2915c7c8778bc..3d190d22b0d8b 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -535,7 +535,10 @@ static bool sk_is_udp(const struct sock *sk) static bool sock_map_redirect_allowed(const struct sock *sk) { - return sk_is_tcp(sk) && sk->sk_state != TCP_LISTEN; + if (sk_is_tcp(sk)) + return sk->sk_state != TCP_LISTEN; + else + return sk->sk_state == TCP_ESTABLISHED; } static bool sock_map_sk_is_suitable(const struct sock *sk)