Browse Source

Use debug auto-colourisation.

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
6ea07b9247
1 changed files with 47 additions and 42 deletions
  1. 47
    42
      src/net/tcp/iscsi.c

+ 47
- 42
src/net/tcp/iscsi.c View File

164
 	command->cmdsn = htonl ( iscsi->cmdsn );
164
 	command->cmdsn = htonl ( iscsi->cmdsn );
165
 	command->expstatsn = htonl ( iscsi->statsn + 1 );
165
 	command->expstatsn = htonl ( iscsi->statsn + 1 );
166
 	memcpy ( &command->cdb, &iscsi->command->cdb, sizeof ( command->cdb ));
166
 	memcpy ( &command->cdb, &iscsi->command->cdb, sizeof ( command->cdb ));
167
-	DBG ( "iSCSI %p start " SCSI_CDB_FORMAT " %s %#x\n",
168
-	      iscsi, SCSI_CDB_DATA ( command->cdb ),
169
-	      ( iscsi->command->data_in ? "in" : "out" ),
170
-	      ( iscsi->command->data_in ?
171
-		iscsi->command->data_in_len : iscsi->command->data_out_len ) );
167
+	DBGC ( iscsi, "iSCSI %p start " SCSI_CDB_FORMAT " %s %#x\n",
168
+	       iscsi, SCSI_CDB_DATA ( command->cdb ),
169
+	       ( iscsi->command->data_in ? "in" : "out" ),
170
+	       ( iscsi->command->data_in ?
171
+		 iscsi->command->data_in_len : iscsi->command->data_out_len ));
172
 }
172
 }
173
 
173
 
174
 /**
174
 /**
296
 	data_out->expstatsn = htonl ( iscsi->statsn + 1 );
296
 	data_out->expstatsn = htonl ( iscsi->statsn + 1 );
297
 	data_out->datasn = htonl ( datasn );
297
 	data_out->datasn = htonl ( datasn );
298
 	data_out->offset = htonl ( iscsi->transfer_offset + offset );
298
 	data_out->offset = htonl ( iscsi->transfer_offset + offset );
299
-	DBG ( "iSCSI %p start data out DataSN %#x len %#lx\n",
300
-	      iscsi, datasn, len );
299
+	DBGC ( iscsi, "iSCSI %p start data out DataSN %#x len %#lx\n",
300
+	       iscsi, datasn, len );
301
 }
301
 }
302
 
302
 
303
 /**
303
 /**
525
 	struct sockaddr_in *sin = ( struct sockaddr_in * ) &iscsi->target;
525
 	struct sockaddr_in *sin = ( struct sockaddr_in * ) &iscsi->target;
526
 
526
 
527
 	if ( inet_aton ( value, &address ) == 0 ) {
527
 	if ( inet_aton ( value, &address ) == 0 ) {
528
-		DBG ( "iSCSI %p received invalid TargetAddress \"%s\"\n",
529
-		      iscsi, value );
528
+		DBGC ( iscsi, "iSCSI %p received invalid TargetAddress "
529
+		       "\"%s\"\n", iscsi, value );
530
 		return;
530
 		return;
531
 	}
531
 	}
532
 
532
 
533
-	DBG ( "iSCSI %p will redirect to %s\n", iscsi, value );
533
+	DBGC ( iscsi, "iSCSI %p will redirect to %s\n", iscsi, value );
534
 	sin->sin_addr = address;
534
 	sin->sin_addr = address;
535
 }
535
 }
536
 
536
 
545
 
545
 
546
 	/* If server requests CHAP, send the CHAP_A string */
546
 	/* If server requests CHAP, send the CHAP_A string */
547
 	if ( strcmp ( value, "CHAP" ) == 0 ) {
547
 	if ( strcmp ( value, "CHAP" ) == 0 ) {
548
-		DBG ( "iSCSI %p initiating CHAP authentication\n", iscsi );
548
+		DBGC ( iscsi, "iSCSI %p initiating CHAP authentication\n",
549
+		       iscsi );
549
 		iscsi->status |= ISCSI_STATUS_STRINGS_CHAP_ALGORITHM;
550
 		iscsi->status |= ISCSI_STATUS_STRINGS_CHAP_ALGORITHM;
550
 	}
551
 	}
551
 }
552
 }
565
 	 * violation.
566
 	 * violation.
566
 	 */
567
 	 */
