Johannes Thumshirn 99cc08
From: Karsten Graul <kgraul@linux.ibm.com>
Johannes Thumshirn 99cc08
Date: Mon, 23 Jul 2018 13:53:08 +0200
Johannes Thumshirn 99cc08
Subject: net/smc: provide smc mode in smc_diag.c
Johannes Thumshirn 99cc08
Git-commit: c601171d7a60b5b09d7c2fe0579953323a80744e
Johannes Thumshirn 99cc08
Patch-mainline: v4.19-rc1
Johannes Thumshirn 99cc08
References: bsc#1106287, LTC#170892
Johannes Thumshirn 99cc08
Johannes Thumshirn 99cc08
Rename field diag_fallback into diag_mode and set the smc mode of a
Johannes Thumshirn 99cc08
connection explicitly.
Johannes Thumshirn 99cc08
Johannes Thumshirn 99cc08
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Johannes Thumshirn 99cc08
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Johannes Thumshirn 99cc08
Signed-off-by: David S. Miller <davem@davemloft.net>
Johannes Thumshirn 99cc08
Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
Johannes Thumshirn 99cc08
---
Johannes Thumshirn 99cc08
 include/uapi/linux/smc_diag.h | 9 ++++++++-
Johannes Thumshirn 99cc08
 net/smc/smc_diag.c            | 7 ++++++-
Johannes Thumshirn 99cc08
 2 files changed, 14 insertions(+), 2 deletions(-)
Johannes Thumshirn 99cc08
Johannes Thumshirn 99cc08
diff --git a/include/uapi/linux/smc_diag.h b/include/uapi/linux/smc_diag.h
Johannes Thumshirn 99cc08
index 92be255e534c..48ae3ee22b2d 100644
Johannes Thumshirn 99cc08
--- a/include/uapi/linux/smc_diag.h
Johannes Thumshirn 99cc08
+++ b/include/uapi/linux/smc_diag.h
Johannes Thumshirn 99cc08
@@ -20,7 +20,7 @@ struct smc_diag_req {
Johannes Thumshirn 99cc08
 struct smc_diag_msg {
Johannes Thumshirn 99cc08
 	__u8	diag_family;
Johannes Thumshirn 99cc08
 	__u8	diag_state;
Johannes Thumshirn 99cc08
-	__u8	diag_fallback;
Johannes Thumshirn 99cc08
+	__u8	diag_mode;
Johannes Thumshirn 99cc08
 	__u8	diag_shutdown;
Johannes Thumshirn 99cc08
 	struct inet_diag_sockid id;
Johannes Thumshirn 99cc08
 
Johannes Thumshirn 99cc08
@@ -28,6 +28,13 @@ struct smc_diag_msg {
Johannes Thumshirn 99cc08
 	__u64	diag_inode;
Johannes Thumshirn 99cc08
 };
Johannes Thumshirn 99cc08
 
Johannes Thumshirn 99cc08
+/* Mode of a connection */
Johannes Thumshirn 99cc08
+enum {
Johannes Thumshirn 99cc08
+	SMC_DIAG_MODE_SMCR,
Johannes Thumshirn 99cc08
+	SMC_DIAG_MODE_FALLBACK_TCP,
Johannes Thumshirn 99cc08
+	SMC_DIAG_MODE_SMCD,
Johannes Thumshirn 99cc08
+};
Johannes Thumshirn 99cc08
+
Johannes Thumshirn 99cc08
 /* Extensions */
Johannes Thumshirn 99cc08
 
Johannes Thumshirn 99cc08
 enum {
Johannes Thumshirn 99cc08
diff --git a/net/smc/smc_diag.c b/net/smc/smc_diag.c
Johannes Thumshirn 99cc08
index 6d83eef1b743..d772cd10297e 100644
Johannes Thumshirn 99cc08
--- a/net/smc/smc_diag.c
Johannes Thumshirn 99cc08
+++ b/net/smc/smc_diag.c
Johannes Thumshirn 99cc08
@@ -91,7 +91,12 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb,
Johannes Thumshirn 99cc08
 	r = nlmsg_data(nlh);
Johannes Thumshirn 99cc08
 	smc_diag_msg_common_fill(r, sk);
Johannes Thumshirn 99cc08
 	r->diag_state = sk->sk_state;
Johannes Thumshirn 99cc08
-	r->diag_fallback = smc->use_fallback;
Johannes Thumshirn 99cc08
+	if (smc->use_fallback)
Johannes Thumshirn 99cc08
+		r->diag_mode = SMC_DIAG_MODE_FALLBACK_TCP;
Johannes Thumshirn 99cc08
+	else if (smc->conn.lgr && smc->conn.lgr->is_smcd)
Johannes Thumshirn 99cc08
+		r->diag_mode = SMC_DIAG_MODE_SMCD;
Johannes Thumshirn 99cc08
+	else
Johannes Thumshirn 99cc08
+		r->diag_mode = SMC_DIAG_MODE_SMCR;
Johannes Thumshirn 99cc08
 	user_ns = sk_user_ns(NETLINK_CB(cb->skb).sk);
Johannes Thumshirn 99cc08
 	if (smc_diag_msg_attrs_fill(sk, skb, r, user_ns))
Johannes Thumshirn 99cc08
 		goto errout;
Johannes Thumshirn 99cc08