diff mbox series

[RFC,net-next,15/20] net/smc: enable access of sock flags of inet smc sock

Message ID 1708412505-34470-16-git-send-email-alibuda@linux.alibaba.com (mailing list archive)
State Superseded
Headers show
Series Introduce IPPROTO_SMC | expand

Commit Message

D. Wythe Feb. 20, 2024, 7:01 a.m. UTC
From: "D. Wythe" <alibuda@linux.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@linux.alibaba.com>
---
 net/smc/smc.h | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)
diff mbox series

Patch

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 */