Skip to content

Commit

Permalink
sock_map: Update sock type checks for UDP
Browse files Browse the repository at this point in the history
Now UDP supports sockmap and redirection, we can safely update
the sock type checks for it accordingly.

Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20210331023237.41094-15-xiyou.wangcong@gmail.com
  • Loading branch information
Cong Wang authored and Alexei Starovoitov committed Apr 1, 2021
1 parent 1f5be6b commit 122e6c7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/core/sock_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 122e6c7

Please sign in to comment.