From owner-svn-src-head@FreeBSD.ORG Wed Jun 18 17:04:26 2014 Return-Path: Delivered-To: svn-src-head@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 87B82FF1; Wed, 18 Jun 2014 17:04:26 +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 6875C29F9; Wed, 18 Jun 2014 17:04:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5IH4Qsj055268; Wed, 18 Jun 2014 17:04:26 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5IH4QDp055266; Wed, 18 Jun 2014 17:04:26 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201406181704.s5IH4QDp055266@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 18 Jun 2014 17:04:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267609 - head/usr.sbin/iscsid X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jun 2014 17:04:26 -0000 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");