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 RFC
Delegated to: Netdev Maintainers
Headers show
Series Introduce IPPROTO_SMC | expand

Checks

Context Check Description
netdev/series_format fail Series longer than 15 patches (and no cover letter)
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 940 this patch: 940
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 957 this patch: 957
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 957 this patch: 957
netdev/checkpatch warning WARNING: line length of 84 exceeds 80 columns WARNING: line length of 86 exceeds 80 columns WARNING: line length of 87 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

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