567
 	if ( strcmp ( value, "5" ) != 0 ) {
568
 	if ( strcmp ( value, "5" ) != 0 ) {
568
-		DBG ( "iSCSI %p got invalid CHAP algorithm \"%s\"\n",
569
-		      iscsi, value );
569
+		DBGC ( iscsi, "iSCSI %p got invalid CHAP algorithm \"%s\"\n",
570
+		       iscsi, value );
570
 	}
571
 	}
571
 
572
 
572
 	/* Prepare for CHAP with MD5 */
573
 	/* Prepare for CHAP with MD5 */
573
 	if ( ( rc = chap_init ( &iscsi->chap, &md5_algorithm ) ) != 0 ) {
574
 	if ( ( rc = chap_init ( &iscsi->chap, &md5_algorithm ) ) != 0 ) {
574
-		DBG ( "iSCSI %p could not initialise CHAP\n", iscsi );
575
+		DBGC ( iscsi, "iSCSI %p could not initialise CHAP: %s\n",
576
+		       iscsi, strerror ( rc ) );
575
 		iscsi_close ( iscsi );
577
 		iscsi_close ( iscsi );
576
 		iscsi_done ( iscsi, rc );
578
 		iscsi_done ( iscsi, rc );
577
 	}
579
 	}
591
 	/* The CHAP identifier is an integer value */
593
 	/* The CHAP identifier is an integer value */
592
 	identifier = strtoul ( value, &endp, 0 );
594
 	identifier = strtoul ( value, &endp, 0 );
593
 	if ( *endp != '\0' ) {
595
 	if ( *endp != '\0' ) {
594
-		DBG ( "iSCSI %p saw invalid CHAP identifier \"%s\"\n",
595
-		      iscsi, value );
596
+		DBGC ( iscsi, "iSCSI %p saw invalid CHAP identifier \"%s\"\n",
597
+		       iscsi, value );
596
 	}
598
 	}
597
 
599
 
598
 	/* Identifier and secret are the first two components of the
600
 	/* Identifier and secret are the first two components of the
619
 
621
 
620
 	/* Check and strip leading "0x" */
622
 	/* Check and strip leading "0x" */
621
 	if ( ( value[0] != '0' ) || ( value[1] != 'x' ) ) {
623
 	if ( ( value[0] != '0' ) || ( value[1] != 'x' ) ) {
622
-		DBG ( "iSCSI %p saw invalid CHAP challenge \"%s\"\n",
623
-		      iscsi, value );
624
+		DBGC ( iscsi, "iSCSI %p saw invalid CHAP challenge \"%s\"\n",
625
+		       iscsi, value );
624
 	}
626
 	}
625
 	value += 2;
627
 	value += 2;
626
 
628
 
630
 		buf[3] = 0;
632
 		buf[3] = 0;
631
 		byte = strtoul ( buf, &endp, 16 );
633
 		byte = strtoul ( buf, &endp, 16 );
632
 		if ( *endp != '\0' ) {
634
 		if ( *endp != '\0' ) {
633
-			DBG ( "iSCSI %p saw invalid CHAP challenge byte "
634
-			      "\"%s\"\n", iscsi, buf );
635
+			DBGC ( iscsi, "iSCSI %p saw invalid CHAP challenge "
636
+			       "byte \"%s\"\n", iscsi, buf );
635
 		}
637
 		}
636
 		chap_update ( &iscsi->chap, &byte, sizeof ( byte ) );
638
 		chap_update ( &iscsi->chap, &byte, sizeof ( byte ) );
637
 	}
639
 	}
638
 
640
 
639
 	/* Build CHAP response */
641
 	/* Build CHAP response */
640
-	DBG ( "iSCSI %p sending CHAP response\n", iscsi );
642
+	DBGC ( iscsi, "iSCSI %p sending CHAP response\n", iscsi );
641
 	chap_respond ( &iscsi->chap );
643
 	chap_respond ( &iscsi->chap );
642
 	iscsi->status |= ISCSI_STATUS_STRINGS_CHAP_RESPONSE;
644
 	iscsi->status |= ISCSI_STATUS_STRINGS_CHAP_RESPONSE;
643
 }
645
 }
