From: Cong Wang <[email protected]>

Now UDP supports sockmap and redirection, we can safely update
the sock type checks for it accordingly.

Cc: John Fastabend <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Jakub Sitnicki <[email protected]>
Cc: Lorenz Bauer <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
---
 net/core/sock_map.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/core/sock_map.c b/net/core/sock_map.c
index 2915c7c8778b..3d190d22b0d8 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)
-- 
2.25.1

Reply via email to