]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
psp: don't use flags for checking sk_state
authorDaniel Zahka <daniel.zahka@gmail.com>
Thu, 18 Sep 2025 15:52:04 +0000 (08:52 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 20 Sep 2025 00:01:20 +0000 (17:01 -0700)
Using flags to check sk_state only makes sense to check for a subset
of states in parallel e.g. sk_fullsock(). We are not doing that
here. Compare for individual states directly.

Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20250918155205.2197603-4-daniel.zahka@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/psp/functions.h

index 980de7e58f8aed2dab9964a3de2e4fa6e970e870..ef7743664da390fa3d9bc856fb1822e649aa498b 100644 (file)
@@ -129,11 +129,11 @@ static inline struct psp_assoc *psp_sk_get_assoc_rcu(const struct sock *sk)
        struct psp_assoc *pas;
        int state;
 
-       state = 1 << READ_ONCE(sk->sk_state);
-       if (!sk_is_inet(sk) || state & TCPF_NEW_SYN_RECV)
+       state = READ_ONCE(sk->sk_state);
+       if (!sk_is_inet(sk) || state == TCP_NEW_SYN_RECV)
                return NULL;
 
-       pas = state & TCPF_TIME_WAIT ?
+       pas = state == TCP_TIME_WAIT ?
                      rcu_dereference(inet_twsk(sk)->psp_assoc) :
                      rcu_dereference(sk->psp_assoc);
        return pas;