683
 	for ( type = iscsi_string_types ; type->key ; type++ ) {
685
 	for ( type = iscsi_string_types ; type->key ; type++ ) {
684
 		key_len = strlen ( type->key );
686
 		key_len = strlen ( type->key );
685
 		if ( strncmp ( string, type->key, key_len ) == 0 ) {
687
 		if ( strncmp ( string, type->key, key_len ) == 0 ) {
686
-			DBG ( "iSCSI %p handling %s\n", iscsi, string );
688
+			DBGC ( iscsi, "iSCSI %p handling %s\n",
689
+			       iscsi, string );
687
 			type->handle_value ( iscsi, ( string + key_len ) );
690
 			type->handle_value ( iscsi, ( string + key_len ) );
688
 			return;
691
 			return;
689
 		}
692
 		}
690
 	}
693
 	}
691
-	DBG ( "iSCSI %p ignoring %s\n", iscsi, string );
694
+	DBGC ( iscsi, "iSCSI %p ignoring %s\n", iscsi, string );
692
 }
695
 }
693
 
696
 
694
 /**
697
 /**
732
 
735
 
733
 	/* Buffer up the PDU data */
736
 	/* Buffer up the PDU data */
734
 	if ( ( rc = iscsi_rx_buffered_data ( iscsi, data, len ) ) != 0 ) {
737
 	if ( ( rc = iscsi_rx_buffered_data ( iscsi, data, len ) ) != 0 ) {
735
-		DBG ( "iSCSI %p could not buffer login response\n", iscsi );
738
+		DBGC ( iscsi, "iSCSI %p could not buffer login response: %s\n",
739
+		       iscsi, strerror ( rc ) );
736
 		iscsi_close ( iscsi );
740
 		iscsi_close ( iscsi );
737
 		iscsi_done ( iscsi, rc );
741
 		iscsi_done ( iscsi, rc );
738
 		return;
742
 		return;
746
 
750
 
747
 	/* Check for login redirection */
751
 	/* Check for login redirection */
748
 	if ( response->status_class == ISCSI_STATUS_REDIRECT ) {
752
 	if ( response->status_class == ISCSI_STATUS_REDIRECT ) {
749
-		DBG ( "iSCSI %p redirecting to new server\n", iscsi );
753
+		DBGC ( iscsi, "iSCSI %p redirecting to new server\n", iscsi );
750
 		iscsi_close ( iscsi );
754
 		iscsi_close ( iscsi );
751
 		if ( ( rc = tcp_connect ( &iscsi->tcp, &iscsi->target,
755
 		if ( ( rc = tcp_connect ( &iscsi->tcp, &iscsi->target,
752
 					  0 ) ) != 0 ) {
756
 					  0 ) ) != 0 ) {
753
-			DBG ( "iSCSI %p could not open TCP connection\n",
754
-			      iscsi );
757
+			DBGC ( iscsi, "iSCSI %p could not open TCP "
758
+			       "connection: %s\n", iscsi, strerror ( rc ) );
755
 			iscsi_done ( iscsi, rc );
759
 			iscsi_done ( iscsi, rc );
756
 		}
760
 		}
757
 		return;
761
 		return;
759
 
763
 
760
 	/* Check for fatal errors */
764
 	/* Check for fatal errors */
761
 	if ( response->status_class != 0 ) {
765
 	if ( response->status_class != 0 ) {
762
-		DBG ( "iSCSI login failure: class %02x detail %02x\n",
763
-		      response->status_class, response->status_detail );
766
+		DBGC ( iscsi, "iSCSI login failure: class %02x detail %02x\n",
767
+		       response->status_class, response->status_detail );
764
 		iscsi->instant_rc = -EPERM;
768
 		iscsi->instant_rc = -EPERM;
765
 		iscsi_close ( iscsi );
769
 		iscsi_close ( iscsi );
766
 		iscsi_done ( iscsi, -EPERM );
770
 		iscsi_done ( iscsi, -EPERM );
779
 			iscsi->status = ISCSI_STATUS_FULL_FEATURE_PHASE;
783
 			iscsi->status = ISCSI_STATUS_FULL_FEATURE_PHASE;
780
 			break;
784
 			break;
781
 		default:
785
 		default:
782
-			DBG ( "iSCSI %p got invalid response flags %02x\n",
783
-			      iscsi, response->flags );
786
+			DBGC ( iscsi, "iSCSI %p got invalid response flags "
787
+			       "%02x\n", iscsi, response->flags );
784
 			iscsi_close ( iscsi );
788
 			iscsi_close ( iscsi );
785
 			iscsi_done ( iscsi, -EIO );
789
 			iscsi_done ( iscsi, -EIO );
786
 			return;
790
 			return;
1018
 	default:
1022
 	default:
1019
 		if ( remaining )
1023
 		if ( remaining )
1020
 			return;
1024
 			return;
1021
-		DBG ( "Unknown iSCSI opcode %02x\n", response->opcode );
1025
+		DBGC ( iscsi, "iSCSI %p unknown opcode %02x\n", iscsi,
1026
+		       response->opcode );
1022
 		iscsi_close ( iscsi );
1027
 		iscsi_close ( iscsi );
1023
 		iscsi_done ( iscsi, -EOPNOTSUPP );
1028
 		iscsi_done ( iscsi, -EOPNOTSUPP );
1024
 		break;
1029
 		break;
1056
 			   size_t len, size_t remaining __unused ) {
1061
 			   size_t len, size_t remaining __unused ) {
1057
 	memcpy ( &iscsi->rx_bhs.bytes[iscsi->rx_offset], data, len );
1062
 	memcpy ( &iscsi->rx_bhs.bytes[iscsi->rx_offset], data, len );
1058
 	if ( ( iscsi->rx_offset + len ) >= sizeof ( iscsi->rx_bhs ) ) {
1063
 	if ( ( iscsi->rx_offset + len ) >= sizeof ( iscsi->rx_bhs ) ) {
1059
-		DBG ( "iSCSI %p received PDU opcode %#x len %#lx\n",
1060
-		      iscsi, iscsi->rx_bhs.common.opcode,
1061
-		      ISCSI_DATA_LEN ( iscsi->rx_bhs.common.lengths ) );
1064
+		DBGC ( iscsi, "iSCSI %p received PDU opcode %#x len %#lx\n",
1065
+		       iscsi, iscsi->rx_bhs.common.opcode,
1066
+		       ISCSI_DATA_LEN ( iscsi->rx_bhs.common.lengths ) );
1062
 	}
1067
 	}
1063
 }
1068
 }
1064
 
1069
 
1154
 
1159
 
1155
 	/* Retry connection if within the retry limit, otherwise fail */
1160
 	/* Retry connection if within the retry limit, otherwise fail */
1156
 	if ( ++iscsi->retry_count <= ISCSI_MAX_RETRIES ) {
1161
 	if ( ++iscsi->retry_count <= ISCSI_MAX_RETRIES ) {
1157
-		DBG ( "iSCSI %p retrying connection (retry #%d)\n",
1158
-		      iscsi, iscsi->retry_count );
1162
+		DBGC ( iscsi, "iSCSI %p retrying connection (retry #%d)\n",
1163
+		       iscsi, iscsi->retry_count );
1159
 		if ( ( rc = tcp_connect ( app, &iscsi->target, 0 ) ) != 0 ) {
1164
 		if ( ( rc = tcp_connect ( app, &iscsi->target, 0 ) ) != 0 ) {
1160
-			DBG ( "iSCSI %p could not open TCP connection\n",
1161
-			      iscsi );
1165
+			DBGC ( iscsi, "iSCSI %p could not open TCP "
1166
+			       "connection: %s\n", iscsi, strerror ( rc ) );
1162
 			iscsi_done ( iscsi, rc );
1167
 			iscsi_done ( iscsi, rc );
1163
 		}
1168
 		}
1164
 	} else {
1169
 	} else {
1165
-		DBG ( "iSCSI %p retry count exceeded\n", iscsi );
1170
+		DBGC ( iscsi, "iSCSI %p retry count exceeded\n", iscsi );
1166
 		iscsi->instant_rc = status;
1171
 		iscsi->instant_rc = status;
1167
 		iscsi_done ( iscsi, status );
1172
 		iscsi_done ( iscsi, status );
1168
 	}
1173
 	}
1226
 		iscsi->tcp.tcp_op = &iscsi_tcp_operations;
1231
 		iscsi->tcp.tcp_op = &iscsi_tcp_operations;
1227
 		if ( ( rc = tcp_connect ( &iscsi->tcp, &iscsi->target,
1232
 		if ( ( rc = tcp_connect ( &iscsi->tcp, &iscsi->target,
1228
 					  0 ) ) != 0 ) {
1233
 					  0 ) ) != 0 ) {
1229
-			DBG ( "iSCSI %p could not open TCP connection\n",
1230
-			      iscsi );
1234
+			DBGC ( iscsi, "iSCSI %p could not open TCP "
1235
+			       "connection: %s\n", iscsi, strerror ( rc ) );
1231
 			iscsi_done ( iscsi, rc );
1236
 			iscsi_done ( iscsi, rc );
1232
 		}
1237
 		}
1233
 	}
1238
 	}

Loading…
Cancel
Save