This function does not need a mutable reference to its argument. Signed-off-by: Daniel Zahka --- include/net/psp/functions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/psp/functions.h b/include/net/psp/functions.h index 91ba06733321..fb3cbe8427ea 100644 --- a/include/net/psp/functions.h +++ b/include/net/psp/functions.h @@ -124,7 +124,7 @@ psp_twsk_rx_policy_check(struct inet_timewait_sock *tw, struct sk_buff *skb) return __psp_sk_rx_policy_check(skb, rcu_dereference(tw->psp_assoc)); } -static inline struct psp_assoc *psp_sk_get_assoc_rcu(struct sock *sk) +static inline struct psp_assoc *psp_sk_get_assoc_rcu(const struct sock *sk) { struct inet_timewait_sock *tw; struct psp_assoc *pas; -- 2.47.3 It is weird to cast to a timewait_sock before checking sk_state, even if the use is after such a check. Remove the tw local variable, and use inet_twsk() directly in the timewait branch. Signed-off-by: Daniel Zahka --- include/net/psp/functions.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/net/psp/functions.h b/include/net/psp/functions.h index fb3cbe8427ea..980de7e58f8a 100644 --- a/include/net/psp/functions.h +++ b/include/net/psp/functions.h @@ -126,7 +126,6 @@ psp_twsk_rx_policy_check(struct inet_timewait_sock *tw, struct sk_buff *skb) static inline struct psp_assoc *psp_sk_get_assoc_rcu(const struct sock *sk) { - struct inet_timewait_sock *tw; struct psp_assoc *pas; int state; @@ -134,9 +133,9 @@ static inline struct psp_assoc *psp_sk_get_assoc_rcu(const struct sock *sk) if (!sk_is_inet(sk) || state & TCPF_NEW_SYN_RECV) return NULL; - tw = inet_twsk(sk); - pas = state & TCPF_TIME_WAIT ? rcu_dereference(tw->psp_assoc) : - rcu_dereference(sk->psp_assoc); + pas = state & TCPF_TIME_WAIT ? + rcu_dereference(inet_twsk(sk)->psp_assoc) : + rcu_dereference(sk->psp_assoc); return pas; } -- 2.47.3 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 --- include/net/psp/functions.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/net/psp/functions.h b/include/net/psp/functions.h index 980de7e58f8a..ef7743664da3 100644 --- a/include/net/psp/functions.h +++ b/include/net/psp/functions.h @@ -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; -- 2.47.3