Lines Matching +full:p +full:- +full:states

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
60 TAILQ_INIT(&conf->conf_targets); in conf_new()
70 TAILQ_FOREACH(targ, &conf->conf_targets, t_next) { in target_find()
71 if (targ->t_nickname != NULL && in target_find()
72 strcasecmp(targ->t_nickname, nickname) == 0) in target_find()
87 targ->t_conf = conf; in target_new()
88 targ->t_dscp = -1; in target_new()
89 targ->t_pcp = -1; in target_new()
90 targ->t_pingtimeout = -1; in target_new()
91 targ->t_logintimeout = -1; in target_new()
92 TAILQ_INSERT_TAIL(&conf->conf_targets, targ, t_next); in target_new()
101 TAILQ_REMOVE(&targ->t_conf->conf_targets, targ, t_next); in target_delete()
119 namelen - strlen(DEFAULT_IQN)); in default_initiator_name()
148 TAILQ_FOREACH(targ, &conf->conf_targets, t_next) { in conf_verify()
149 assert(targ->t_nickname != NULL); in conf_verify()
150 if (targ->t_session_type == SESSION_TYPE_UNSPECIFIED) in conf_verify()
151 targ->t_session_type = SESSION_TYPE_NORMAL; in conf_verify()
152 if (targ->t_session_type == SESSION_TYPE_NORMAL && in conf_verify()
153 targ->t_name == NULL) in conf_verify()
155 targ->t_nickname); in conf_verify()
156 if (targ->t_session_type == SESSION_TYPE_DISCOVERY && in conf_verify()
157 targ->t_name != NULL) in conf_verify()
159 "sessions for target \"%s\"", targ->t_nickname); in conf_verify()
160 if (targ->t_name != NULL) { in conf_verify()
161 if (valid_iscsi_name(targ->t_name, xo_warnx) == false) in conf_verify()
163 targ->t_name); in conf_verify()
165 if (targ->t_protocol == PROTOCOL_UNSPECIFIED) in conf_verify()
166 targ->t_protocol = PROTOCOL_ISCSI; in conf_verify()
167 if (targ->t_address == NULL) in conf_verify()
169 targ->t_nickname); in conf_verify()
170 if (targ->t_initiator_name == NULL) in conf_verify()
171 targ->t_initiator_name = default_initiator_name(); in conf_verify()
172 if (valid_iscsi_name(targ->t_initiator_name, xo_warnx) == false) in conf_verify()
174 targ->t_initiator_name); in conf_verify()
175 if (targ->t_header_digest == DIGEST_UNSPECIFIED) in conf_verify()
176 targ->t_header_digest = DIGEST_NONE; in conf_verify()
177 if (targ->t_data_digest == DIGEST_UNSPECIFIED) in conf_verify()
178 targ->t_data_digest = DIGEST_NONE; in conf_verify()
179 if (targ->t_auth_method == AUTH_METHOD_UNSPECIFIED) { in conf_verify()
180 if (targ->t_user != NULL || targ->t_secret != NULL || in conf_verify()
181 targ->t_mutual_user != NULL || in conf_verify()
182 targ->t_mutual_secret != NULL) in conf_verify()
183 targ->t_auth_method = in conf_verify()
186 targ->t_auth_method = in conf_verify()
189 if (targ->t_auth_method == AUTH_METHOD_CHAP) { in conf_verify()
190 if (targ->t_user == NULL) { in conf_verify()
192 targ->t_nickname); in conf_verify()
194 if (targ->t_secret == NULL) in conf_verify()
196 targ->t_nickname); in conf_verify()
197 if (targ->t_mutual_user != NULL || in conf_verify()
198 targ->t_mutual_secret != NULL) { in conf_verify()
199 if (targ->t_mutual_user == NULL) in conf_verify()
201 "target \"%s\"", targ->t_nickname); in conf_verify()
202 if (targ->t_mutual_secret == NULL) in conf_verify()
204 "target \"%s\"", targ->t_nickname); in conf_verify()
219 if (targ->t_initiator_name != NULL) in conf_from_target()
220 strlcpy(conf->isc_initiator, targ->t_initiator_name, in conf_from_target()
221 sizeof(conf->isc_initiator)); in conf_from_target()
222 if (targ->t_initiator_address != NULL) in conf_from_target()
223 strlcpy(conf->isc_initiator_addr, targ->t_initiator_address, in conf_from_target()
224 sizeof(conf->isc_initiator_addr)); in conf_from_target()
225 if (targ->t_initiator_alias != NULL) in conf_from_target()
226 strlcpy(conf->isc_initiator_alias, targ->t_initiator_alias, in conf_from_target()
227 sizeof(conf->isc_initiator_alias)); in conf_from_target()
228 if (targ->t_name != NULL) in conf_from_target()
229 strlcpy(conf->isc_target, targ->t_name, in conf_from_target()
230 sizeof(conf->isc_target)); in conf_from_target()
231 if (targ->t_address != NULL) in conf_from_target()
232 strlcpy(conf->isc_target_addr, targ->t_address, in conf_from_target()
233 sizeof(conf->isc_target_addr)); in conf_from_target()
234 if (targ->t_user != NULL) in conf_from_target()
235 strlcpy(conf->isc_user, targ->t_user, in conf_from_target()
236 sizeof(conf->isc_user)); in conf_from_target()
237 if (targ->t_secret != NULL) in conf_from_target()
238 strlcpy(conf->isc_secret, targ->t_secret, in conf_from_target()
239 sizeof(conf->isc_secret)); in conf_from_target()
240 if (targ->t_mutual_user != NULL) in conf_from_target()
241 strlcpy(conf->isc_mutual_user, targ->t_mutual_user, in conf_from_target()
242 sizeof(conf->isc_mutual_user)); in conf_from_target()
243 if (targ->t_mutual_secret != NULL) in conf_from_target()
244 strlcpy(conf->isc_mutual_secret, targ->t_mutual_secret, in conf_from_target()
245 sizeof(conf->isc_mutual_secret)); in conf_from_target()
246 if (targ->t_session_type == SESSION_TYPE_DISCOVERY) in conf_from_target()
247 conf->isc_discovery = 1; in conf_from_target()
248 if (targ->t_enable != ENABLE_OFF) in conf_from_target()
249 conf->isc_enable = 1; in conf_from_target()
250 if (targ->t_protocol == PROTOCOL_ISER) in conf_from_target()
251 conf->isc_iser = 1; in conf_from_target()
252 if (targ->t_offload != NULL) in conf_from_target()
253 strlcpy(conf->isc_offload, targ->t_offload, in conf_from_target()
254 sizeof(conf->isc_offload)); in conf_from_target()
255 if (targ->t_header_digest == DIGEST_CRC32C) in conf_from_target()
256 conf->isc_header_digest = ISCSI_DIGEST_CRC32C; in conf_from_target()
258 conf->isc_header_digest = ISCSI_DIGEST_NONE; in conf_from_target()
259 if (targ->t_data_digest == DIGEST_CRC32C) in conf_from_target()
260 conf->isc_data_digest = ISCSI_DIGEST_CRC32C; in conf_from_target()
262 conf->isc_data_digest = ISCSI_DIGEST_NONE; in conf_from_target()
263 conf->isc_dscp = targ->t_dscp; in conf_from_target()
264 conf->isc_pcp = targ->t_pcp; in conf_from_target()
265 conf->isc_ping_timeout = targ->t_pingtimeout; in conf_from_target()
266 conf->isc_login_timeout = targ->t_logintimeout; in conf_from_target()
302 struct iscsi_session_state *states = NULL; in kernel_modify_some() local
311 states = realloc(states, in kernel_modify_some()
313 if (states == NULL) in kernel_modify_some()
318 isl.isl_pstates = states; in kernel_modify_some()
331 state = &states[i]; in kernel_modify_some()
333 if (state->iss_id == session_id) in kernel_modify_some()
337 xo_errx(1, "session-id %u not found", session_id); in kernel_modify_some()
339 conf = &state->iss_conf; in kernel_modify_some()
342 strlcpy(conf->isc_target, target, sizeof(conf->isc_target)); in kernel_modify_some()
344 strlcpy(conf->isc_target_addr, target_addr, in kernel_modify_some()
345 sizeof(conf->isc_target_addr)); in kernel_modify_some()
347 strlcpy(conf->isc_user, user, sizeof(conf->isc_user)); in kernel_modify_some()
349 strlcpy(conf->isc_secret, secret, sizeof(conf->isc_secret)); in kernel_modify_some()
351 conf->isc_enable = 1; in kernel_modify_some()
353 conf->isc_enable = 0; in kernel_modify_some()
384 struct iscsi_session_state *states = NULL; in kernel_list() local
392 states = realloc(states, in kernel_list()
394 if (states == NULL) in kernel_list()
399 isl.isl_pstates = states; in kernel_list()
416 state = &states[i]; in kernel_list()
417 conf = &state->iss_conf; in kernel_list()
422 * Display-only modifier as this information in kernel_list()
425 xo_emit("{L:/%-26s}{V:sessionId/%u}\n", in kernel_list()
426 "Session ID:", state->iss_id); in kernel_list()
429 xo_emit("{L:/%-26s}{V:name/%s}\n", in kernel_list()
430 "Initiator name:", conf->isc_initiator); in kernel_list()
431 xo_emit("{L:/%-26s}{V:portal/%s}\n", in kernel_list()
432 "Initiator portal:", conf->isc_initiator_addr); in kernel_list()
433 xo_emit("{L:/%-26s}{V:alias/%s}\n", in kernel_list()
434 "Initiator alias:", conf->isc_initiator_alias); in kernel_list()
438 xo_emit("{L:/%-26s}{V:name/%s}\n", in kernel_list()
439 "Target name:", conf->isc_target); in kernel_list()
440 xo_emit("{L:/%-26s}{V:portal/%s}\n", in kernel_list()
441 "Target portal:", conf->isc_target_addr); in kernel_list()
442 xo_emit("{L:/%-26s}{V:alias/%s}\n", in kernel_list()
443 "Target alias:", state->iss_target_alias); in kernel_list()
444 if (conf->isc_dscp != -1) in kernel_list()
445 xo_emit("{L:/%-26s}{V:dscp/0x%02x}\n", in kernel_list()
446 "Target DSCP:", conf->isc_dscp); in kernel_list()
447 if (conf->isc_pcp != -1) in kernel_list()
448 xo_emit("{L:/%-26s}{V:pcp/0x%02x}\n", in kernel_list()
449 "Target PCP:", conf->isc_pcp); in kernel_list()
450 if (conf->isc_ping_timeout != -1) in kernel_list()
451 xo_emit("{L:/%-26s}{V:PingTimeout/%d}\n", in kernel_list()
453 conf->isc_ping_timeout); in kernel_list()
454 if (conf->isc_login_timeout != -1) in kernel_list()
455 xo_emit("{L:/%-26s}{V:LoginTimeout/%d}\n", in kernel_list()
457 conf->isc_login_timeout); in kernel_list()
461 xo_emit("{L:/%-26s}{V:user/%s}\n", in kernel_list()
462 "User:", conf->isc_user); in kernel_list()
463 xo_emit("{L:/%-26s}{V:secret/%s}\n", in kernel_list()
464 "Secret:", conf->isc_secret); in kernel_list()
465 xo_emit("{L:/%-26s}{V:mutualUser/%s}\n", in kernel_list()
466 "Mutual user:", conf->isc_mutual_user); in kernel_list()
467 xo_emit("{L:/%-26s}{V:mutualSecret/%s}\n", in kernel_list()
468 "Mutual secret:", conf->isc_mutual_secret); in kernel_list()
471 xo_emit("{L:/%-26s}{V:type/%s}\n", in kernel_list()
473 conf->isc_discovery ? "Discovery" : "Normal"); in kernel_list()
474 xo_emit("{L:/%-26s}{V:enable/%s}\n", in kernel_list()
476 conf->isc_enable ? "Yes" : "No"); in kernel_list()
477 xo_emit("{L:/%-26s}{V:state/%s}\n", in kernel_list()
479 state->iss_connected ? "Connected" : "Disconnected"); in kernel_list()
480 xo_emit("{L:/%-26s}{V:failureReason/%s}\n", in kernel_list()
481 "Failure reason:", state->iss_reason); in kernel_list()
482 xo_emit("{L:/%-26s}{V:headerDigest/%s}\n", in kernel_list()
484 state->iss_header_digest == ISCSI_DIGEST_CRC32C ? in kernel_list()
486 xo_emit("{L:/%-26s}{V:dataDigest/%s}\n", in kernel_list()
488 state->iss_data_digest == ISCSI_DIGEST_CRC32C ? in kernel_list()
490 xo_emit("{L:/%-26s}{V:recvDataSegmentLen/%d}\n", in kernel_list()
492 state->iss_max_recv_data_segment_length); in kernel_list()
493 xo_emit("{L:/%-26s}{V:sendDataSegmentLen/%d}\n", in kernel_list()
495 state->iss_max_send_data_segment_length); in kernel_list()
496 xo_emit("{L:/%-26s}{V:maxBurstLen/%d}\n", in kernel_list()
497 "MaxBurstLen:", state->iss_max_burst_length); in kernel_list()
498 xo_emit("{L:/%-26s}{V:firstBurstLen/%d}\n", in kernel_list()
499 "FirstBurstLen:", state->iss_first_burst_length); in kernel_list()
500 xo_emit("{L:/%-26s}{V:immediateData/%s}\n", in kernel_list()
501 "ImmediateData:", state->iss_immediate_data ? "Yes" : "No"); in kernel_list()
502 xo_emit("{L:/%-26s}{V:iSER/%s}\n", in kernel_list()
503 "iSER (RDMA):", conf->isc_iser ? "Yes" : "No"); in kernel_list()
504 xo_emit("{L:/%-26s}{V:offloadDriver/%s}\n", in kernel_list()
505 "Offload driver:", state->iss_offload); in kernel_list()
506 xo_emit("{L:/%-26s}", in kernel_list()
508 print_periphs(state->iss_id); in kernel_list()
514 xo_emit("{T:/%-36s} {T:/%-16s} {T:/%s}\n", in kernel_list()
521 state = &states[i]; in kernel_list()
522 conf = &state->iss_conf; in kernel_list()
525 xo_emit("{V:name/%-36s/%s} {V:portal/%-16s/%s} ", in kernel_list()
526 conf->isc_target, conf->isc_target_addr); in kernel_list()
528 if (state->iss_reason[0] != '\0' && in kernel_list()
529 conf->isc_enable != 0) { in kernel_list()
530 xo_emit("{V:state/%s}\n", state->iss_reason); in kernel_list()
532 if (conf->isc_discovery) { in kernel_list()
534 } else if (conf->isc_enable == 0) { in kernel_list()
536 } else if (state->iss_connected) { in kernel_list()
538 print_periphs(state->iss_id); in kernel_list()
556 struct iscsi_session_state *states = NULL; in kernel_wait() local
565 states = realloc(states, in kernel_wait()
567 if (states == NULL) in kernel_wait()
572 isl.isl_pstates = states; in kernel_wait()
588 state = &states[i]; in kernel_wait()
590 if (!state->iss_connected) { in kernel_wait()
602 timeout--; in kernel_wait()
613 xo_error("usage: iscsictl -A -p portal -t target " in usage()
614 "[-u user -s secret] [-w timeout] [-e on | off]\n"); in usage()
615 xo_error(" iscsictl -A -d discovery-host " in usage()
616 "[-u user -s secret] [-e on | off]\n"); in usage()
617 xo_error(" iscsictl -A -a [-c path]\n"); in usage()
618 xo_error(" iscsictl -A -n nickname [-c path]\n"); in usage()
619 xo_error(" iscsictl -M -i session-id [-p portal] " in usage()
620 "[-t target] [-u user] [-s secret] [-e on | off]\n"); in usage()
621 xo_error(" iscsictl -M -i session-id -n nickname " in usage()
622 "[-c path]\n"); in usage()
623 xo_error(" iscsictl -R [-p portal] [-t target]\n"); in usage()
624 xo_error(" iscsictl -R -a\n"); in usage()
625 xo_error(" iscsictl -R -n nickname [-c path]\n"); in usage()
626 xo_error(" iscsictl -L [-v] [-w timeout]\n"); in usage()
638 int timeout = -1, enable = ENABLE_UNSPECIFIED; in main()
639 long long session_id = -1; in main()
653 while ((ch = getopt(argc, argv, "AMRLac:d:e:i:n:p:rt:u:s:vw:")) != -1) { in main()
679 xo_errx(1, "invalid argument to -e, " in main()
685 if ((size_t)(end - optarg) != strlen(optarg)) in main()
686 xo_errx(1, "trailing characters after session-id"); in main()
688 xo_errx(1, "session-id cannot be negative"); in main()
690 xo_errx(1, "session-id cannot be greater than %u", in main()
696 case 'p': in main()
716 if ((size_t)(end - optarg) != strlen(optarg)) in main()
726 argc -= optind; in main()
733 xo_errx(1, "at most one of -A, -M, -R, or -L may be specified"); in main()
736 * Note that we ignore unnecessary/inapplicable "-c" flag; so that in main()
737 * people can do something like "alias ISCSICTL="iscsictl -c path" in main()
743 xo_errx(1, "-a and -e are mutually exclusive"); in main()
745 xo_errx(1, "-a and -p are mutually exclusive"); in main()
747 xo_errx(1, "-a and -t are mutually exclusive"); in main()
749 xo_errx(1, "-a and -u are mutually exclusive"); in main()
751 xo_errx(1, "-a and -s are mutually exclusive"); in main()
753 xo_errx(1, "-a and -n are mutually exclusive"); in main()
755 xo_errx(1, "-a and -d are mutually exclusive"); in main()
757 xo_errx(1, "-a and -r are mutually exclusive"); in main()
760 xo_errx(1, "-n and -e are mutually exclusive"); in main()
762 xo_errx(1, "-n and -p are mutually exclusive"); in main()
764 xo_errx(1, "-n and -t are mutually exclusive"); in main()
766 xo_errx(1, "-n and -u are mutually exclusive"); in main()
768 xo_errx(1, "-n and -s are mutually exclusive"); in main()
770 xo_errx(1, "-n and -d are mutually exclusive"); in main()
772 xo_errx(1, "-n and -r are mutually exclusive"); in main()
775 xo_errx(1, "-d and -p are mutually exclusive"); in main()
777 xo_errx(1, "-d and -t are mutually exclusive"); in main()
780 xo_errx(1, "must specify -a, -n or -t/-p"); in main()
783 xo_errx(1, "-t must always be used with -p"); in main()
785 xo_errx(1, "-p must always be used with -t"); in main()
789 xo_errx(1, "-u must always be used with -s"); in main()
791 xo_errx(1, "-s must always be used with -u"); in main()
793 if (session_id != -1) in main()
794 xo_errx(1, "-i cannot be used with -A"); in main()
796 xo_errx(1, "-v cannot be used with -A"); in main()
799 if (session_id == -1) in main()
800 xo_errx(1, "-M requires -i"); in main()
804 xo_errx(1, "-n and -e are mutually exclusive"); in main()
806 xo_errx(1, "-n and -p are mutually exclusive"); in main()
808 xo_errx(1, "-n and -t are mutually exclusive"); in main()
810 xo_errx(1, "-n and -u are mutually exclusive"); in main()
812 xo_errx(1, "-n and -s are mutually exclusive"); in main()
816 xo_errx(1, "-a cannot be used with -M"); in main()
818 xo_errx(1, "-d cannot be used with -M"); in main()
820 xo_errx(1, "-r cannot be used with -M"); in main()
822 xo_errx(1, "-v cannot be used with -M"); in main()
823 if (timeout != -1) in main()
824 xo_errx(1, "-w cannot be used with -M"); in main()
829 xo_errx(1, "-a and -p are mutually exclusive"); in main()
831 xo_errx(1, "-a and -t are mutually exclusive"); in main()
833 xo_errx(1, "-a and -n are mutually exclusive"); in main()
836 xo_errx(1, "-n and -p are mutually exclusive"); in main()
838 xo_errx(1, "-n and -t are mutually exclusive"); in main()
840 xo_errx(1, "must specify either -a, -n, -t, or -p"); in main()
844 xo_errx(1, "-d cannot be used with -R"); in main()
846 xo_errx(1, "-e cannot be used with -R"); in main()
847 if (session_id != -1) in main()
848 xo_errx(1, "-i cannot be used with -R"); in main()
850 xo_errx(1, "-r cannot be used with -R"); in main()
852 xo_errx(1, "-u cannot be used with -R"); in main()
854 xo_errx(1, "-s cannot be used with -R"); in main()
856 xo_errx(1, "-v cannot be used with -R"); in main()
857 if (timeout != -1) in main()
858 xo_errx(1, "-w cannot be used with -R"); in main()
864 xo_errx(1, "-d cannot be used with -L"); in main()
865 if (session_id != -1) in main()
866 xo_errx(1, "-i cannot be used with -L"); in main()
868 xo_errx(1, "-n cannot be used with -L"); in main()
870 xo_errx(1, "-p cannot be used with -L"); in main()
872 xo_errx(1, "-r cannot be used with -L"); in main()
874 xo_errx(1, "-t cannot be used with -L"); in main()
876 xo_errx(1, "-u cannot be used with -L"); in main()
878 xo_errx(1, "-s cannot be used with -L"); in main()
885 if (retval != -1) in main()
896 TAILQ_FOREACH(targ, &conf->conf_targets, t_next) in main()
923 targ->t_initiator_name = default_initiator_name(); in main()
924 targ->t_header_digest = DIGEST_NONE; in main()
925 targ->t_data_digest = DIGEST_NONE; in main()
926 targ->t_name = target; in main()
928 targ->t_session_type = SESSION_TYPE_DISCOVERY; in main()
929 targ->t_address = discovery_host; in main()
931 targ->t_session_type = SESSION_TYPE_NORMAL; in main()
932 targ->t_address = portal; in main()
934 targ->t_enable = enable; in main()
936 targ->t_protocol = PROTOCOL_ISER; in main()
937 targ->t_user = user; in main()
938 targ->t_secret = secret; in main()
948 if (timeout != -1) in main()