public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Ursula Braun <ubraun@linux.ibm.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org,
	schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com,
	raspl@linux.ibm.com, kgraul@linux.ibm.com, ubraun@linux.ibm.com
Subject: [PATCH net-next 3/8] net/smc: check for ip prefix and subnet
Date: Fri, 12 Apr 2019 12:57:25 +0200	[thread overview]
Message-ID: <20190412105730.96245-4-ubraun@linux.ibm.com> (raw)
In-Reply-To: <20190412105730.96245-1-ubraun@linux.ibm.com>

From: Karsten Graul <kgraul@linux.ibm.com>

The check for a matching ip prefix and subnet was only done for SMC-R
in smc_listen_rdma_check() but not when an SMC-D connection was
possible. Rename the function into smc_listen_prfx_check() and move its
call to a place where it is called for both SMC variants.
And add a new CLC DECLINE reason for the case when the IP prefix or
subnet check fails so the reason for the failing SMC connection can be
found out more easily.

Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
---
 net/smc/af_smc.c  | 12 +++++++++---
 net/smc/smc_clc.h |  1 +
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index e1b7b5bdb440..cb8bc77c75d6 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1104,7 +1104,7 @@ static void smc_listen_decline(struct smc_sock *new_smc, int reason_code,
 }
 
 /* listen worker: check prefixes */
-static int smc_listen_rdma_check(struct smc_sock *new_smc,
+static int smc_listen_prfx_check(struct smc_sock *new_smc,
 				 struct smc_clc_msg_proposal *pclc)
 {
 	struct smc_clc_msg_proposal_prefix *pclc_prfx;
@@ -1112,7 +1112,7 @@ static int smc_listen_rdma_check(struct smc_sock *new_smc,
 
 	pclc_prfx = smc_clc_proposal_get_prefix(pclc);
 	if (smc_clc_prfx_match(newclcsock, pclc_prfx))
-		return SMC_CLC_DECL_CNFERR;
+		return SMC_CLC_DECL_DIFFPREFIX;
 
 	return 0;
 }
@@ -1272,6 +1272,13 @@ static void smc_listen_work(struct work_struct *work)
 		return;
 	}
 
+	/* check for matching IP prefix and subnet length */
+	rc = smc_listen_prfx_check(new_smc, pclc);
+	if (rc) {
+		smc_listen_decline(new_smc, rc, 0);
+		return;
+	}
+
 	mutex_lock(&smc_server_lgr_pending);
 	smc_close_init(new_smc);
 	smc_rx_init(new_smc);
@@ -1289,7 +1296,6 @@ static void smc_listen_work(struct work_struct *work)
 	    ((pclc->hdr.path != SMC_TYPE_R && pclc->hdr.path != SMC_TYPE_B) ||
 	     smc_vlan_by_tcpsk(new_smc->clcsock, &vlan) ||
 	     smc_check_rdma(new_smc, &ibdev, &ibport, vlan, NULL) ||
-	     smc_listen_rdma_check(new_smc, pclc) ||
 	     smc_listen_rdma_init(new_smc, pclc, ibdev, ibport,
 				  &local_contact) ||
 	     smc_listen_rdma_reg(new_smc, local_contact))) {
diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h
index 6c94d54e7a67..f251bed2e7d5 100644
--- a/net/smc/smc_clc.h
+++ b/net/smc/smc_clc.h
@@ -38,6 +38,7 @@
 #define SMC_CLC_DECL_MODEUNSUPP	0x03040000  /* smc modes do not match (R or D)*/
 #define SMC_CLC_DECL_RMBE_EC	0x03050000  /* peer has eyecatcher in RMBE    */
 #define SMC_CLC_DECL_OPTUNSUPP	0x03060000  /* fastopen sockopt not supported */
+#define SMC_CLC_DECL_DIFFPREFIX	0x03070000  /* IP prefix / subnet mismatch    */
 #define SMC_CLC_DECL_SYNCERR	0x04000000  /* synchronization error          */
 #define SMC_CLC_DECL_PEERDECL	0x05000000  /* peer declined during handshake */
 #define SMC_CLC_DECL_INTERR	0x09990000  /* internal error		      */
-- 
2.16.4

  parent reply	other threads:[~2019-04-12 10:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-12 10:57 [PATCH net-next 0/8] net/smc: patches 2019-04-12 Ursula Braun
2019-04-12 10:57 ` [PATCH net-next 1/8] net/smc: nonblocking connect rework Ursula Braun
2019-04-12 10:57 ` [PATCH net-next 2/8] net/smc: fallback to TCP after connect problems Ursula Braun
2019-04-12 10:57 ` Ursula Braun [this message]
2019-04-12 10:57 ` [PATCH net-next 4/8] net/smc: consolidate function parameters Ursula Braun
2019-04-12 10:57 ` [PATCH net-next 5/8] net/smc: cleanup of get vlan id Ursula Braun
2019-04-12 10:57 ` [PATCH net-next 6/8] net/smc: code cleanup smc_listen_work Ursula Braun
2019-04-12 10:57 ` [PATCH net-next 7/8] net/smc: improve smc_listen_work reason codes Ursula Braun
2019-04-12 10:57 ` [PATCH net-next 8/8] net/smc: improve smc_conn_create " Ursula Braun
2019-04-12 18:25 ` [PATCH net-next 0/8] net/smc: patches 2019-04-12 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190412105730.96245-4-ubraun@linux.ibm.com \
    --to=ubraun@linux.ibm.com \
    --cc=davem@davemloft.net \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kgraul@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=raspl@linux.ibm.com \
    --cc=schwidefsky@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox