[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1708412505-34470-16-git-send-email-alibuda@linux.alibaba.com>
Date: Tue, 20 Feb 2024 15:01:40 +0800
From: "D. Wythe" <alibuda@...ux.alibaba.com>
To: kgraul@...ux.ibm.com,
wenjia@...ux.ibm.com,
jaka@...ux.ibm.com,
wintera@...ux.ibm.com,
guwen@...ux.alibaba.com
Cc: kuba@...nel.org,
davem@...emloft.net,
netdev@...r.kernel.org,
linux-s390@...r.kernel.org,
linux-rdma@...r.kernel.org,
tonylu@...ux.alibaba.com,
pabeni@...hat.com,
edumazet@...gle.com
Subject: [RFC net-next 15/20] net/smc: enable access of sock flags of inet smc sock
From: "D. Wythe" <alibuda@...ux.alibaba.com>
Since smc_sock and tcp_sock coexist in inet version of smc, the
sock flags field are shared between tcp and smc. Like the sk_state,
we also need a extra sock flags filed for smc in inet version, and
using the icsk field to determine which is the very field needed to
be accessed or changed.
Signed-off-by: D. Wythe <alibuda@...ux.alibaba.com>
---
net/smc/smc.h | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/net/smc/smc.h b/net/smc/smc.h
index e54a30c..1675193 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -252,6 +252,7 @@ struct smc_sock { /* smc sock container */
};
struct socket *clcsock; /* internal tcp socket */
unsigned char smc_state; /* smc state used in smc via inet_sk */
+ unsigned long smc_sk_flags; /* smc sock flags used for inet sock */
void (*clcsk_state_change)(struct sock *sk);
/* original stat_change fct. */
void (*clcsk_data_ready)(struct sock *sk);
@@ -385,10 +386,6 @@ void smc_fill_gid_list(struct smc_link_group *lgr,
int smc_nl_enable_hs_limitation(struct sk_buff *skb, struct genl_info *info);
int smc_nl_disable_hs_limitation(struct sk_buff *skb, struct genl_info *info);
-static inline void smc_sock_set_flag(struct sock *sk, enum sock_flags flag)
-{
- set_bit(flag, &sk->sk_flags);
-}
static __always_inline bool smc_sock_is_inet_sock(const struct sock *sk)
{
@@ -409,6 +406,33 @@ static __always_inline void smc_sk_set_state(struct sock *sk, unsigned char stat
sk->sk_state = state;
}
-#define smc_sock_flag(sk, flag) sock_flag(sk, flag)
+static __always_inline bool smc_sock_flag(const struct sock *sk, enum sock_flags flag)
+{
+ if (smc_sock_is_inet_sock(sk)) {
+ switch (flag) {
+ case SOCK_DEAD:
+ case SOCK_DONE:
+ return test_bit(flag, &smc_sk(sk)->smc_sk_flags);
+ default:
+ break;
+ }
+ }
+ return sock_flag(sk, flag);
+}
+
+static __always_inline void smc_sock_set_flag(struct sock *sk, enum sock_flags flag)
+{
+ if (smc_sock_is_inet_sock(sk)) {
+ switch (flag) {
+ case SOCK_DEAD:
+ case SOCK_DONE:
+ __set_bit(flag, &smc_sk(sk)->smc_sk_flags);
+ return;
+ default:
+ break;
+ }
+ }
+ set_bit(flag, &sk->sk_flags);
+}
#endif /* __SMC_H */
--
1.8.3.1
Powered by blists - more mailing lists