~ubuntu-branches/ubuntu/oneiric/open-iscsi/oneiric

« back to all changes in this revision

Viewing changes to usr/login.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Zobel-Helas
  • Date: 2006-12-03 16:54:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20061203165421-udgd6i05ugt1byrh
Tags: upstream-2.0.730
ImportĀ upstreamĀ versionĀ 2.0.730

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <sys/param.h>
31
31
 
32
32
#include "initiator.h"
 
33
#include "transport.h"
33
34
#include "log.h"
34
35
 
35
36
/* caller is assumed to be well-behaved and passing NUL terminated strings */
210
211
        }
211
212
 
212
213
        conn->saddr = addr;
213
 
        /* update session's rec */
214
 
        memset(session->nrec.conn[0].address, 0, NI_MAXHOST);
215
 
        memcpy(session->nrec.conn[0].address, address, strlen(address));
216
 
        session->nrec.conn[0].port = atoi(port);
217
214
        if (tag)
218
 
                session->nrec.tpgt = atoi(tag);
 
215
                session->portal_group_tag = atoi(tag);
219
216
        return 1;
220
217
}
221
218
 
382
379
                text = value_end;
383
380
        } else if (iscsi_find_key_value("MaxRecvDataSegmentLength", text, end,
384
381
                                     &value, &value_end)) {
385
 
                conn->max_xmit_dlength = strtoul(value, NULL, 0);
 
382
                if (session->type == ISCSI_SESSION_TYPE_DISCOVERY ||
 
383
                    !session->provider->utransport->rdma)
 
384
                        conn->max_xmit_dlength = strtoul(value, NULL, 0);
386
385
                text = value_end;
387
386
        } else if (iscsi_find_key_value("FirstBurstLength", text, end, &value,
388
387
                                         &value_end)) {
539
538
                text = value_end;
540
539
        } else if (iscsi_find_key_value("RDMAExtensions", text, end,
541
540
                                        &value, &value_end)) {
542
 
                if (session->provider->rdma) {
543
 
                        if (strcmp(value, "Yes") == 0)
544
 
                                session->rdma_ext = RDMA_EXT_YES;
545
 
                        else
546
 
                                session->rdma_ext = RDMA_EXT_NO;
547
 
                } else if (strcmp(value, "Yes") == 0) {
 
541
                if (session->provider->utransport->rdma &&
 
542
                    strcmp(value, "Yes") != 0) {
548
543
                        log_error("Login negotiation failed, "
549
 
                                  "can't support RDMAExtensions");
 
544
                                  "Target must support RDMAExtensions");
550
545
                        return LOGIN_NEGOTIATION_FAILED;
551
546
                }
552
547
                text = value_end;
553
548
        } else if (iscsi_find_key_value("InitiatorRecvDataSegmentLength", text,
554
549
                                        end, &value, &value_end)) {
555
 
                if (session->provider->rdma) {
556
 
                        if (conn->max_recv_dlength != strtoul(value, NULL, 0)) {
557
 
                                log_error("Login negotiation failed, "
558
 
                                          "InitiatorRecvDataSegmentLength wasn't "
559
 
                                          "accepted by the target");
560
 
                                return LOGIN_NEGOTIATION_FAILED;
561
 
                        }
 
550
                if (session->provider->utransport->rdma) {
 
551
                        conn->max_recv_dlength = MIN(conn->max_recv_dlength,
 
552
                                                     strtoul(value, NULL, 0));
562
553
                }
563
554
                text = value_end;
564
555
        } else if (iscsi_find_key_value("TargetRecvDataSegmentLength", text,
565
556
                                        end, &value, &value_end)) {
566
 
                if (session->provider->rdma)
567
 
                        conn->max_xmit_dlength = strtoul(value, NULL, 0);
 
557
                if (session->provider->utransport->rdma) {
 
558
                        conn->max_xmit_dlength = MIN(conn->max_xmit_dlength,
 
559
                                                     strtoul(value, NULL, 0));
 
560
                }
568
561
                text = value_end;
569
562
        } else if (iscsi_find_key_value ("X-com.cisco.protocol", text, end,
570
563
                                         &value, &value_end)) {
820
813
        char value[AUTH_STR_MAX_LEN];
821
814
        iscsi_conn_t *conn = &session->conn[cid];
822
815
 
823
 
        if (!session->provider->rdma) {
 
816
        if (session->type == ISCSI_SESSION_TYPE_DISCOVERY ||
 
817
            !session->provider->utransport->rdma) {
824
818
                sprintf(value, "%d", conn->max_recv_dlength);
825
819
                if (!iscsi_add_text(pdu, data, max_data_length,
826
820
                                    "MaxRecvDataSegmentLength", value))
827
821
                        return 0;
828
 
                session->rdma_ext = RDMA_EXT_NO;
829
822
        } else {
830
823
                sprintf(value, "%d", conn->max_recv_dlength);
831
824
                if (!iscsi_add_text(pdu, data, max_data_length,
832
825
                                   "InitiatorRecvDataSegmentLength",
833
826
                                    value))
834
827
                        return 0;
 
828
 
 
829
                sprintf(value, "%d", conn->max_xmit_dlength);
 
830
                if (!iscsi_add_text(pdu, data, max_data_length,
 
831
                                   "TargetRecvDataSegmentLength",
 
832
                                    value))
 
833
                        return 0;
 
834
 
835
835
                if (!iscsi_add_text(pdu, data, max_data_length,
836
836
                                   "RDMAExtensions", "Yes"))
837
837
                        return 0;
958
958
        *transit = 1;
959
959
 
960
960
        rdma = (session->type == ISCSI_SESSION_TYPE_NORMAL) &&
961
 
                        session->provider->rdma;
962
 
                        
963
 
        /* For RDMA transport stage switched after RDMAExtensions negotiated */
964
 
        if (rdma && session->rdma_ext != RDMA_EXT_NOT_NEGOTIATED)
965
 
                *transit = 0;
 
961
                        session->provider->utransport->rdma;
966
962
 
967
963
        /*
968
964
         * If we haven't gotten a partial response, then either we shouldn't be
1136
1132
        /* don't increment on immediate */
1137
1133
        login_hdr->min_version = ISCSI_DRAFT20_VERSION;
1138
1134
        login_hdr->max_version = ISCSI_DRAFT20_VERSION;
1139
 
 
1140
 
        /* we have to send 0 until full-feature stage */
1141
1135
        login_hdr->exp_statsn = htonl(conn->exp_statsn);
1142
1136
 
1143
1137
        /*
1342
1336
                session->max_cmdsn = 1;
1343
1337
        }
1344
1338
 
1345
 
        conn->exp_statsn = 0;
1346
1339
        conn->current_stage = ISCSI_INITIAL_LOGIN_STAGE;
1347
1340
        conn->partial_response = 0;
1348
1341
 
1508
1501
        iscsi_login_context_t *c = &conn->login_context;
1509
1502
 
1510
1503
        conn->kernel_io = 0;
 
1504
        /*
 
1505
         * assume iscsi_login is only called from discovery, so it is
 
1506
         * safe to always set to zero
 
1507
         */
 
1508
        conn->exp_statsn = 0;
1511
1509
 
1512
1510
        c->cid = cid;
1513
1511
        c->buffer = buffer;