From owner-svn-src-all@FreeBSD.ORG Thu Jul 24 15:41:17 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 60290678; Thu, 24 Jul 2014 15:41:17 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 419252D07; Thu, 24 Jul 2014 15:41:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6OFfHGl005236; Thu, 24 Jul 2014 15:41:17 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6OFfHI7005235; Thu, 24 Jul 2014 15:41:17 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201407241541.s6OFfHI7005235@svn.freebsd.org> From: Alexander Motin Date: Thu, 24 Jul 2014 15:41:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r269068 - stable/10/usr.sbin/iscsid X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jul 2014 15:41:17 -0000 Author: mav Date: Thu Jul 24 15:41:16 2014 New Revision: 269068 URL: http://svnweb.freebsd.org/changeset/base/269068 Log: MFC r267609 (by trasz): Improve code a little; no functional changes. Modified: stable/10/usr.sbin/iscsid/login.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/iscsid/login.c ============================================================================== --- stable/10/usr.sbin/iscsid/login.c Thu Jul 24 15:38:49 2014 (r269067) +++ stable/10/usr.sbin/iscsid/login.c Thu Jul 24 15:41:16 2014 (r269068) @@ -266,18 +266,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_tsih = htons(conn->conn_tsih); bhslr->bhslr_initiator_task_tag = 0; @@ -558,9 +572,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(); /* @@ -632,7 +644,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); @@ -694,7 +706,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); @@ -821,7 +833,7 @@ login(struct connection *conn) int i; 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");