address miscellaneous issues with psp_sk_get_assoc_rcu()
Subsystems (3)
Daniel Zahka
maintainercover address miscellaneous issues with psp_sk_get_assoc_rcu()
There were a few minor issues with psp_sk_get_assoc_rcu() identified by Eric in his review of the initial psp series. This series addresses them.
Daniel Zahka (3):
psp: make struct sock argument const in psp_sk_get_assoc_rcu()
psp: fix preemptive inet_twsk() cast in psp_sk_get_assoc_rcu()
psp: don't use flags for checking sk_state
include/net/psp/functions.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
Signature · 1 line
2.47.3
Daniel Zahka
maintainerPATCH 1/3 psp: make struct sock argument const in psp_sk_get_assoc_rcu()
This function does not need a mutable reference to its argument.
--- include/net/psp/functions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/psp/functions.h +1 -1
@@ -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;
Signature · 1 line
2.47.3
Daniel Zahka
maintainerPATCH 2/3 psp: fix preemptive inet_twsk() cast in psp_sk_get_assoc_rcu()
In reply to Daniel ZahkaIt 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.
--- include/net/psp/functions.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
include/net/psp/functions.h +3 -4
@@ -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; }
Signature · 1 line
2.47.3
Daniel Zahka
maintainerPATCH 3/3 psp: don't use flags for checking sk_state
In reply to Daniel ZahkaUsing 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.
--- include/net/psp/functions.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/net/psp/functions.h +3 -3
@@ -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;
Signature · 1 line
2.47.3
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Thu, 18 Sep 2025 08:52:01 -0700 you wrote:
There were a few minor issues with
psp_sk_get_assoc_rcu()identified by Eric in his review of the initial psp series. This series addresses them.Daniel Zahka (3):
psp: make struct sock argument const inpsp_sk_get_assoc_rcu()
psp: fix preemptiveinet_twsk()cast inpsp_sk_get_assoc_rcu()
psp: don't use flags for checkingsk_state[...]
Here is the summary with links:
- [net-next,1/3] psp: make struct sock argument const in psp_sk_get_assoc_rcu()
https://git.kernel.org/netdev/net-next/c/f8d2f8205be8 - [net-next,2/3] psp: fix preemptive inet_twsk() cast in psp_sk_get_assoc_rcu() https://git.kernel.org/netdev/net-next/c/803cdb6ddca3 - [net-next,3/3] psp: don't use flags for checking sk_state https://git.kernel.org/netdev/net-next/c/28bb24dadd0e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html