Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jun 2014 17:04:26 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r267609 - head/usr.sbin/iscsid
Message-ID:  <201406181704.s5IH4QDp055266@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Wed Jun 18 17:04:25 2014
New Revision: 267609
URL: http://svnweb.freebsd.org/changeset/base/267609

Log:
  Improve code a little; no functional changes.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/usr.sbin/iscsid/login.c

Modified: head/usr.sbin/iscsid/login.c
==============================================================================
--- head/usr.sbin/iscsid/login.c	Wed Jun 18 17:00:41 2014	(r267608)
+++ head/usr.sbin/iscsid/login.c	Wed Jun 18 17:04:25 2014	(r267609)
@@ -205,18 +205,32 @@ login_receive(struct connection *conn, b
 }
 
 static struct pdu *
-login_new_request(struct connection *conn)
+login_new_request(struct connection *conn, int csg)
 {
 	struct pdu *request;
 	struct iscsi_bhs_login_request *bhslr;
+	int nsg;
 
 	request = pdu_new(conn);
 	bhslr = (struct iscsi_bhs_login_request *)request->pdu_bhs;
 	bhslr->bhslr_opcode = ISCSI_BHS_OPCODE_LOGIN_REQUEST |
 	    ISCSI_BHS_OPCODE_IMMEDIATE;
+
 	bhslr->bhslr_flags = BHSLR_FLAGS_TRANSIT;
-	login_set_csg(request, BHSLR_STAGE_SECURITY_NEGOTIATION);
-	login_set_nsg(request, BHSLR_STAGE_OPERATIONAL_NEGOTIATION);
+	switch (csg) {
+	case BHSLR_STAGE_SECURITY_NEGOTIATION:
+		nsg = BHSLR_STAGE_OPERATIONAL_NEGOTIATION;
+		break;
+	case BHSLR_STAGE_OPERATIONAL_NEGOTIATION:
+		nsg = BHSLR_STAGE_FULL_FEATURE_PHASE;
+		break;
+	default:
+		assert(!"invalid csg");
+		log_errx(1, "invalid csg %d", csg);
+	}
+	login_set_csg(request, csg);
+	login_set_nsg(request, nsg);
+
 	memcpy(bhslr->bhslr_isid, &conn->conn_isid, sizeof(bhslr->bhslr_isid));
 	bhslr->bhslr_initiator_task_tag = 0;
 	bhslr->bhslr_cmdsn = 0;
@@ -496,9 +510,7 @@ login_negotiate(struct connection *conn)
 	int i;
 
 	log_debugx("beginning operational parameter negotiation");
-	request = login_new_request(conn);
-	login_set_csg(request, BHSLR_STAGE_OPERATIONAL_NEGOTIATION);
-	login_set_nsg(request, BHSLR_STAGE_FULL_FEATURE_PHASE);
+	request = login_new_request(conn, BHSLR_STAGE_OPERATIONAL_NEGOTIATION);
 	request_keys = keys_new();
 
 	/*
@@ -570,7 +582,7 @@ login_send_chap_a(struct connection *con
 	struct pdu *request;
 	struct keys *request_keys;
 
-	request = login_new_request(conn);
+	request = login_new_request(conn, BHSLR_STAGE_SECURITY_NEGOTIATION);
 	request_keys = keys_new();
 	keys_add(request_keys, "CHAP_A", "5");
 	keys_save(request_keys, request);
@@ -632,7 +644,7 @@ login_send_chap_r(struct pdu *response)
 
 	keys_delete(response_keys);
 
-	request = login_new_request(conn);
+	request = login_new_request(conn, BHSLR_STAGE_SECURITY_NEGOTIATION);
 	request_keys = keys_new();
 	keys_add(request_keys, "CHAP_N", conn->conn_conf.isc_user);
 	keys_add(request_keys, "CHAP_R", chap_r);
@@ -779,7 +791,7 @@ login(struct connection *conn)
 	login_create_isid(conn);
 
 	log_debugx("beginning Login phase; sending Login PDU");
-	request = login_new_request(conn);
+	request = login_new_request(conn, BHSLR_STAGE_SECURITY_NEGOTIATION);
 	request_keys = keys_new();
 	if (conn->conn_conf.isc_mutual_user[0] != '\0') {
 		keys_add(request_keys, "AuthMethod", "CHAP");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406181704.s5IH4QDp055266>