Lines Matching +full:key +full:- +full:value
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * (c) Copyright 2007-2013 Datera, Inc.
7 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
33 return -1; in iscsi_login_rx_data()
64 return -1; in iscsi_login_tx_data()
72 pr_debug("HeaderDigest: %s\n", (conn_ops->HeaderDigest) ? in iscsi_dump_conn_ops()
74 pr_debug("DataDigest: %s\n", (conn_ops->DataDigest) ? in iscsi_dump_conn_ops()
77 conn_ops->MaxRecvDataSegmentLength); in iscsi_dump_conn_ops()
82 pr_debug("InitiatorName: %s\n", sess_ops->InitiatorName); in iscsi_dump_sess_ops()
83 pr_debug("InitiatorAlias: %s\n", sess_ops->InitiatorAlias); in iscsi_dump_sess_ops()
84 pr_debug("TargetName: %s\n", sess_ops->TargetName); in iscsi_dump_sess_ops()
85 pr_debug("TargetAlias: %s\n", sess_ops->TargetAlias); in iscsi_dump_sess_ops()
87 sess_ops->TargetPortalGroupTag); in iscsi_dump_sess_ops()
88 pr_debug("MaxConnections: %hu\n", sess_ops->MaxConnections); in iscsi_dump_sess_ops()
90 (sess_ops->InitialR2T) ? "Yes" : "No"); in iscsi_dump_sess_ops()
91 pr_debug("ImmediateData: %s\n", (sess_ops->ImmediateData) ? in iscsi_dump_sess_ops()
93 pr_debug("MaxBurstLength: %u\n", sess_ops->MaxBurstLength); in iscsi_dump_sess_ops()
94 pr_debug("FirstBurstLength: %u\n", sess_ops->FirstBurstLength); in iscsi_dump_sess_ops()
95 pr_debug("DefaultTime2Wait: %hu\n", sess_ops->DefaultTime2Wait); in iscsi_dump_sess_ops()
97 sess_ops->DefaultTime2Retain); in iscsi_dump_sess_ops()
99 sess_ops->MaxOutstandingR2T); in iscsi_dump_sess_ops()
101 (sess_ops->DataPDUInOrder) ? "Yes" : "No"); in iscsi_dump_sess_ops()
103 (sess_ops->DataSequenceInOrder) ? "Yes" : "No"); in iscsi_dump_sess_ops()
105 sess_ops->ErrorRecoveryLevel); in iscsi_dump_sess_ops()
106 pr_debug("SessionType: %s\n", (sess_ops->SessionType) ? in iscsi_dump_sess_ops()
114 list_for_each_entry(param, ¶m_list->param_list, p_list) in iscsi_print_params()
115 pr_debug("%s: %s\n", param->name, param->value); in iscsi_print_params()
119 char *name, char *value, u8 phase, u8 scope, u8 sender, in iscsi_set_default_param() argument
129 INIT_LIST_HEAD(¶m->p_list); in iscsi_set_default_param()
131 param->name = kstrdup(name, GFP_KERNEL); in iscsi_set_default_param()
132 if (!param->name) { in iscsi_set_default_param()
137 param->value = kstrdup(value, GFP_KERNEL); in iscsi_set_default_param()
138 if (!param->value) { in iscsi_set_default_param()
139 pr_err("Unable to allocate memory for parameter value.\n"); in iscsi_set_default_param()
143 param->phase = phase; in iscsi_set_default_param()
144 param->scope = scope; in iscsi_set_default_param()
145 param->sender = sender; in iscsi_set_default_param()
146 param->use = use; in iscsi_set_default_param()
147 param->type_range = type_range; in iscsi_set_default_param()
149 switch (param->type_range) { in iscsi_set_default_param()
151 param->type = TYPE_BOOL_AND; in iscsi_set_default_param()
154 param->type = TYPE_BOOL_OR; in iscsi_set_default_param()
163 param->type = TYPE_NUMBER; in iscsi_set_default_param()
167 param->type = TYPE_VALUE_LIST | TYPE_STRING; in iscsi_set_default_param()
173 param->type = TYPE_STRING; in iscsi_set_default_param()
177 param->type_range); in iscsi_set_default_param()
180 list_add_tail(¶m->p_list, ¶m_list->param_list); in iscsi_set_default_param()
185 kfree(param->value); in iscsi_set_default_param()
186 kfree(param->name); in iscsi_set_default_param()
203 return -ENOMEM; in iscsi_create_default_params()
205 INIT_LIST_HEAD(&pl->param_list); in iscsi_create_default_params()
206 INIT_LIST_HEAD(&pl->extra_response_list); in iscsi_create_default_params()
212 * Initial value: in iscsi_create_default_params()
404 * Extra parameters for ISER from RFC-5046 in iscsi_create_default_params()
430 return -1; in iscsi_create_default_params()
439 param_list->iser = iser; in iscsi_set_keys_to_negotiate()
441 list_for_each_entry(param, ¶m_list->param_list, p_list) { in iscsi_set_keys_to_negotiate()
442 param->state = 0; in iscsi_set_keys_to_negotiate()
443 if (!strcmp(param->name, AUTHMETHOD)) { in iscsi_set_keys_to_negotiate()
445 } else if (!strcmp(param->name, HEADERDIGEST)) { in iscsi_set_keys_to_negotiate()
448 } else if (!strcmp(param->name, DATADIGEST)) { in iscsi_set_keys_to_negotiate()
451 } else if (!strcmp(param->name, MAXCONNECTIONS)) { in iscsi_set_keys_to_negotiate()
453 } else if (!strcmp(param->name, TARGETNAME)) { in iscsi_set_keys_to_negotiate()
455 } else if (!strcmp(param->name, INITIATORNAME)) { in iscsi_set_keys_to_negotiate()
457 } else if (!strcmp(param->name, TARGETALIAS)) { in iscsi_set_keys_to_negotiate()
458 if (param->value) in iscsi_set_keys_to_negotiate()
460 } else if (!strcmp(param->name, INITIATORALIAS)) { in iscsi_set_keys_to_negotiate()
462 } else if (!strcmp(param->name, TARGETPORTALGROUPTAG)) { in iscsi_set_keys_to_negotiate()
464 } else if (!strcmp(param->name, INITIALR2T)) { in iscsi_set_keys_to_negotiate()
466 } else if (!strcmp(param->name, IMMEDIATEDATA)) { in iscsi_set_keys_to_negotiate()
468 } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) { in iscsi_set_keys_to_negotiate()
471 } else if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) { in iscsi_set_keys_to_negotiate()
473 } else if (!strcmp(param->name, MAXBURSTLENGTH)) { in iscsi_set_keys_to_negotiate()
475 } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) { in iscsi_set_keys_to_negotiate()
477 } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) { in iscsi_set_keys_to_negotiate()
479 } else if (!strcmp(param->name, DEFAULTTIME2RETAIN)) { in iscsi_set_keys_to_negotiate()
481 } else if (!strcmp(param->name, MAXOUTSTANDINGR2T)) { in iscsi_set_keys_to_negotiate()
483 } else if (!strcmp(param->name, DATAPDUINORDER)) { in iscsi_set_keys_to_negotiate()
485 } else if (!strcmp(param->name, DATASEQUENCEINORDER)) { in iscsi_set_keys_to_negotiate()
487 } else if (!strcmp(param->name, ERRORRECOVERYLEVEL)) { in iscsi_set_keys_to_negotiate()
489 } else if (!strcmp(param->name, SESSIONTYPE)) { in iscsi_set_keys_to_negotiate()
491 } else if (!strcmp(param->name, IFMARKER)) { in iscsi_set_keys_to_negotiate()
493 } else if (!strcmp(param->name, OFMARKER)) { in iscsi_set_keys_to_negotiate()
495 } else if (!strcmp(param->name, IFMARKINT)) { in iscsi_set_keys_to_negotiate()
497 } else if (!strcmp(param->name, OFMARKINT)) { in iscsi_set_keys_to_negotiate()
499 } else if (!strcmp(param->name, RDMAEXTENSIONS)) { in iscsi_set_keys_to_negotiate()
502 } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) { in iscsi_set_keys_to_negotiate()
505 } else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH)) { in iscsi_set_keys_to_negotiate()
519 list_for_each_entry(param, ¶m_list->param_list, p_list) { in iscsi_set_keys_irrelevant_for_discovery()
520 if (!strcmp(param->name, MAXCONNECTIONS)) in iscsi_set_keys_irrelevant_for_discovery()
521 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
522 else if (!strcmp(param->name, INITIALR2T)) in iscsi_set_keys_irrelevant_for_discovery()
523 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
524 else if (!strcmp(param->name, IMMEDIATEDATA)) in iscsi_set_keys_irrelevant_for_discovery()
525 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
526 else if (!strcmp(param->name, MAXBURSTLENGTH)) in iscsi_set_keys_irrelevant_for_discovery()
527 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
528 else if (!strcmp(param->name, FIRSTBURSTLENGTH)) in iscsi_set_keys_irrelevant_for_discovery()
529 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
530 else if (!strcmp(param->name, MAXOUTSTANDINGR2T)) in iscsi_set_keys_irrelevant_for_discovery()
531 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
532 else if (!strcmp(param->name, DATAPDUINORDER)) in iscsi_set_keys_irrelevant_for_discovery()
533 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
534 else if (!strcmp(param->name, DATASEQUENCEINORDER)) in iscsi_set_keys_irrelevant_for_discovery()
535 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
536 else if (!strcmp(param->name, ERRORRECOVERYLEVEL)) in iscsi_set_keys_irrelevant_for_discovery()
537 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
538 else if (!strcmp(param->name, DEFAULTTIME2WAIT)) in iscsi_set_keys_irrelevant_for_discovery()
539 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
540 else if (!strcmp(param->name, DEFAULTTIME2RETAIN)) in iscsi_set_keys_irrelevant_for_discovery()
541 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
542 else if (!strcmp(param->name, IFMARKER)) in iscsi_set_keys_irrelevant_for_discovery()
543 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
544 else if (!strcmp(param->name, OFMARKER)) in iscsi_set_keys_irrelevant_for_discovery()
545 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
546 else if (!strcmp(param->name, IFMARKINT)) in iscsi_set_keys_irrelevant_for_discovery()
547 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
548 else if (!strcmp(param->name, OFMARKINT)) in iscsi_set_keys_irrelevant_for_discovery()
549 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
550 else if (!strcmp(param->name, RDMAEXTENSIONS)) in iscsi_set_keys_irrelevant_for_discovery()
551 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
552 else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) in iscsi_set_keys_irrelevant_for_discovery()
553 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
554 else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH)) in iscsi_set_keys_irrelevant_for_discovery()
555 param->state &= ~PSTATE_NEGOTIATE; in iscsi_set_keys_irrelevant_for_discovery()
573 return -ENOMEM; in iscsi_copy_param_list()
575 INIT_LIST_HEAD(¶m_list->param_list); in iscsi_copy_param_list()
576 INIT_LIST_HEAD(¶m_list->extra_response_list); in iscsi_copy_param_list()
578 list_for_each_entry(param, &src_param_list->param_list, p_list) { in iscsi_copy_param_list()
579 if (!leading && (param->scope & SCOPE_SESSION_WIDE)) { in iscsi_copy_param_list()
580 if ((strcmp(param->name, "TargetName") != 0) && in iscsi_copy_param_list()
581 (strcmp(param->name, "InitiatorName") != 0) && in iscsi_copy_param_list()
582 (strcmp(param->name, "TargetPortalGroupTag") != 0)) in iscsi_copy_param_list()
592 new_param->name = kstrdup(param->name, GFP_KERNEL); in iscsi_copy_param_list()
593 new_param->value = kstrdup(param->value, GFP_KERNEL); in iscsi_copy_param_list()
594 if (!new_param->value || !new_param->name) { in iscsi_copy_param_list()
595 kfree(new_param->value); in iscsi_copy_param_list()
596 kfree(new_param->name); in iscsi_copy_param_list()
598 pr_err("Unable to allocate memory for parameter name/value.\n"); in iscsi_copy_param_list()
602 new_param->set_param = param->set_param; in iscsi_copy_param_list()
603 new_param->phase = param->phase; in iscsi_copy_param_list()
604 new_param->scope = param->scope; in iscsi_copy_param_list()
605 new_param->sender = param->sender; in iscsi_copy_param_list()
606 new_param->type = param->type; in iscsi_copy_param_list()
607 new_param->use = param->use; in iscsi_copy_param_list()
608 new_param->type_range = param->type_range; in iscsi_copy_param_list()
610 list_add_tail(&new_param->p_list, ¶m_list->param_list); in iscsi_copy_param_list()
613 if (!list_empty(¶m_list->param_list)) { in iscsi_copy_param_list()
624 return -ENOMEM; in iscsi_copy_param_list()
631 list_for_each_entry_safe(er, er_tmp, ¶m_list->extra_response_list, in iscsi_release_extra_responses()
633 list_del(&er->er_list); in iscsi_release_extra_responses()
642 list_for_each_entry_safe(param, param_tmp, ¶m_list->param_list, in iscsi_release_param_list()
644 list_del(¶m->p_list); in iscsi_release_param_list()
646 kfree(param->name); in iscsi_release_param_list()
647 kfree(param->value); in iscsi_release_param_list()
657 char *key, in iscsi_find_param_from_key() argument
662 if (!key || !param_list) { in iscsi_find_param_from_key()
663 pr_err("Key or parameter list pointer is NULL.\n"); in iscsi_find_param_from_key()
667 list_for_each_entry(param, ¶m_list->param_list, p_list) { in iscsi_find_param_from_key()
668 if (!strcmp(key, param->name)) in iscsi_find_param_from_key()
672 pr_err("Unable to locate key \"%s\".\n", key); in iscsi_find_param_from_key()
677 int iscsi_extract_key_value(char *textbuf, char **key, char **value) in iscsi_extract_key_value() argument
679 *value = strchr(textbuf, '='); in iscsi_extract_key_value()
680 if (!*value) { in iscsi_extract_key_value()
681 pr_err("Unable to locate \"=\" separator for key," in iscsi_extract_key_value()
683 return -1; in iscsi_extract_key_value()
686 *key = textbuf; in iscsi_extract_key_value()
687 **value = '\0'; in iscsi_extract_key_value()
688 *value = *value + 1; in iscsi_extract_key_value()
693 int iscsi_update_param_value(struct iscsi_param *param, char *value) in iscsi_update_param_value() argument
695 kfree(param->value); in iscsi_update_param_value()
697 param->value = kstrdup(value, GFP_KERNEL); in iscsi_update_param_value()
698 if (!param->value) { in iscsi_update_param_value()
699 pr_err("Unable to allocate memory for value.\n"); in iscsi_update_param_value()
700 return -ENOMEM; in iscsi_update_param_value()
704 param->name, param->value); in iscsi_update_param_value()
709 char *key, in iscsi_add_notunderstood_response() argument
710 char *value, in iscsi_add_notunderstood_response() argument
715 if (strlen(value) > VALUE_MAXLEN) { in iscsi_add_notunderstood_response()
716 pr_err("Value for notunderstood key \"%s\" exceeds %d," in iscsi_add_notunderstood_response()
717 " protocol error.\n", key, VALUE_MAXLEN); in iscsi_add_notunderstood_response()
718 return -1; in iscsi_add_notunderstood_response()
725 return -ENOMEM; in iscsi_add_notunderstood_response()
727 INIT_LIST_HEAD(&extra_response->er_list); in iscsi_add_notunderstood_response()
729 strscpy(extra_response->key, key, sizeof(extra_response->key)); in iscsi_add_notunderstood_response()
730 strscpy(extra_response->value, NOTUNDERSTOOD, in iscsi_add_notunderstood_response()
731 sizeof(extra_response->value)); in iscsi_add_notunderstood_response()
733 list_add_tail(&extra_response->er_list, in iscsi_add_notunderstood_response()
734 ¶m_list->extra_response_list); in iscsi_add_notunderstood_response()
738 static int iscsi_check_for_auth_key(char *key) in iscsi_check_for_auth_key() argument
743 if (!strcmp(key, "CHAP_A") || !strcmp(key, "CHAP_I") || in iscsi_check_for_auth_key()
744 !strcmp(key, "CHAP_C") || !strcmp(key, "CHAP_N") || in iscsi_check_for_auth_key()
745 !strcmp(key, "CHAP_R")) in iscsi_check_for_auth_key()
751 if (!strcmp(key, "SRP_U") || !strcmp(key, "SRP_N") || in iscsi_check_for_auth_key()
752 !strcmp(key, "SRP_g") || !strcmp(key, "SRP_s") || in iscsi_check_for_auth_key()
753 !strcmp(key, "SRP_A") || !strcmp(key, "SRP_B") || in iscsi_check_for_auth_key()
754 !strcmp(key, "SRP_M") || !strcmp(key, "SRP_HM")) in iscsi_check_for_auth_key()
764 if (!strcmp(param->value, NO)) in iscsi_check_proposer_for_optional_reply()
767 if (!strcmp(param->value, YES)) in iscsi_check_proposer_for_optional_reply()
774 if (!strcmp(param->name, IMMEDIATEDATA)) in iscsi_check_proposer_for_optional_reply()
778 if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) in iscsi_check_proposer_for_optional_reply()
785 if (!strcmp(param->name, FIRSTBURSTLENGTH)) in iscsi_check_proposer_for_optional_reply()
791 if (!strcmp(param->name, MAXCONNECTIONS)) in iscsi_check_proposer_for_optional_reply()
798 static int iscsi_check_boolean_value(struct iscsi_param *param, char *value) in iscsi_check_boolean_value() argument
800 if (strcmp(value, YES) && strcmp(value, NO)) { in iscsi_check_boolean_value()
801 pr_err("Illegal value for \"%s\", must be either" in iscsi_check_boolean_value()
802 " \"%s\" or \"%s\".\n", param->name, YES, NO); in iscsi_check_boolean_value()
803 return -1; in iscsi_check_boolean_value()
812 int value = 0; in iscsi_check_numerical_value() local
814 value = simple_strtoul(value_ptr, &tmpptr, 0); in iscsi_check_numerical_value()
817 if ((value < 0) || (value > 2)) { in iscsi_check_numerical_value()
818 pr_err("Illegal value for \"%s\", must be" in iscsi_check_numerical_value()
819 " between 0 and 2.\n", param->name); in iscsi_check_numerical_value()
820 return -1; in iscsi_check_numerical_value()
825 if ((value < 0) || (value > 3600)) { in iscsi_check_numerical_value()
826 pr_err("Illegal value for \"%s\", must be" in iscsi_check_numerical_value()
827 " between 0 and 3600.\n", param->name); in iscsi_check_numerical_value()
828 return -1; in iscsi_check_numerical_value()
833 if ((value < 0) || (value > 32767)) { in iscsi_check_numerical_value()
834 pr_err("Illegal value for \"%s\", must be" in iscsi_check_numerical_value()
835 " between 0 and 32767.\n", param->name); in iscsi_check_numerical_value()
836 return -1; in iscsi_check_numerical_value()
841 if ((value < 0) || (value > 65535)) { in iscsi_check_numerical_value()
842 pr_err("Illegal value for \"%s\", must be" in iscsi_check_numerical_value()
843 " between 0 and 65535.\n", param->name); in iscsi_check_numerical_value()
844 return -1; in iscsi_check_numerical_value()
849 if ((value < 1) || (value > 65535)) { in iscsi_check_numerical_value()
850 pr_err("Illegal value for \"%s\", must be" in iscsi_check_numerical_value()
851 " between 1 and 65535.\n", param->name); in iscsi_check_numerical_value()
852 return -1; in iscsi_check_numerical_value()
857 if ((value < 2) || (value > 3600)) { in iscsi_check_numerical_value()
858 pr_err("Illegal value for \"%s\", must be" in iscsi_check_numerical_value()
859 " between 2 and 3600.\n", param->name); in iscsi_check_numerical_value()
860 return -1; in iscsi_check_numerical_value()
865 if ((value < 512) || (value > 16777215)) { in iscsi_check_numerical_value()
866 pr_err("Illegal value for \"%s\", must be" in iscsi_check_numerical_value()
867 " between 512 and 16777215.\n", param->name); in iscsi_check_numerical_value()
868 return -1; in iscsi_check_numerical_value()
876 static int iscsi_check_string_or_list_value(struct iscsi_param *param, char *value) in iscsi_check_string_or_list_value() argument
882 if (strcmp(value, KRB5) && strcmp(value, SPKM1) && in iscsi_check_string_or_list_value()
883 strcmp(value, SPKM2) && strcmp(value, SRP) && in iscsi_check_string_or_list_value()
884 strcmp(value, CHAP) && strcmp(value, NONE)) { in iscsi_check_string_or_list_value()
885 pr_err("Illegal value for \"%s\", must be" in iscsi_check_string_or_list_value()
887 " or \"%s\".\n", param->name, KRB5, in iscsi_check_string_or_list_value()
889 return -1; in iscsi_check_string_or_list_value()
893 if (strcmp(value, CRC32C) && strcmp(value, NONE)) { in iscsi_check_string_or_list_value()
894 pr_err("Illegal value for \"%s\", must be" in iscsi_check_string_or_list_value()
895 " \"%s\" or \"%s\".\n", param->name, in iscsi_check_string_or_list_value()
897 return -1; in iscsi_check_string_or_list_value()
901 if (strcmp(value, DISCOVERY) && strcmp(value, NORMAL)) { in iscsi_check_string_or_list_value()
902 pr_err("Illegal value for \"%s\", must be" in iscsi_check_string_or_list_value()
903 " \"%s\" or \"%s\".\n", param->name, in iscsi_check_string_or_list_value()
905 return -1; in iscsi_check_string_or_list_value()
914 char *value) in iscsi_check_valuelist_for_support() argument
919 acceptor_values = param->value; in iscsi_check_valuelist_for_support()
920 proposer_values = value; in iscsi_check_valuelist_for_support()
928 acceptor_values = param->value; in iscsi_check_valuelist_for_support()
957 static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value, in iscsi_check_acceptor_state() argument
964 pr_err("Received key \"%s\" twice, protocol error.\n", in iscsi_check_acceptor_state()
965 param->name); in iscsi_check_acceptor_state()
966 return -1; in iscsi_check_acceptor_state()
973 if (!strcmp(value, YES)) in iscsi_check_acceptor_state()
975 if (!strcmp(param->value, YES)) in iscsi_check_acceptor_state()
981 return -1; in iscsi_check_acceptor_state()
986 if (!strcmp(value, YES)) in iscsi_check_acceptor_state()
988 if (!strcmp(param->value, YES)) in iscsi_check_acceptor_state()
992 return -1; in iscsi_check_acceptor_state()
998 u32 acceptor_value = simple_strtoul(param->value, &tmpptr, 0); in iscsi_check_acceptor_state()
999 u32 proposer_value = simple_strtoul(value, &tmpptr, 0); in iscsi_check_acceptor_state()
1003 if (!strcmp(param->name, MAXCONNECTIONS) || in iscsi_check_acceptor_state()
1004 !strcmp(param->name, MAXBURSTLENGTH) || in iscsi_check_acceptor_state()
1005 !strcmp(param->name, FIRSTBURSTLENGTH) || in iscsi_check_acceptor_state()
1006 !strcmp(param->name, MAXOUTSTANDINGR2T) || in iscsi_check_acceptor_state()
1007 !strcmp(param->name, DEFAULTTIME2RETAIN) || in iscsi_check_acceptor_state()
1008 !strcmp(param->name, ERRORRECOVERYLEVEL)) { in iscsi_check_acceptor_state()
1013 return -1; in iscsi_check_acceptor_state()
1015 if (iscsi_update_param_value(param, value) < 0) in iscsi_check_acceptor_state()
1016 return -1; in iscsi_check_acceptor_state()
1018 } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) { in iscsi_check_acceptor_state()
1023 return -1; in iscsi_check_acceptor_state()
1025 if (iscsi_update_param_value(param, value) < 0) in iscsi_check_acceptor_state()
1026 return -1; in iscsi_check_acceptor_state()
1029 if (iscsi_update_param_value(param, value) < 0) in iscsi_check_acceptor_state()
1030 return -1; in iscsi_check_acceptor_state()
1033 if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) { in iscsi_check_acceptor_state()
1038 rc = kstrtoull(param->value, 0, &tmp); in iscsi_check_acceptor_state()
1040 return -1; in iscsi_check_acceptor_state()
1042 conn->conn_ops->MaxRecvDataSegmentLength = tmp; in iscsi_check_acceptor_state()
1043 pr_debug("Saving op->MaxRecvDataSegmentLength from" in iscsi_check_acceptor_state()
1044 " original initiator received value: %u\n", in iscsi_check_acceptor_state()
1045 conn->conn_ops->MaxRecvDataSegmentLength); in iscsi_check_acceptor_state()
1049 conn->param_list); in iscsi_check_acceptor_state()
1051 return -1; in iscsi_check_acceptor_state()
1054 param_mxdsl->value); in iscsi_check_acceptor_state()
1056 return -1; in iscsi_check_acceptor_state()
1058 pr_debug("Updated %s to target MXDSL value: %s\n", in iscsi_check_acceptor_state()
1059 param->name, param->value); in iscsi_check_acceptor_state()
1063 param, value); in iscsi_check_acceptor_state()
1065 pr_err("Proposer's value list \"%s\" contains" in iscsi_check_acceptor_state()
1066 " no valid values from Acceptor's value list" in iscsi_check_acceptor_state()
1067 " \"%s\".\n", value, param->value); in iscsi_check_acceptor_state()
1068 return -1; in iscsi_check_acceptor_state()
1071 return -1; in iscsi_check_acceptor_state()
1073 if (iscsi_update_param_value(param, value) < 0) in iscsi_check_acceptor_state()
1074 return -1; in iscsi_check_acceptor_state()
1081 static int iscsi_check_proposer_state(struct iscsi_param *param, char *value) in iscsi_check_proposer_state() argument
1084 pr_err("Received key \"%s\" twice, protocol error.\n", in iscsi_check_proposer_state()
1085 param->name); in iscsi_check_proposer_state()
1086 return -1; in iscsi_check_proposer_state()
1092 comma_ptr = strchr(value, ','); in iscsi_check_proposer_state()
1095 param->name); in iscsi_check_proposer_state()
1096 return -1; in iscsi_check_proposer_state()
1099 tmp_ptr = iscsi_check_valuelist_for_support(param, value); in iscsi_check_proposer_state()
1101 return -1; in iscsi_check_proposer_state()
1104 if (iscsi_update_param_value(param, value) < 0) in iscsi_check_proposer_state()
1105 return -1; in iscsi_check_proposer_state()
1110 static int iscsi_check_value(struct iscsi_param *param, char *value) in iscsi_check_value() argument
1114 if (!strcmp(value, REJECT)) { in iscsi_check_value()
1115 if (!strcmp(param->name, IFMARKINT) || in iscsi_check_value()
1116 !strcmp(param->name, OFMARKINT)) { in iscsi_check_value()
1124 pr_err("Received %s=%s\n", param->name, value); in iscsi_check_value()
1125 return -1; in iscsi_check_value()
1127 if (!strcmp(value, IRRELEVANT)) { in iscsi_check_value()
1128 pr_debug("Received %s=%s\n", param->name, value); in iscsi_check_value()
1132 if (!strcmp(value, NOTUNDERSTOOD)) { in iscsi_check_value()
1135 param->name, value); in iscsi_check_value()
1136 return -1; in iscsi_check_value()
1139 /* #warning FIXME: Add check for X-ExtensionKey here */ in iscsi_check_value()
1140 pr_err("Standard iSCSI key \"%s\" cannot be answered" in iscsi_check_value()
1141 " with \"%s\", protocol error.\n", param->name, value); in iscsi_check_value()
1142 return -1; in iscsi_check_value()
1147 comma_ptr = strchr(value, ','); in iscsi_check_value()
1150 pr_err("Detected value separator \",\", but" in iscsi_check_value()
1151 " key \"%s\" does not allow a value list," in iscsi_check_value()
1152 " protocol error.\n", param->name); in iscsi_check_value()
1153 return -1; in iscsi_check_value()
1158 if (strlen(value) > VALUE_MAXLEN) { in iscsi_check_value()
1159 pr_err("Value for key \"%s\" exceeds %d," in iscsi_check_value()
1160 " protocol error.\n", param->name, in iscsi_check_value()
1162 return -1; in iscsi_check_value()
1166 if (iscsi_check_boolean_value(param, value) < 0) in iscsi_check_value()
1167 return -1; in iscsi_check_value()
1169 if (iscsi_check_numerical_value(param, value) < 0) in iscsi_check_value()
1170 return -1; in iscsi_check_value()
1172 if (iscsi_check_string_or_list_value(param, value) < 0) in iscsi_check_value()
1173 return -1; in iscsi_check_value()
1175 pr_err("Huh? 0x%02x\n", param->type); in iscsi_check_value()
1176 return -1; in iscsi_check_value()
1182 value = comma_ptr; in iscsi_check_value()
1183 } while (value); in iscsi_check_value()
1189 char *key, in __iscsi_check_key() argument
1195 if (strlen(key) > KEY_MAXLEN) { in __iscsi_check_key()
1196 pr_err("Length of key name \"%s\" exceeds %d.\n", in __iscsi_check_key()
1197 key, KEY_MAXLEN); in __iscsi_check_key()
1201 param = iscsi_find_param_from_key(key, param_list); in __iscsi_check_key()
1206 pr_err("Key \"%s\" may not be sent to %s," in __iscsi_check_key()
1207 " protocol error.\n", param->name, in __iscsi_check_key()
1213 pr_err("Key \"%s\" may not be sent to %s," in __iscsi_check_key()
1214 " protocol error.\n", param->name, in __iscsi_check_key()
1223 char *key, in iscsi_check_key() argument
1230 * Key name length must not exceed 63 bytes. (See iSCSI v20 5.1) in iscsi_check_key()
1232 if (strlen(key) > KEY_MAXLEN) { in iscsi_check_key()
1233 pr_err("Length of key name \"%s\" exceeds %d.\n", in iscsi_check_key()
1234 key, KEY_MAXLEN); in iscsi_check_key()
1238 param = iscsi_find_param_from_key(key, param_list); in iscsi_check_key()
1243 pr_err("Key \"%s\" may not be sent to %s," in iscsi_check_key()
1244 " protocol error.\n", param->name, in iscsi_check_key()
1249 pr_err("Key \"%s\" may not be sent to %s," in iscsi_check_key()
1250 " protocol error.\n", param->name, in iscsi_check_key()
1256 pr_err("Key \"%s\" received twice, protocol error.\n", in iscsi_check_key()
1257 key); in iscsi_check_key()
1264 if (!(param->phase & phase)) { in iscsi_check_key()
1277 pr_err("Key \"%s\" may not be negotiated during %s phase.\n", in iscsi_check_key()
1278 param->name, phase_name); in iscsi_check_key()
1295 list_for_each_entry(param, ¶m_list->param_list, p_list) { in iscsi_enforce_integrity_rules()
1296 if (!(param->phase & phase)) in iscsi_enforce_integrity_rules()
1298 if (!strcmp(param->name, SESSIONTYPE)) in iscsi_enforce_integrity_rules()
1299 if (!strcmp(param->value, NORMAL)) in iscsi_enforce_integrity_rules()
1301 if (!strcmp(param->name, ERRORRECOVERYLEVEL)) in iscsi_enforce_integrity_rules()
1302 ErrorRecoveryLevel = simple_strtoul(param->value, in iscsi_enforce_integrity_rules()
1304 if (!strcmp(param->name, DATASEQUENCEINORDER)) in iscsi_enforce_integrity_rules()
1305 if (!strcmp(param->value, YES)) in iscsi_enforce_integrity_rules()
1307 if (!strcmp(param->name, MAXBURSTLENGTH)) in iscsi_enforce_integrity_rules()
1308 MaxBurstLength = simple_strtoul(param->value, in iscsi_enforce_integrity_rules()
1312 list_for_each_entry(param, ¶m_list->param_list, p_list) { in iscsi_enforce_integrity_rules()
1313 if (!(param->phase & phase)) in iscsi_enforce_integrity_rules()
1317 if (!strcmp(param->name, MAXOUTSTANDINGR2T) && in iscsi_enforce_integrity_rules()
1319 if (strcmp(param->value, "1")) { in iscsi_enforce_integrity_rules()
1321 return -1; in iscsi_enforce_integrity_rules()
1323 param->name, param->value); in iscsi_enforce_integrity_rules()
1326 if (!strcmp(param->name, MAXCONNECTIONS) && !SessionType) { in iscsi_enforce_integrity_rules()
1327 if (strcmp(param->value, "1")) { in iscsi_enforce_integrity_rules()
1329 return -1; in iscsi_enforce_integrity_rules()
1331 param->name, param->value); in iscsi_enforce_integrity_rules()
1334 if (!strcmp(param->name, FIRSTBURSTLENGTH)) { in iscsi_enforce_integrity_rules()
1335 FirstBurstLength = simple_strtoul(param->value, in iscsi_enforce_integrity_rules()
1342 return -1; in iscsi_enforce_integrity_rules()
1344 param->name, param->value); in iscsi_enforce_integrity_rules()
1359 struct iscsi_param_list *param_list = conn->param_list; in iscsi_decode_text_input()
1365 return -ENOMEM; in iscsi_decode_text_input()
1372 char *key, *value; in iscsi_decode_text_input() local
1375 if (iscsi_extract_key_value(start, &key, &value) < 0) in iscsi_decode_text_input()
1378 pr_debug("Got key: %s=%s\n", key, value); in iscsi_decode_text_input()
1381 if (iscsi_check_for_auth_key(key) > 0) { in iscsi_decode_text_input()
1387 param = iscsi_check_key(key, phase, sender, param_list); in iscsi_decode_text_input()
1389 if (iscsi_add_notunderstood_response(key, value, in iscsi_decode_text_input()
1393 start += strlen(key) + strlen(value) + 2; in iscsi_decode_text_input()
1396 if (iscsi_check_value(param, value) < 0) in iscsi_decode_text_input()
1399 start += strlen(key) + strlen(value) + 2; in iscsi_decode_text_input()
1402 if (iscsi_check_proposer_state(param, value) < 0) in iscsi_decode_text_input()
1407 if (iscsi_check_acceptor_state(param, value, conn) < 0) in iscsi_decode_text_input()
1419 return -1; in iscsi_decode_text_input()
1437 return -1; in iscsi_encode_text_output()
1439 list_for_each_entry(param, ¶m_list->param_list, p_list) { in iscsi_encode_text_output()
1440 if (!(param->sender & sender)) in iscsi_encode_text_output()
1445 (param->phase & phase)) { in iscsi_encode_text_output()
1447 param->name, param->value); in iscsi_encode_text_output()
1451 pr_debug("Sending key: %s=%s\n", in iscsi_encode_text_output()
1452 param->name, param->value); in iscsi_encode_text_output()
1458 (param->phase & phase)) { in iscsi_encode_text_output()
1460 param->name, param->value); in iscsi_encode_text_output()
1466 pr_debug("Sending key: %s=%s\n", in iscsi_encode_text_output()
1467 param->name, param->value); in iscsi_encode_text_output()
1471 list_for_each_entry(er, ¶m_list->extra_response_list, er_list) { in iscsi_encode_text_output()
1472 *length += sprintf(output_buf, "%s=%s", er->key, er->value); in iscsi_encode_text_output()
1475 pr_debug("Sending key: %s=%s\n", er->key, er->value); in iscsi_encode_text_output()
1487 list_for_each_entry(param, ¶m_list->param_list, p_list) { in iscsi_check_negotiated_keys()
1493 pr_err("No response for proposed key \"%s\".\n", in iscsi_check_negotiated_keys()
1494 param->name); in iscsi_check_negotiated_keys()
1495 ret = -1; in iscsi_check_negotiated_keys()
1507 char *key = NULL, *value = NULL; in iscsi_change_param_value() local
1511 if (iscsi_extract_key_value(keyvalue, &key, &value) < 0) in iscsi_change_param_value()
1512 return -1; in iscsi_change_param_value()
1517 return -1; in iscsi_change_param_value()
1521 return -1; in iscsi_change_param_value()
1523 param->set_param = 1; in iscsi_change_param_value()
1524 if (iscsi_check_value(param, value) < 0) { in iscsi_change_param_value()
1525 param->set_param = 0; in iscsi_change_param_value()
1526 return -1; in iscsi_change_param_value()
1528 param->set_param = 0; in iscsi_change_param_value()
1531 if (iscsi_update_param_value(param, value) < 0) in iscsi_change_param_value()
1532 return -1; in iscsi_change_param_value()
1544 pr_debug("---------------------------------------------------" in iscsi_set_connection_parameters()
1545 "---------------\n"); in iscsi_set_connection_parameters()
1546 list_for_each_entry(param, ¶m_list->param_list, p_list) { in iscsi_set_connection_parameters()
1550 * this key is not sent over the wire. in iscsi_set_connection_parameters()
1552 if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) { in iscsi_set_connection_parameters()
1553 ops->MaxXmitDataSegmentLength = in iscsi_set_connection_parameters()
1554 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_connection_parameters()
1556 param->value); in iscsi_set_connection_parameters()
1561 if (!strcmp(param->name, AUTHMETHOD)) { in iscsi_set_connection_parameters()
1563 param->value); in iscsi_set_connection_parameters()
1564 } else if (!strcmp(param->name, HEADERDIGEST)) { in iscsi_set_connection_parameters()
1565 ops->HeaderDigest = !strcmp(param->value, CRC32C); in iscsi_set_connection_parameters()
1567 param->value); in iscsi_set_connection_parameters()
1568 } else if (!strcmp(param->name, DATADIGEST)) { in iscsi_set_connection_parameters()
1569 ops->DataDigest = !strcmp(param->value, CRC32C); in iscsi_set_connection_parameters()
1571 param->value); in iscsi_set_connection_parameters()
1572 } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) { in iscsi_set_connection_parameters()
1575 * set ops->MaxRecvDataSegmentLength from the original in iscsi_set_connection_parameters()
1576 * initiator provided value. in iscsi_set_connection_parameters()
1579 ops->MaxRecvDataSegmentLength); in iscsi_set_connection_parameters()
1580 } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) { in iscsi_set_connection_parameters()
1581 ops->InitiatorRecvDataSegmentLength = in iscsi_set_connection_parameters()
1582 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_connection_parameters()
1584 param->value); in iscsi_set_connection_parameters()
1585 ops->MaxRecvDataSegmentLength = in iscsi_set_connection_parameters()
1586 ops->InitiatorRecvDataSegmentLength; in iscsi_set_connection_parameters()
1588 } else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH)) { in iscsi_set_connection_parameters()
1589 ops->TargetRecvDataSegmentLength = in iscsi_set_connection_parameters()
1590 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_connection_parameters()
1592 param->value); in iscsi_set_connection_parameters()
1593 ops->MaxXmitDataSegmentLength = in iscsi_set_connection_parameters()
1594 ops->TargetRecvDataSegmentLength; in iscsi_set_connection_parameters()
1598 pr_debug("----------------------------------------------------" in iscsi_set_connection_parameters()
1599 "--------------\n"); in iscsi_set_connection_parameters()
1610 pr_debug("----------------------------------------------------" in iscsi_set_session_parameters()
1611 "--------------\n"); in iscsi_set_session_parameters()
1612 list_for_each_entry(param, ¶m_list->param_list, p_list) { in iscsi_set_session_parameters()
1615 if (!strcmp(param->name, INITIATORNAME)) { in iscsi_set_session_parameters()
1616 if (!param->value) in iscsi_set_session_parameters()
1619 snprintf(ops->InitiatorName, in iscsi_set_session_parameters()
1620 sizeof(ops->InitiatorName), in iscsi_set_session_parameters()
1621 "%s", param->value); in iscsi_set_session_parameters()
1623 param->value); in iscsi_set_session_parameters()
1624 } else if (!strcmp(param->name, INITIATORALIAS)) { in iscsi_set_session_parameters()
1625 if (!param->value) in iscsi_set_session_parameters()
1627 snprintf(ops->InitiatorAlias, in iscsi_set_session_parameters()
1628 sizeof(ops->InitiatorAlias), in iscsi_set_session_parameters()
1629 "%s", param->value); in iscsi_set_session_parameters()
1631 param->value); in iscsi_set_session_parameters()
1632 } else if (!strcmp(param->name, TARGETNAME)) { in iscsi_set_session_parameters()
1633 if (!param->value) in iscsi_set_session_parameters()
1636 snprintf(ops->TargetName, in iscsi_set_session_parameters()
1637 sizeof(ops->TargetName), in iscsi_set_session_parameters()
1638 "%s", param->value); in iscsi_set_session_parameters()
1640 param->value); in iscsi_set_session_parameters()
1641 } else if (!strcmp(param->name, TARGETALIAS)) { in iscsi_set_session_parameters()
1642 if (!param->value) in iscsi_set_session_parameters()
1644 snprintf(ops->TargetAlias, sizeof(ops->TargetAlias), in iscsi_set_session_parameters()
1645 "%s", param->value); in iscsi_set_session_parameters()
1647 param->value); in iscsi_set_session_parameters()
1648 } else if (!strcmp(param->name, TARGETPORTALGROUPTAG)) { in iscsi_set_session_parameters()
1649 ops->TargetPortalGroupTag = in iscsi_set_session_parameters()
1650 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_session_parameters()
1652 param->value); in iscsi_set_session_parameters()
1653 } else if (!strcmp(param->name, MAXCONNECTIONS)) { in iscsi_set_session_parameters()
1654 ops->MaxConnections = in iscsi_set_session_parameters()
1655 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_session_parameters()
1657 param->value); in iscsi_set_session_parameters()
1658 } else if (!strcmp(param->name, INITIALR2T)) { in iscsi_set_session_parameters()
1659 ops->InitialR2T = !strcmp(param->value, YES); in iscsi_set_session_parameters()
1661 param->value); in iscsi_set_session_parameters()
1662 } else if (!strcmp(param->name, IMMEDIATEDATA)) { in iscsi_set_session_parameters()
1663 ops->ImmediateData = !strcmp(param->value, YES); in iscsi_set_session_parameters()
1665 param->value); in iscsi_set_session_parameters()
1666 } else if (!strcmp(param->name, MAXBURSTLENGTH)) { in iscsi_set_session_parameters()
1667 ops->MaxBurstLength = in iscsi_set_session_parameters()
1668 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_session_parameters()
1670 param->value); in iscsi_set_session_parameters()
1671 } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) { in iscsi_set_session_parameters()
1672 ops->FirstBurstLength = in iscsi_set_session_parameters()
1673 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_session_parameters()
1675 param->value); in iscsi_set_session_parameters()
1676 } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) { in iscsi_set_session_parameters()
1677 ops->DefaultTime2Wait = in iscsi_set_session_parameters()
1678 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_session_parameters()
1680 param->value); in iscsi_set_session_parameters()
1681 } else if (!strcmp(param->name, DEFAULTTIME2RETAIN)) { in iscsi_set_session_parameters()
1682 ops->DefaultTime2Retain = in iscsi_set_session_parameters()
1683 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_session_parameters()
1685 param->value); in iscsi_set_session_parameters()
1686 } else if (!strcmp(param->name, MAXOUTSTANDINGR2T)) { in iscsi_set_session_parameters()
1687 ops->MaxOutstandingR2T = in iscsi_set_session_parameters()
1688 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_session_parameters()
1690 param->value); in iscsi_set_session_parameters()
1691 } else if (!strcmp(param->name, DATAPDUINORDER)) { in iscsi_set_session_parameters()
1692 ops->DataPDUInOrder = !strcmp(param->value, YES); in iscsi_set_session_parameters()
1694 param->value); in iscsi_set_session_parameters()
1695 } else if (!strcmp(param->name, DATASEQUENCEINORDER)) { in iscsi_set_session_parameters()
1696 ops->DataSequenceInOrder = !strcmp(param->value, YES); in iscsi_set_session_parameters()
1698 param->value); in iscsi_set_session_parameters()
1699 } else if (!strcmp(param->name, ERRORRECOVERYLEVEL)) { in iscsi_set_session_parameters()
1700 ops->ErrorRecoveryLevel = in iscsi_set_session_parameters()
1701 simple_strtoul(param->value, &tmpptr, 0); in iscsi_set_session_parameters()
1703 param->value); in iscsi_set_session_parameters()
1704 } else if (!strcmp(param->name, SESSIONTYPE)) { in iscsi_set_session_parameters()
1705 ops->SessionType = !strcmp(param->value, DISCOVERY); in iscsi_set_session_parameters()
1707 param->value); in iscsi_set_session_parameters()
1708 } else if (!strcmp(param->name, RDMAEXTENSIONS)) { in iscsi_set_session_parameters()
1709 ops->RDMAExtensions = !strcmp(param->value, YES); in iscsi_set_session_parameters()
1711 param->value); in iscsi_set_session_parameters()
1714 pr_debug("----------------------------------------------------" in iscsi_set_session_parameters()
1715 "--------------\n"); in iscsi_set_session_parameters()