bpf: sockmap: Don't attach programs to UDP sockets
[linux-2.6-microblaze.git] / net / core / sock_map.c
index 17a40a9..a2dc64d 100644 (file)
@@ -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);